Skip to main content

Creating a Cash Receipt from a Goods Receipt/Issue Note - API

How to create a cash receipt document from a goods receipt or issue note via REST API?

Written by Petr Pech

From a stock movement, you can create a cash movement via the REST API. Depending on whether it is a goods receipt or a goods issue, an expense or income movement will be created — a goods receipt generates an expense cash movement, while a goods issue generates an income cash movement.

The key requirement is specifying the correct identifier of the stock movement — ABRA Flexi will take care of the rest.


Calling method

The request is sent using the method PUT or POST to the skladovy-pohyb record. In the zaplat element, specify the cash register identifier and the type of cash document:

  • pokladna — the cash register identifier. If not specified, the cash register set in the cash document type will be used.

  • typDokl — the type of cash document

PUT https://demo.flexibee.eu/c/demo/skladovy-pohyb.xml

💡 First try the request with the ?dry-run=true parameter. The request will be processed and validated, but nothing will be written to the database.


Request examples

XML

<winstrom version="1.0">
<skladovy-pohyb>
<id>code:S-0118/2024</id>
<!-- lze uvést i další vlastnosti, jako při běžném importu -->
<zaplat>
<pokladna>code:POKLADNA KČ</pokladna>
<typDokl>code:STANDARD</typDokl>
</zaplat>
</skladovy-pohyb>
</winstrom>

JSON

{
"winstrom": {
"skladovy-pohyb": {
"id": "code:S-0118/2024",
"zaplat": [
{
"pokladna": "code:POKLADNA KČ",
"typDokl": "code:STANDARD"
}
]
}
}
}


Response

The response is a standard import result — the stock document has been updated:

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<success>true</success>
<stats>
<created>0</created>
<updated>1</updated>
<deleted>0</deleted>
<skipped>0</skipped>
<failed>0</failed>
</stats>
<results>
<result>
<id>1129</id>
<request-id>code:S-0118/2024</request-id>
<ref>/c/demo/skladovy-pohyb/1129.xml</ref>
</result>
</results>
</winstrom>

More important, however, is the result itself — the newly created cash movement linked to the stock document:

<winstrom version="1.0">
<pokladni-pohyb>
<id>code:P+0008/2024</id>
<typDokl>code:STANDARD</typDokl>
<typPohybuK>typPohybu.prijem</typPohybuK>
<vazby>
<vazba>
<a>code:P+0008/2024</a>
<b>code:S-0118/2024</b>
</vazba>
</vazby>
</pokladni-pohyb>
</winstrom>


Failed requests

If the stock document is in a state in which it cannot be paid, the server returns 400 with the code parovaniSklNefakturovatelneNejdouUhradit and the message Skladové doklady ve stavu nefakturovatelné nejdou uhradit. A non-existent cash register or document type returns 400 with the error NOT-FOUND and the name of the object being searched for.


FAQ

Can a goods receipt or issue be paid this way using multiple cash documents?

No. This functionality can only create a single cash document and cannot match a goods issue with multiple cash documents.

Can I also create an invoice from a goods receipt or issue?

Yes. Just like a cash movement, you can also create an invoice from a stock movement — for details, see the article Invoicing a stock movement via the REST API.


Related

Did this answer your question?