Skip to main content

Creation of GDD via REST API

How to create a proforma tax document (advance tax document) from a deposit and the invoice that settles it.

Written by Petr Pech

In the REST API, it is possible to create a advance tax document (ZDD) from an advance payment and the document that settles it.

The service is available in the banka, pokladni-pohyb and vzajemny-zapocet registers. Requests can be sent in XML or JSON format.

The call is made using the POST or PUT method, for example on the bank register:

Request body:

<winstrom version="1.0"> 
<banka>
<!-- Bankovní doklad, který uhrazuje přijatou zálohu. -->
<id>code:B-0001/2021</id>
<!-- Lze uvést vlastnosti dokladu, jako při běžném importu. -->
<vytvorZDD>
<typDokl>code:ZDD</typDokl>
<prenasetCisDosle>true</prenasetCisDosle>
</vytvorZDD>
</banka>
</winstrom>

In the example, we reference the bank document using the internal number of the bank transaction. The bank document must be matched to the advance invoice.

If the bank transaction is not fully matched to the advance invoice, the Flexi API will return an error:

<errors>
<error>
Doklad není kompletně spárován. Nelze vygenerovat ZDD.
</error>
</errors>

Request input parameters:

- none of the parameters are mandatory!

  • typDokl: Document type for creating the ZDD. If not specified, the default document type from company settings is used. This is an identifier of a record from the typ-faktury-prijate or typ-faktury-vydane register.

  • rada: Document series of the ZDD being created. If not specified, it is derived from the document type. This is an identifier of a record from the rada-faktury-prijate or rada-faktury-vydane register.

  • clenDph: VAT classification of the ZDD being created. If not specified, it is derived from the advance payment. This is an identifier of a record from the cleneni-dph register.

  • castkyDph: Amounts for individual VAT lines of the advance payment:

    • zklZakl, dphZakl and celkZakl (Base, VAT and VAT-inclusive): for the standard rate

    • zklSniz, dphSniz and celkSniz (Base, VAT and VAT-inclusive): for the reduced rate

    • zklSniz2, dphSniz2 and celkSniz2 (Base, VAT and VAT-inclusive): for the second reduced rate

    • osv: for the tax-exempt amount

  • prenasetCisDosle: Flag indicating that the incoming number should be transferred from the advance payment to the ZDD being created. Possible values are true or false. If not specified, the incoming number is not transferred.

The result will be a new record in the faktura-prijata register:

<winstrom version="1.0"> 
<faktura-prijata>
<id>code:PF0001/2021</id>
<typDokl>code:ZDD</typDokl>
<vazby>
<vazba>
<a>code:B-0001/2021</a>
<b>code:PF0001/2021</b>
</vazba>
</vazby>
</faktura-prijata>
</winstrom>

The Flexi API returns the service result as standard return values.

Complete XML structure:

<winstrom version="1.0"> 
<banka>
<!-- Bankovní doklad, který uhazuje přijatou zálohu. -->
<id>code:B-0001/2021</id>
<!-- Lze uvést vlastnosti dokladu, jako při běžném importu. -->
<vytvorZDD>
<typDokl>code:ZDD</typDokl>
<!-- Typ dokladu pro vytvoření ZDD. -->
<rada>code:FAKTURY</rada>
<!-- Dokladová řada vytvářeného ZDD. -->
<clenDph>code:40-41</clenDph>
<!-- Členění DPH vytvářeného ZDD. -->
<prenasetCisDosle>true</prenasetCisDosle>
<!-- Příznak, že se má číslo došlé přenést ze zálohy. -->
<castkyDph>
<!-- Částky jednotlivých řádků DPH zálohy -->
<zklZakl>100</zklZakl>
<!-- Základ částky pro základní sazbu. -->
<dphZakl>21</dphZakl>
<!-- DPH částky pro základní sazbu. -->
<celkZakl>121</celkZakl>
<!-- Částka pro základní sazbu Včetně DPH. -->
</castkyDph>
</vytvorZDD>
</banka>
</winstrom>

In the section on request input parameters, it is stated that none of the parameters are mandatory if the document type is configured in company settings. A standard call without parameters in JSON format is made as follows (analogously using the POST method):

{
"winstrom": {
"banka": {
"id": "code:BF072302605",
"vytvorZDD": {}
}
}
}

The call contains the vytvorZDD service without a body (analogously, {} can be replaced with "").

The result is the created ZDD:

{
"winstrom": {
"@version": "1.0",
"success": "true",
"stats": {
"created": "0",
"updated": "1",
"deleted": "0",
"skipped": "0",
"failed": "0"
},
"results": [
{
"id": "123",
"request-id": "code:BF072302605",
"ref": "/c/demo/banka/123.json"
} ] }
}

Complete structure in JSON:

{
"winstrom": {
"banka": {
"id": "code:B-0001/2021",
"vytvorZDD": {
"typDokl": "code:ZDD",
"rada": "code:FAKTURY",
"clenDph": "code:40-41",
"prenasetCisDosle": "true",
"castkyDph": {
"zklZakl": "100",
"dphZakl": "21",
"celkZakl": "121"
}
}
}
}
}
Did this answer your question?