Just like in the desktop or web application, it is possible to allocate ancillary costs into the price of goods, and this functionality is also available via the REST API.
In the API, the allocation of ancillary costs is always performed on a warehouse document, specifically a goods receipt — only there is the allocation function available.
Allocation methods
Ancillary costs can be allocated in two ways:
Method | How it's calculated |
By price | Costs are allocated in the same ratio to all prices per unit. For example, the delivery price is 1,000 CZK and the ancillary costs are 500 CZK, i.e. 50% of the purchase price — each purchase price per unit is therefore also increased by 50%. |
By pieces | The costs are divided by the number of pieces in the delivery, and the acquisition price per unit is increased by the resulting amount. For example, there are 20 pieces in the delivery and the ancillary costs are 500 CZK — the price per unit for each item will be increased by 25 CZK regardless of the existing purchase prices per unit. |
Calling method
The request is sent using the method PUT or POST to the skladovy-pohyb record. In the request body, specify the document's identifier and the element rozuctuj with the following properties:
vedlejsiNaklady— required amount of ancillary costs to be allocatedpodleCeny— optional flagtrue/false. If not specified, or set tofalse, the costs will be allocated by number of pieces.
PUT https://demo.flexibee.eu/c/demo/skladovy-pohyb.xml
⚠️ Without the vedlejsiNaklady property, the server will return 400 with code undefinedProperty and the message Není definována vlastnost "vedlejsiNaklady".
Usage examples
Allocating 500 CZK by price in XML
<winstrom version="1.0">
<skladovy-pohyb>
<id>1015</id>
<rozuctuj>
<vedlejsiNaklady>500</vedlejsiNaklady>
<podleCeny>true</podleCeny>
</rozuctuj>
</skladovy-pohyb>
</winstrom>
Allocating 500 CZK by pieces in XML
<winstrom version="1.0">
<skladovy-pohyb>
<id>1015</id>
<rozuctuj>
<vedlejsiNaklady>500</vedlejsiNaklady>
<podleCeny>false</podleCeny>
</rozuctuj>
</skladovy-pohyb>
</winstrom>
On success, the response is:
<winstrom version="1.0">
<success>true</success>
<stats>
<created>0</created>
<updated>1</updated>
<deleted>0</deleted>
<skipped>0</skipped>
<failed>0</failed>
</stats>
<results>
<result>
<id>1015</id>
<request-id>1015</request-id>
<ref>/c/demo/skladovy-pohyb/1015.xml</ref>
</result>
</results>
</winstrom>
Allocating 500 CZK by price in JSON
{
"winstrom": {
"@version": "1.0",
"skladovy-pohyb": [
{
"id": "1015",
"rozuctuj": {
"vedlejsiNaklady": 500,
"podleCeny": true
}
}
]
}
}
On success, the response is:
{
"winstrom": {
"@version": "1.0",
"success": "true",
"stats": {
"created": "0",
"updated": "1",
"deleted": "0",
"skipped": "0",
"failed": "0"
},
"results": [
{
"id": "1015",
"request-id": "1015",
"ref": "/c/demo/skladovy-pohyb/1015.json"
}
]
}
}
Result on the document
The result is changed item prices on the document. For a document that originally had a cenaMj of 100 and two units, after allocating 50 CZK by pieces, the ancillary costs will appear in the cenaMjNakl item as follows:
<winstrom version="1.0">
<skladovy-pohyb>
<id>code:S+0001/2024</id>
<polozkyDokladu>
<skladovy-pohyb-polozka>
<mnozMj>2.0</mnozMj>
<cenaMj>125.0</cenaMj>
<cenaMjNakl>25.0</cenaMjNakl>
<cenaMjPoriz>100.0</cenaMjPoriz>
<sumCelkem>250.0</sumCelkem>
</skladovy-pohyb-polozka>
</polozkyDokladu>
</skladovy-pohyb>
</winstrom>
💡 First try out the entry with the ?dry-run=true parameter. The request will be processed and validated, but nothing will be written to the database.
