The REST API lets you recalculate the purchase and sales price of a bill of materials using the actions prepocti-nakupni-cenu and prepocti-prodejni-cenu. This is used to adjust the product price when the prices of the materials it consists of have changed. These are the same services that operate behind these buttons in the application:
The recalculation sums the material prices multiplied by their quantities and writes the result to the parent price list item — into nakupCena or cenaZakl, respectively. The kusovnik record itself does not hold any prices.
⚠️ The actions only add up prices from a single level of the bill of materials. If a bill of materials consists of other bills of materials, recalculate those first — work your way up from the lowest level.
ℹ️ During actual production, i.e. when the finished product is received into stock, the price of the received product is calculated automatically based on the actual price of the consumed material — regardless of the price stated in the bill of materials. You can find more about the bill of materials in the record description.
Recalculating a specific bill of materials
The action is triggered via import using the action attribute; send the request using the POST or PUT method:
POST https://demo.flexibee.eu/c/demo/kusovnik.xml
<winstrom version="1.0">
<kusovnik id="123" action="prepocti-nakupni-cenu"/>
</winstrom>
The same in JSON — the action name is written as @action:
{
"winstrom": {
"kusovnik": {
"id": "123",
"@action": "prepocti-nakupni-cenu"
}
}
}
The response is a standard import result with 201 Created and the ID of the recalculated bill of materials:
{
"winstrom": {
"@version": "1.0",
"success": "true",
"stats": {
"created": "0",
"updated": "1",
"deleted": "0",
"skipped": "0",
"failed": "0"
},
"results": [
{
"id": "123",
"request-id": "123",
"ref": "/c/demo/kusovnik/123.json"
}
]
}
}
Recalculating an entire level
The bill of materials level (hladina) determines which level you are about to recalculate. Instead of an ID, use the filter attribute, and the action will be performed on all bills of materials that match the filter:
<winstrom version="1.0">
<kusovnik filter="hladina eq 1" action="prepocti-nakupni-cenu"/>
</winstrom>
And the same query in JSON:
{
"winstrom": {
"kusovnik": {
"@filter": "hladina eq 1",
"@action": "prepocti-nakupni-cenu"
}
}
}
You can read the number of records actually recalculated from updated in the response — a filter on a level typically affects tens of bills of materials.
Failed requests
Situation | Response |
The specified bill of materials does not exist |
|
Typo in the action name |
|
The filter does not comply with the filtering rules |
|
The filtered level contains no bill of materials |
|

