Ordering items from a received order using an issued order is implemented as a virtual record /objednani. It has two subresources:
/polozek
creates an issued purchase order (OBV) of the given type from selected items of the received order (OBP), ordering all items from the specified supplier
called using POST or PUT methods and requires the following parameters:
typDokl - id or code of an object from the /typ-objednavky-vydane record
dodavatelFirma - id or code of an object from the /adresar record
polozkyObp
id of objects from the /objednavka-prijata-polozka record
mnozstvi - the quantity to be ordered
/hromadne
creates an OBV from all OBP items that have a supplier assigned
called using POST, PUT, or GET methods and requires only typDokl (either in the request body or as a query parameter).
The endpoints are therefore:
/objednani/polozek – for creating issued purchase orders for specified suppliers and OBP items, including the quantity to be ordered
/objednani/hromadne – for automatically creating OBV records from all OBP items that have a primary supplier assigned
Examples:
1. Request to the /objednani/polozek resource
curl -k -X POST 'https://localhost:5434/v2/c/fcn_obv/objednani/polozek' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"winstrom":{"@version":"1.0","objednaniPolozek":{"typDokl":"code:OBV","dodavatelFirma":"code:AAA","polozkyObp":[{"id":3704,"mnozstvi":2},{"id":3706,"mnozstvi":3}]}}}' -u admin:adminadmin | jqsends data in the following format
{
"winstrom": {
"@version": "1.0",
"objednaniPolozek": {
"typDokl": "code:OBV",
"dodavatel": "code:AAA",
"polozkyObp": [
{
"id": 3704,
"mnozMj": 2
},
{
"id": 3706,
"mnozMj": 3
}
]
}
}
}and receives a 200 OK response with the id of the OBV that was created
{ "winstrom": { "@version": "1.0", "success": true, "stats": { "created": 1, "updated": 0, "deleted": 0, "skipped": 0, "failed": 0 }, "results": [ { "id": 1638 } ] }}or 400 Bad Request
{ "winstrom": { "@version": 1, "success": false, "message": "Nebyly nalezeny \u017e\u00e1dn\u00e9 polo\u017eky vhodn\u00e9 pro objedn\u00e1n\u00ed." }}if none of the submitted items can be ordered.
2. Multiple orders on the /objednani/polozek resource
curl -k -X POST 'https://localhost:5434/v2/c/fcn_obv/objednani/polozek' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"winstrom":{"@version":"1.0","objednaniPolozek":[{"typDokl":"code:OBV","dodavatelFirma":"code:AAA","polozkyObp":[{"id":3709,"mnozstvi":2},{"id":3711,"mnozstvi":3}]},{"typDokl":"code:OBV","dodavatelFirma":"code:ABC","polozkyObp":[{"id":3715,"mnozstvi":4},{"id":3717,"mnozstvi":5}]}]}}' -u admin:adminadmin | jqsends data in the following format
{"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
}]}
]}
}{ "winstrom": { "@version": "1.0", "success": true, "stats": { "created": 2, "updated": 0, "deleted": 0, "skipped": 0, "failed": 0 }, "results": [ { "id": 1663 }, { "id": 1664 } ] }}3. Request to the /objednani/hromadne resource
curl -k -X POST 'https://localhost:5434/v2/c/fcn_obv/objednani/hromadne' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"winstrom":{"@version":"1.0","objednaniHromadne":{"typDokl":"code:OBV"}}}' -u admin:adminadmin | jq
sends data in the following format
{ "winstrom": { "@version": "1.0", "objednaniHromadne": { "typDokl": "code:OBV" } }}or similarly using GET
curl -k -X GET 'https://localhost:5434/v2/c/fcn_obv/objednani/hromadne?typDokl=code%3AOBV' -H 'Accept: application/json' -u admin:adminadmin
with the query parameter typDokl=code:OBV, the 200 OK response contains a list of IDs of the OBV records that were created
{ "winstrom": { "@version": "1.0", "success": true, "stats": { "created": 2, "updated": 0, "deleted": 0, "skipped": 0, "failed": 0 }, "results": [ { "id": 1639 }, { "id": 1640 } ] }}or 400 Bad Request
{ "winstrom": { "@version": 1, "success": false, "message": "Nebyly nalezeny \u017e\u00e1dn\u00e9 polo\u017eky vhodn\u00e9 pro objedn\u00e1n\u00ed." }}