Skip to main content

The last price is not filled in for an item when creating a goods receipt via the API

Using previousValue in a Receiver - API

Written by Petr Pech

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

<cenik>code:KOD_CENIK</cenik>

0.0

<cenik previousValue="">code:KOD_CENIK</cenik>

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.


Related

Did this answer your question?