A set or kit consists of other price list items. Its "stock status" is therefore based on the stock levels of the individual components — and these can be retrieved with a single query.
Set composition
The components are held by the relation sady-a-komplety:
GET /c/{firma}/cenik/code:SADA.xml?detail=custom:kod,sada,sady-a-komplety(cenik,mnozMj)
For each component, a link to the price list item and the quantity included in the set are returned.
Stock status of components
Expanding all the way to the stock cards adds the stock levels of the individual components to the output:
GET /c/{firma}/cenik/code:SADA.xml
?detail=custom:kod,sady-a-komplety(cenik(kod,skladKarty(stavMJ,sklad)))
&includes=/cenik/sady-a-komplety/sady-a-komplety/cenik/,
/cenik/sady-a-komplety/sady-a-komplety/cenik/skladKarty/skladova-karta/
The result includes, for each component, a list of stock cards with the field stavMJ — i.e., how many units are in which warehouse:
<sady-a-komplety>
<cenik>
<kod>8806086522977</kod>
<skladKarty>
<skladova-karta>
<stavMJ>3.0</stavMJ>
<sklad showAs="LIBEREC">code:LIBEREC</sklad>
</skladova-karta>
<skladova-karta>
<stavMJ>11.0</stavMJ>
<sklad showAs="PLZEŇ">code:PLZEŇ</sklad>
</skladova-karta>
</skladKarty>
</cenik>
</sady-a-komplety>
ℹ️ How many sets can actually be assembled must be calculated by the caller — it's the smallest ratio of stavMJ to the quantity of the component in the set. Flexi does not maintain this figure for the set itself.
💡 The includes parameter specifies which relations should be expanded instead of just linked; the principle is described in the article Using includes. The relations parameter is not needed for this query — the relation specified in detail=custom is included in the output automatically.
