Skip to main content

Ordering goods in a received order

Creating an issued order from a received order via REST API

Written by Petr Pech

Ordering items from a received order (OBP) via an issued order (OBV) is implemented in the REST API as a virtual record /objednani. It has two sub-resources:

Address

Methods

What it does

/c/{firma}/objednani/polozek

POST, PUT

Creates an issued order (OBV) for the specified suppliers and the selected received order (OBP) items, with the quantities to be ordered.

/c/{firma}/objednani/hromadne

POST, PUT, GET

Automatically creates issued orders (OBV) from all received order (OBP) items that have a primary supplier set.


Ordering selected items

In the request body, include the objednaniPolozek element with the following properties:

POST https://demo.flexibee.eu/c/demo/objednani/polozek.json
{
"winstrom": {
"@version": "1.0",
"objednaniPolozek": {
"typDokl": "code:OBV",
"dodavatel": "code:AAA",
"polozkyObp": [
{ "id": 3704, "mnozMj": 2 },
{ "id": 3706, "mnozMj": 3 }
]
}
}
}

The response is 201 Created containing the IDs of the created issued orders (OBV):

{
"winstrom": {
"@version": "1.0",
"success": true,
"stats": {
"created": 1,
"updated": 0,
"deleted": 0,
"skipped": 0,
"failed": 0
},
"results": [
{ "id": 1638 }
]
}
}

⚠️ The property names are dodavatel and mnozMj. Using any other naming will cause the server to reject the request and return a list of allowed elements — for example, dodavatelFirma returns 400 with the message unexpected element … Expected elements are <dodavatel>, <polozkyObp>, <typDokl>. Omitting dodavatel returns 400 with the code importXmlMissingIdentifier.

Multiple suppliers in a single request

The objednaniPolozek element can be included multiple times in a single request — a separate issued order (OBV) is created for each supplier:

{
"winstrom": {
"@version": "1.0",
"objednaniPolozek": [
{
"typDokl": "code:OBV",
"dodavatel": "code:AAA",
"polozkyObp": [
{ "id": 3709, "mnozMj": 2 },
{ "id": 3711, "mnozMj": 3 }
]
},
{
"typDokl": "code:OBV",
"dodavatel": "code:ABC",
"polozkyObp": [
{ "id": 3715, "mnozMj": 4 },
{ "id": 3717, "mnozMj": 5 }
]
}
]
}
}

The response is again 201 Created, this time with two created issued orders (OBV):

{
"winstrom": {
"@version": "1.0",
"success": true,
"stats": {
"created": 2,
"updated": 0,
"deleted": 0,
"skipped": 0,
"failed": 0
},
"results": [
{ "id": 1663 },
{ "id": 1664 }
]
}
}


Bulk ordering

Bulk ordering creates issued orders (OBV) from all received order (OBP) items that have a primary supplier set. It only requires typDokl, either in the request body or as a query parameter.

POST https://demo.flexibee.eu/c/demo/objednani/hromadne.json
{
"winstrom": {
"@version": "1.0",
"objednaniHromadne": {
"typDokl": "code:OBV"
}
}
}

You can achieve the same result using the GET method with the document type as a parameter:

GET https://demo.flexibee.eu/c/demo/objednani/hromadne.json?typDokl=code:OBV

In both cases, the response is 201 Created containing a list of the IDs of the created issued orders (OBV):

{
"winstrom": {
"@version": "1.0",
"success": true,
"stats": {
"created": 2,
"updated": 0,
"deleted": 0,
"skipped": 0,
"failed": 0
},
"results": [
{ "id": 1639 },
{ "id": 1640 }
]
}
}

🚨 Bulk ordering does not respect the dry-run parameter ?dry-run=true — issued orders will be created even when it is used. Therefore, do not try this call "just to test" in your production company.


Failed requests

If none of the submitted items can be ordered, the service returns 400 Bad Request with the code obchodGenerNicProHromObj:

{
"winstrom": {
"@version": 1,
"success": false,
"message": "Nebyly nalezeny žádné položky vhodné pro objednání."
}
}

Omitting typDokl for bulk ordering returns 400 with the code importXmlMissingIdentifier and the message Identifikátor (typDokl) není uveden.


Related

Did this answer your question?