Similarly to how it is possible in the desktop or web application to create an invoice and a cash document from a goods issue, the same can be done via the REST API.
The same applies to creating and completing a transfer order, provided that the warehouse document is an issue for a transfer order. If you are interested in how to do this, please refer to our other guide.
In this guide, however, we will show you how to perform these operations via the REST API. The similarity of these operations can be found in order fulfillment.
The creation of issued and received invoices, as well as cash documents, is handled by the realizaceSklPoh function. The realizaceSklPoh function supports two services.
The request can be sent using the PUT/POST method to a URL of the following type:
https://localhost:5434/v2/c/testovaci/skladovy-pohyb.json
Creating an invoice or cash document from a warehouse document is only supported by API v2. The URL must therefore include "v2" (see the example above).
In the request body, you then send the information listed below as needed.
Creating an Invoice
The service requires the use of two attributes:
type -
vytvorit-fakturutypDokl - object identifier from the
typ-faktury-prijateortyp-faktury-vydaneregister
Example XML entry for creating an invoice from a goods receipt or goods issue:
<winstrom version="1.0">
<skladovy-pohyb>
<id>123</id>
<realizaceSklPoh type="vytvorit-fakturu">
<typDokladu>code:FAKTURA</typDokladu>
</realizaceSklPoh>
</skladovy-pohyb>
</winstrom>
Example JSON entry for creating an invoice from a goods receipt or goods issue:
{
"winstrom":{
"skladovy-pohyb":[
{
"id":123,
"realizaceSklPoh":{
"@type":"vytvorit-fakturu",
"typDokl":"code:FAKTURA"
}
}
]
}
}
Whether a received or issued invoice is created depends on the movement type of the warehouse document. If it is a goods receipt, a received invoice will be created. If it is a goods issue, an issued invoice will be created.
If the goods issue was first created via order fulfillment, creating an invoice in this way will change the order status to "Done".
Creating a Cash Document
The service requires the use of two attributes (and an optional third):
type -
vytvorit-pokladni-dokladtypDokl - object identifier from the
typ-pokladni-pohybregisterbspandrada- optional, derived from the document type
Example XML entry for creating a cash document:
<winstrom version="1.0">
<skladovy-pohyb>
<id>321</id>
<realizaceSklPoh type="vytvorit-pokladni-doklad">
<typDokladu>code:POKLADNA</typDokladu>
</realizaceSklPoh>
</skladovy-pohyb>
</winstrom>
Example JSON entry for creating a cash document:
{
"winstrom":{
"skladovy-pohyb":[
{
"id":321,
"realizaceSklPoh":{
"@type":"vytvorit-pokladni-doklad",
"typDokl":"code:POKLADNA"
}
}
]
}
}
Whether a cash payment or cash receipt is created depends on the movement type of the warehouse document. If it is a goods receipt, a cash receipt document will be created. If it is a goods issue, a cash payment document will be created.
cURL Call Example
As with any other operation in the API, the cURL command is commonly used. Below you can find one such example.
curl -X PUT
'https://localhost:5434/v2/c/flexi_clean/skladovy-pohyb.json'
-H 'Accept: application/json' -H 'Content-Type: application/json'
--data-binary '
{ "winstrom":{ "skladovy-pohyb":[{ "id":385, "realizaceSklPoh":{ "@type":"vytvorit-pokladni-doklad", "typDokl":"code:POKLADNA" } }] } }'
--insecure -u admin:adminadmin | jq
Allocation of Incidental Costs to Warehouse
Using the REST API, it is also possible to allocate incidental costs to a warehouse document.
Input parameters:
vedlejsiNaklady: The amount of incidental costs to be allocated (required).podleCeny: A flag indicating that costs should be allocated by price (optional). Possible values aretrueorfalse. If not specified, or if the value is false, costs will be allocated by quantity.
Example XML entry for calling the rozuctuj service:
<winstrom version="1.0">
<skladovy-pohyb>
<!-- Skladový doklad, na nějž mají být náklady rozúčtovány. -->
<id>code:S+0001/2021</id>
<!-- Lze uvést i další vlastnosti dokladu, jako při běžném importu. -->
<rozuctuj>
<vedlejsiNaklady>50</vedlejsiNaklady>
<podleCeny>false</podleCeny>
</rozuctuj>
</skladovy-pohyb>
</winstrom>
The result will be price changes to the above-mentioned document, which originally had cenaMj 100:
<winstrom version="1.0">
<skladovy-pohyb>
<id>code:S+0001/2021</id>
<polozkyDokladu>
<skladovy-pohyb-polozka>
<mnozMj>2.0</mnozMj>
<cenaMj>125.0</cenaMj>
<cenaMjNakl>25.0</cenaMjNakl>
<cenaMjPoriz>100.0</cenaMjPoriz>
<sumCelkem>250.0</sumCelkem>
</skladovy-pohyb-polozka>
</polozkyDokladu>
</skladovy-pohyb>
</winstrom>
