Using the REST API, you can create an invoice from advance payments settled by bank transfer, cash register, or mutual offset.
This is equivalent to the "Create invoice from advance payment" function available on issued or received invoices. The only difference is that in the desktop application you run the function from within the invoice itself. Here, in the API, you need the payment identifier instead.
This approach can be considered faster compared to the function for advance payment or VAT document deduction. You do not need the identifier of the advance payment here — instead, you need the identifier of the payment.
How does the create invoice from advance payments function work?
The base request body looks the same as for any other invoice. It includes both required and optional properties, such as typDokl, cisDosle, datSplat. All available properties can be found in the so-called evidence list.
The API action <vytvorZUhrazenychZaloh> can only be used for the same movement types.
Otherwise, the call returns error 400: "The movement type of the advance payment (Issue) must be the same as the movement type of the new document (Receipt)."
The API action <vytvorZUhrazenychZaloh> can only be used on newly created documents.
Otherwise, the call returns error 400: "Action "vytvorZUhrazenychZaloh" is not allowed on existing documents."
In the vytvorZUhrazenychZaloh element, you must provide uhrazujiciDokl to identify the document by which the advance payment was settled.
<vytvorZUhrazenychZaloh>
<uhrazujiciDokl>code:B+0005/2022</uhrazujiciDokl>
</vytvorZUhrazenychZaloh>
You also need the uhrazujiciEvidence element to identify the evidence (in this case you can choose from banka, pokladna, vzajemny-zapocet) that this document belongs to.
<vytvorZUhrazenychZaloh>
<uhrazujiciDokl>code:B+0005/2022</uhrazujiciDokl>
<uhrazujiciEvidence>banka</uhrazujiciEvidence>
</vytvorZUhrazenychZaloh>
A complete example of creating an issued invoice from advance payments settled by bank transfer may look like this:
<winstrom version="1.0">
<faktura-vydana>
<typDokl>code:FAKTURA</typDokl>
<cisDosle>123</cisDosle>
<datSplat>2022-01-17</datSplat>
<vytvorZUhrazenychZaloh>
<uhrazujiciDokl>code:B+0005/2022</uhrazujiciDokl>
<uhrazujiciEvidence>banka</uhrazujiciEvidence>
</vytvorZUhrazenychZaloh>
</faktura-vydana>
</winstrom>
An example of creating a received invoice from advance payments settled by cash register:
<winstrom version="1.0">
<faktura-prijata>
<typDokl>code:FAKTURA</typDokl>
<cisDosle>123</cisDosle>
<datSplat>2022-01-17</datSplat>
<vytvorZUhrazenychZaloh>
<uhrazujiciDokl>code:P-0001/2022</uhrazujiciDokl>
<uhrazujiciEvidence>pokladni-pohyb</uhrazujiciEvidence>
</vytvorZUhrazenychZaloh>
</faktura-prijata>
</winstrom>
Note:
Advance payments with serial numbers are not currently supported by the API.
