Salt la conținut
Documentație

Caută în documentație

    English

    Revizii și concurență

    Fiecare sold are o revizie care crește la fiecare mișcare. O comandă poartă revizia citită și este refuzată dacă soldul s‑a schimbat între timp.

    Pe această pagină

    Mai multe sisteme modifică același stoc: ERP‑ul rezervă, casa de marcat vinde, depozitul inventariază. Reviziile le împiedică să se suprascrie între ele.

    Revizia unui sold

    Revizia unui sold este numărul de mișcări înregistrate pentru acel articol la acea locație. Un sold nou este la revizia 0. O citești din disponibil sau din resultingRevision al ultimei mișcări din fișa de stoc.

    expectedRevision

    Fiecare linie indică soldul pe care îl modifică și revizia citită, ca expectedRevision. O linie de transfer are două: fromExpectedRevision și toExpectedRevision. O linie de stornare indică o mișcare, iar expectedRevision al ei este cel al soldului de care ține mișcarea, așa cum este acum.

    Dacă oricare sold al comenzii este la altă revizie, răspunsul este un 409 cu revision_conflict și nu se aplică nimic: nici linia aceea, nici celelalte.

    O rezervare care a citit o revizie mai veche a făinii

    curl

    curl -X POST "$RDC_BASE_URL/inventory/v1/reservations" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:19:00Z",
      "source": {
        "service": "erp",
        "documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
        "documentType": "sales-order",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
      },
      "lines": [
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "10",
          "expectedRevision": 5
        }
      ]
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/reservations`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
        "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
        "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
        "occurredAt": "2026-11-23T07:19:00Z",
        "source": {
          "service": "erp",
          "documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
          "documentType": "sales-order",
          "documentRevision": 1
        },
        "actor": {
          "serviceId": "brumar-erp",
          "userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
        },
        "lines": [
          {
            "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
            "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
            "quantity": "10",
            "expectedRevision": 5
          }
        ]
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/inventory/v1/reservations',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': 'e3f4095f-d443-4219-a81e-abdd81abec57',
            'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
            'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
            'occurredAt': '2026-11-23T07:19:00Z',
            'source': {
                'service': 'erp',
                'documentId': '59bebeb2-d0f4-439c-a445-74c4fa0f971c',
                'documentType': 'sales-order',
                'documentRevision': 1,
            },
            'actor': {
                'serviceId': 'brumar-erp',
                'userId': '4e2f591e-3df0-4f36-8741-3e49134249b0',
            },
            'lines': [
                {
                    'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
                    'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                    'quantity': '10',
                    'expectedRevision': 5,
                },
            ],
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:19:00Z",
      "source": {
        "service": "erp",
        "documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
        "documentType": "sales-order",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
      },
      "lines": [
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "10",
          "expectedRevision": 5
        }
      ]
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/reservations');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => $body,
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/inventory/v1/reservations");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "e3f4095f-d443-4219-a81e-abdd81abec57",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:19:00Z",
      "source": {
        "service": "erp",
        "documentId": "59bebeb2-d0f4-439c-a445-74c4fa0f971c",
        "documentType": "sales-order",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "4e2f591e-3df0-4f36-8741-3e49134249b0"
      },
      "lines": [
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "10",
          "expectedRevision": 5
        }
      ]
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Răspuns 409

    {
      "code": "revision_conflict",
      "message": "A balance has changed since the revision you sent.",
      "requestId": "req_4f9d2a7c1b6e8035"
    }

    După un conflict

    1. Citește din nou

      Citește disponibilul fiecărui sold al comenzii. Revizia și cantitățile sunt actuale.

    2. Hotărăște

      Dacă modificarea mai are sens: o rezervare poate depăși acum ce este disponibil.

    3. Trimite o comandă nouă

      Trimite‑o cu reviziile noi și cu un operationId nou. Comanda refuzată nu a schimbat nimic și nu a lăsat nicio înregistrare.

    curl

    curl -X POST "$RDC_BASE_URL/inventory/v1/receipts" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:26:00Z",
      "source": {
        "service": "erp",
        "documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
        "documentType": "goods-receipt",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "100",
          "expectedRevision": 7
        },
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "60",
          "expectedRevision": 7
        },
        {
          "productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "40",
          "expectedRevision": 3
        }
      ]
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/inventory/v1/receipts`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
        "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
        "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
        "occurredAt": "2026-11-23T07:26:00Z",
        "source": {
          "service": "erp",
          "documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
          "documentType": "goods-receipt",
          "documentRevision": 1
        },
        "actor": {
          "serviceId": "brumar-erp",
          "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
        },
        "lines": [
          {
            "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
            "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
            "quantity": "100",
            "expectedRevision": 7
          },
          {
            "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
            "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
            "quantity": "60",
            "expectedRevision": 7
          },
          {
            "productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
            "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
            "quantity": "40",
            "expectedRevision": 3
          }
        ]
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/inventory/v1/receipts',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '4bfa0af7-a8f7-4d84-ae30-792b7a99b286',
            'customerOrgId': '690fa0e3-547f-4f93-96b7-824475cc3d7c',
            'legalCompanyId': 'd84ba982-ca9a-4e91-9566-21bd23f7227b',
            'occurredAt': '2026-11-23T07:26:00Z',
            'source': {
                'service': 'erp',
                'documentId': '978dd1f4-5f65-4307-9b96-beb995212227',
                'documentType': 'goods-receipt',
                'documentRevision': 1,
            },
            'actor': {
                'serviceId': 'brumar-erp',
                'userId': '376a64f7-268a-4f79-808e-0d89162055ac',
            },
            'lines': [
                {
                    'productId': '11079e9a-344b-409c-8da5-e8335a7846b1',
                    'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                    'quantity': '100',
                    'expectedRevision': 7,
                },
                {
                    'productId': '6cbfcba3-55fd-4cf0-9709-6e75c9717bb3',
                    'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                    'quantity': '60',
                    'expectedRevision': 7,
                },
                {
                    'productId': '109ebad9-6627-4ac3-817e-f81ad628676b',
                    'locationId': 'b006344d-2fae-4970-bb6f-c32877084b4f',
                    'quantity': '40',
                    'expectedRevision': 3,
                },
            ],
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:26:00Z",
      "source": {
        "service": "erp",
        "documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
        "documentType": "goods-receipt",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "100",
          "expectedRevision": 7
        },
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "60",
          "expectedRevision": 7
        },
        {
          "productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "40",
          "expectedRevision": 3
        }
      ]
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/inventory/v1/receipts');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => $body,
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/inventory/v1/receipts");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
      "customerOrgId": "690fa0e3-547f-4f93-96b7-824475cc3d7c",
      "legalCompanyId": "d84ba982-ca9a-4e91-9566-21bd23f7227b",
      "occurredAt": "2026-11-23T07:26:00Z",
      "source": {
        "service": "erp",
        "documentId": "978dd1f4-5f65-4307-9b96-beb995212227",
        "documentType": "goods-receipt",
        "documentRevision": 1
      },
      "actor": {
        "serviceId": "brumar-erp",
        "userId": "376a64f7-268a-4f79-808e-0d89162055ac"
      },
      "lines": [
        {
          "productId": "11079e9a-344b-409c-8da5-e8335a7846b1",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "100",
          "expectedRevision": 7
        },
        {
          "productId": "6cbfcba3-55fd-4cf0-9709-6e75c9717bb3",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "60",
          "expectedRevision": 7
        },
        {
          "productId": "109ebad9-6627-4ac3-817e-f81ad628676b",
          "locationId": "b006344d-2fae-4970-bb6f-c32877084b4f",
          "quantity": "40",
          "expectedRevision": 3
        }
      ]
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Răspuns 202

    {
      "operationId": "4bfa0af7-a8f7-4d84-ae30-792b7a99b286",
      "status": "completed",
      "aggregateRevision": 8,
      "movementIds": [
        "cd93538c-9b49-4605-97b7-b9b2eb2ea9d6",
        "ead9c438-3b01-4074-8613-c6e7d090fd80",
        "b02ec58f-c921-4591-899e-22679fccb209"
      ]
    }