In both the desktop and web applications, when you add an item to a receipt, the last price at which the item was previously received is pre-filled. Via the API, this doesn't happen by default — Flexi assumes you provide the price yourself, and creates the item with a zero price if none is given.
How to fill in the last price
Adding an empty previousValue attribute to the cenik element will make this happen. This makes Flexi behave as if the user had just selected the item in the application:
<winstrom version="1.0">
<skladovy-pohyb>
<typDokl>code:PŘÍJEMKA</typDokl>
<typPohybuK>typPohybu.prijem</typPohybuK>
<sklad>code:SKLAD</sklad>
<skladovePolozky>
<skladovy-pohyb-polozka>
<cenik previousValue="">code:KOD_CENIK</cenik>
<sklad>code:SKLAD</sklad>
<mnozMj>10</mnozMj>
</skladovy-pohyb-polozka>
</skladovePolozky>
</skladovy-pohyb>
</winstrom>
The difference is immediately visible on the resulting item:
Request | Price per unit on the item |
|
|
| the item's last purchase price |
💡 The price filled in this way is an estimate — the last known purchase price. The actual price may differ from it, but it's usually closer to reality than zero, so it's useful until you receive the invoice from the supplier. You can of course overwrite the price at any time.
ℹ️ The previousValue attribute tells Flexi what the previous value of the field was — this triggers the same logic as when the field is changed manually in the application. It's also used elsewhere, for example when changing the document type or exchange rate.
