Skip to main content

# Overview of REST API

How to Perform an Inventory Using the Flexi REST API?

Written by Petr Pech

Stock inventory can be managed via the REST API. Three services are available — inserting items into the inventory, updating system quantities, and generating documents from the inventory.

Service

Method

Address

POST

/c/{firma}/inventura/{id}/vloz-polozky

GET

/c/{firma}/inventura/{id}/aktualizuj-stavy

GET

/c/{firma}/inventura/{id}/vygeneruj-doklady

Where {firma} is the database company identifier and {id} is the database identifier of the inventory. You can obtain a list of available inventories at /c/{firma}/inventura.xml?limit=0.


Insert items

Selected price lists are inserted into the inventory with the default quantity. Only price lists that are not yet in the inventory are inserted; the quantity of price lists already present in the inventory is not changed. Only stock cards belonging to the inventory's accounting period are accepted — cards from a different period will be skipped.

The request is sent using the POST method to the address /c/{firma}/inventura/{id}/vloz-polozky.{přípona}. Parameters are passed in the request body:

  • filter — 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

Sample request

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

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>

⚠️ This service only accepts the POST method. Calling it with the GET method returns 405 Method Not Allowed.

Inserting items via a record

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 identification of the inventory to which you want to add the item:

POST https://demo.flexibee.eu/c/demo/inventura-polozka.xml
<?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>


Update quantities

Updates the system quantity, which may differ from the one shown in the inventory due to stock movements created later. Once stock movements occur after the inventory has been created and items have been added, the quantities in the inventory items must be updated before generating documents.

This service is available using the GET method at the address /c/{firma}/inventura/{id}/aktualizuj-stavy.{přípona}. On success, HTTP status 200 is returned.

GET https://demo.flexibee.eu/c/demo/inventura/1/aktualizuj-stavy.xml

If an invalid inventory ID is provided, HTTP status 404 is returned with code formZaznamNenalezen:

<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 stock quantity matches the actual quantity. Based on the difference between the system and actual stock levels, stock receipts and issues are generated.

This service is available using the GET method at the address /c/{firma}/inventura/{id}/vygeneruj-doklady.{přípona}?typDoklId={idDokl}, where {idDokl} is the database identifier of the required document type for the stock movement from the /typ-skladovy-pohyb record.

GET https://demo.flexibee.eu/c/demo/inventura/1/vygeneruj-doklady.xml?typDoklId=1

If the service completes successfully, HTTP status 200 is returned. If the specified quantity differs from the system quantity:

<?xml version="1.0" ?>
<winstrom version="1.0">
<success>true</success>
<message>Doklady byly úspěšně vygenerovány.</message>
</winstrom>

If the specified quantity does not differ from the system quantity:

<?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 invalid inventory ID is provided, HTTP status 404 is returned with code formZaznamNenalezen:

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

⚠️ If an invalid document type ID is provided, no differences will be generated. If there is not enough stock available, the service returns 400 with a message of type Na položce s ID = 2 se vyskytla chyba: Na skladě není dostatek zboží.


FAQ

Where can I find a description of inventory in the application?

The general description is covered in the article Inventories, the procedure in the desktop application in Inventory - GUI, and in the web interface in Inventory - WUI.

Items with an incorrect stock quantity are being loaded into my inventory.

The causes are described in the articles Incorrect stock quantity in inventory and Discrepancy in inventory.

The inventory generates already generated items again.

You can find a solution in the article Generating items during inventory.

The inventory reports insufficient stock.

An explanation can be found in the article Inventory - insufficient stock.


Related

Did this answer your question?