Skip to main content

Creating a DDA via REST API

How to create an advance tax document (ZDD) from an advance payment and the document that settles it

Written by Petr Pech

In the REST API, you can create a tax document for an advance payment (ZDD) from an advance invoice and the document that settles it.

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

⚠️ In other records, where creating a ZDD doesn't make sense, the <vytvorZDD> element is silently ignored — the call will return 200, but no ZDD will be created.


Basic call

The call is made using the POST or PUT method, for example on the banka record:

POST https://demo.flexibee.eu/c/demo/banka.xml

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 this example, we reference the bank document using the internal number of the bank transaction. The bank document must be paired with an 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 required — if you have a default document type set in your company settings, an empty <vytvorZDD/> element is sufficient.

Parameter

Meaning

typDokl

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

rada

Document series of the created ZDD. 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 records.

clenDph

VAT classification of the created ZDD. If not specified, it is derived from the advance invoice. This is an identifier of a record from the cleneni-dph records.

castkyDph

Amounts of individual VAT lines for the advance payment:

zklZakl, dphZakl, celkZakl (Base, VAT, and Including VAT) — for the standard rate

zklSniz, dphSniz, celkSniz — for the reduced rate

zklSniz2, dphSniz2, celkSniz2 — for the second reduced rate

osv — for the tax-exempt amount

prenasetCisDosle

Flag indicating whether the received number should be carried over from the advance payment to the created ZDD. Possible values are true or false. If not specified, the received number is not carried over.


Result

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

<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 will return the result of the service as standard return values.


Complete structure in XML

<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> <!-- 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>


Calling in JSON

A standard call without parameters in JSON format is made as follows (analogously using the POST method):

PUT https://demo.flexibee.eu/c/demo/banka.json
{
"winstrom": {
"banka": {
"id": "code:BF072302605",
"vytvorZDD": {}
}
}
}

The call includes the vytvorZDD service with no content (similarly, "" can be used instead of {}). 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"
}
}
}
}
}


Related

Did this answer your question?