Skip to main content

Inventory in REST API

How to Perform Inventory Using the Flexi REST API?

Written by Petr Pech

Stock inventory can be managed using the REST API. The API provides services for updating statuses in the inventory and generating documents from the inventory. Both actions can use the HTTP method: GET.

It is also possible to insert items into the inventory via the API. For this, we use the POST method.

The individual services are described in this documentation.

Adding inventory items via API

Selected price list items will be inserted into the inventory with their default quantity. Only those price list items that are not already present in the inventory will be inserted. It does not change the quantity for price list items that are already included in the inventory.

Only stock cards belonging to the accounting period of the inventory are accepted.

The service is available at: /c/{firma}/inventura/{id}/vloz-polozky, where {firma} is the database identifier of the company, {id} is the database identifier of the inventory.

Parameters are passed in the request body:

  • filter - is a filter for selecting stock cards

  • initialValueNull - with the value true specifies that the default quantity should be null, otherwise it will be 0.0.

Example:

<winstrom version="1.0">
<filter>(cenik in ('code:XO 253S SO I', 'code:XO CWAA1N000') and sklad = 'code:PLZEŇ')</filter>
<initialValueNull>true</initialValueNull>
</winstrom>

Stock cards belonging to a different accounting period than the inventory will be skipped.

The response indicates how many items were inserted into the inventory.

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<success>true</success>
<stats>
<created>2</created>
<updated>0</updated>
<deleted>0</deleted>
<skipped>0</skipped>
<failed>0</failed>
</stats>
<results>
<result></result>
</results>
</winstrom>

Legacy call:

Items can also be added to the inventory via the /inventura-polozka record. In the POST request, send the price list item code, the actual quantity in stock, and the identifier of the inventory to which you want to add the items.

Send the POST request to server:port/c/firma/inventura-polozka.xml

XML example:

<?xml version="1.0"?>
<winstrom>
<inventura-polozka>
<!-- kód ceníkové položky -->
<cenik>code:TRIKO123</cenik>
<!-- reálné množství zjištěné při inventuře fyzického skladu -->
<mnozmjreal>157</mnozmjreal>
<!-- identifikátor inventury, do které položku přidáváme -->
<inventura>3</inventura>
</inventura-polozka>
</winstrom>

The ID of an available inventory can be retrieved with a GET request at /inventura.xml?limit=0

Update statuses

Updates the system status, which may differ from the one recorded in the inventory due to stock movements created after the inventory was established. Once stock movements occur after the inventory has been created and items have been added, the statuses in the inventory items must be updated before generating documents.

The service is available at:

/c/{firma}/inventura/{id}/aktualizuj-stavy.xml(.json),

where {firma} is the database identifier of the company, {id} is the database identifier of the inventory.

If the service executes successfully, HTTP status 200 is returned.

Example call:

If an incorrect inventory ID is provided, HTTP status 404 is returned:

<message>Záznam nebyl v datovém zdroji nalezen: cz.winstrom.vo.skl.Inventura#12 (Inventury)</message>

Generate documents

Generates stock movements so that the system quantity in stock matches the actual quantity. Stock receipts and issues are generated based on the difference between the system and actual stock levels.

The service is available at:

/c/{firma}/inventura/{id}/vygeneruj-doklady.xml?typDoklId={idDokl},

where {firma} is the database identifier of the company,

{id} is the database identifier of the inventory,

{idDokl} is the database identifier of the required document type for the stock movement.

Example call:

If the service executes successfully, HTTP status 200 is returned along with the response:

  • If the entered status differs from the system status:

<?xml version="1.0" ?>
<winstrom version="1.0">
<success>true</success>
<message>Doklady byly úspěšně vygenerovány.</message>
</winstrom>
  • If the entered status does not differ from the system status:

<?xml version="1.0" ?>
<winstrom version="1.0">
<success>true</success>
<message>Při inventuře nevznikl žádný inventurní rozdíl.</message>
</winstrom>

If an incorrect inventory ID is provided, HTTP status 404 is returned:

<message>Záznam nebyl v datovém zdroji nalezen: cz.winstrom.vo.skl.Inventura#12 (Inventury)</message>

Note: if an incorrect document type ID is provided, no differences will be generated.

FAQ

Need help?
If you have any questions about the application, contact us at podporaflexi@abra.eu or via the chat window in the bottom right corner.

Did this answer your question?