Setting up the exchange of contracts between 1C and 1C-Bitrix counterparties

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Configuring Counterparty Contract Exchange Between 1C and 1C-Bitrix

In B2B online stores and wholesale portals, contracts are more than just documents. A contract defines: the price a client works at, their credit limit, and their delivery terms. Without transferring contracts from 1C to 1C-Bitrix, the site cannot display correct prices and conditions for a specific counterparty.

The role of a contract in 1C

In UT, KA, and ERP, a counterparty contract (CounterpartyContracts) is the key pricing object. The contract is linked to:

  • Price type — which price list applies to this client
  • Discounts — personal or contract-level discounts
  • Settlement currency
  • Credit limit and credit period
  • Payment terms (prepayment, post-payment, days of deferral)

If a client in 1C has 3 active contracts (e.g., retail, wholesale, and special), on the site they should see prices according to the relevant contract and be able to select a contract at checkout.

Contract transfer: architecture

Standard CommerceML does not transfer contracts. Custom synchronization via a 1C HTTP service or file exchange is required.

Minimum contract data set for the website:

{
  "guid": "a1b2c3d4-1234-...",
  "number": "C-2024-0015",
  "name": "Supply Contract No. 15 dated 01.03.2024",
  "contractor_guid": "counterparty-guid",
  "price_type_guid": "price-type-guid",
  "price_type_name": "Wholesale",
  "credit_limit": 500000,
  "payment_delay_days": 14,
  "currency": "RUB",
  "valid_from": "2024-03-01",
  "valid_to": "2025-03-01",
  "is_active": true
}

In 1C-Bitrix, contracts are stored in a HighloadBlock ContractorContracts. When the catalog is opened, the user's active contract is determined and linked to the price type in the trade catalog.

Mapping a contract to a price in 1C-Bitrix

The key task: a user with a specific contract must see prices from the associated price type.

Implementation:

  1. Upon user login — determine their contract(s) from the HighloadBlock
  2. Determine the price type from the contract (price_type_guid → price type ID in 1C-Bitrix)
  3. Set a session variable or user parameter CURRENT_PRICE_TYPE
  4. The catalog component reads this variable and displays prices of the required type

If the user has multiple contracts — provide a selection in the personal account: "Work under contract No. ...". The selection is saved in the session.

Contract synchronization: frequency

Contracts change rarely — a new contract is signed once a year, terms are revised quarterly. Synchronizing once per hour or even once per day is sufficient.

However, there is a critical scenario: a contract is terminated or has expired — the client must not continue to see wholesale prices. To handle this, add a valid_to check to the authentication logic. If the date has passed — switch the user to the base price type.

Contract at checkout

When transferring an order from 1C-Bitrix to 1C, the contract under which the order is placed must be specified. In the order XML:

<ЗначениеРеквизита>
  <Наименование>ContractId</Наименование>
  <Значение>a1b2c3d4-1234-...</Значение>
</ЗначениеРеквизита>

In UT, when creating a customer order, the contract is taken from this attribute. Without a contract — the order is created using the default (the counterparty's first active contract), which may lead to incorrect pricing in 1C documents.

Case study: distributor with individual terms

A medical equipment distributor: 180 dealers, each with an individual contract with their own price (discount from 5% to 40% off retail). All prices are maintained in UT as separate price types for each dealer (18 price types).

Website objective: each dealer upon login sees only their own prices; other dealers' prices are inaccessible.

Implementation:

  • Contract synchronization from UT to 1C-Bitrix — every 2 hours
  • Upon login — the contract is identified, and the price type GUID is extracted from it
  • The GUID is mapped to a price type in 1C-Bitrix (mapping table in settings)
  • The catalog displays prices of the required type

Additionally: each dealer has a "supervising manager" in UT. When an order is placed on the site, the manager is automatically added to the order (from the contract field ResponsibleManager). The manager in UT immediately sees their client's order.

Expiry and automatic renewal

When a contract is about to expire — N days before expiry, a notification is sent to the responsible manager in Bitrix24 (via REST API). A scheduled task in 1C-Bitrix checks the valid_to of all contracts daily.

// Contract expiry check agent
function checkContractExpiry() {
    $soon = date('Y-m-d', strtotime('+30 days'));
    $contracts = getContractsExpiringBefore($soon);
    foreach ($contracts as $contract) {
        notifyManager($contract['manager_id'], $contract);
    }
    return 'checkContractExpiry()'; // agent reschedules itself
}