Skip to main content

Accounting Reports in API

How to generate accounting reports via API?

Written by Petr Pech

In ABRA Flexi, you can create custom accounting reports. These accounting reports can also be generated via the API interface.

For instructions on how to do this in the desktop application, see the guide here.

How to work with an already recalculated report?

Accounting reports can be found using the endpoint /sestava, i.e. GET to a URL of the type https://server:5434/c/firma/sestava.xml. At this URL you will find a list of accounting reports.

<sestava>
<id>202</id>
<lastUpdate>2010-07-13T00:00:00+02:00</lastUpdate>
<kod>IFRS-PL</kod>
<nazev>IFRS - PROFIT AND LOSS</nazev>
</sestava>
<sestava>
<id>9</id>
<lastUpdate>2018-03-07T00:00:00+01:00</lastUpdate>
<kod>ROZVAHA2018</kod>
<nazev>Rozvaha v plném rozsahu od r. 2018</nazev>
</sestava>
<sestava>
<id>10001</id>
<lastUpdate>2020-02-17T16:24:33.068+01:00</lastUpdate>
<kod>VYSLEDOMOJE</kod>
<nazev>Moje výsledovka</nazev>
</sestava>
<sestava>
<id>7</id>
<lastUpdate>2022-12-14T00:54:34.889+01:00</lastUpdate>
<kod>VÝSLEDOVKA2016</kod>
<nazev>Výkaz zisku a ztráty - druhové členění od r.2016</nazev>
</sestava>

Accounting reports found this way must have been recalculated previously. Otherwise, they will not display any values.

The latest version introduced a new registry in the API for working with standard report definitions. These can be found at the endpoint /standardni-predpis, for example a GET request to a URL of the type https://server:5434/c/firma/standardni-predpis.xml.

However, you can retrieve much more information about a report. Below is a list of what information is available and in what form.

  • /sestava.json - returns only the list of reports

  • /sestava.json?detail=full - returns report → reportRows → stdDefinitions in full detail

  • /sestava.json?relations=radkySestavy - returns report → reportRows

  • /radek-sestavy.json - returns only the list of rows

  • /radek-sestavy.json?detail=full - returns reportRow → stdDefinitions in full detail

  • /radek-sestavy.json?relations=stdPredpisy - returns reportRow → stdDefinitions

  • /standardni-predpis.json - returns the list of standard definitions

  • /standardni-predpis.json?detail=full returns the list of standard definitions in full detail

Report Recalculation

The API does not only allow you to retrieve information and values for a given report. A report can also be recalculated via the API.

Unlike the example described above for retrieving report values, recalculation is triggered by sending a request using the PUT/POST method to the relevant URL.

The element prepocti must contain the vybraneRadky and parametry of the recalculation. The selected rows must contain identifiers ucet and radek. Which rows can be selected for which accounts can be found in the sub-registry umisteni-uctu. You must select rows for all accounts listed in it.

Example of recalculating the Profit and Loss Statement report:

Recalculation is triggered by sending a request using the PUT method to the URL

/c/{firma}/sestava/code:VÝSLEDOVKA2016 with the following data in the request body:

<winstrom version="1.0">
<sestava>
<prepocti>
<vybraneRadky>
<vybranyRadek>
<ucet>code:662001</ucet>
<radek>383</radek>
</vybranyRadek>
<vybranyRadek>
<ucet>code:562001</ucet>
<radek>387</radek>
</vybranyRadek>
</vybraneRadky>
<parametry>
<ucetniObdobi>code:2022</ucetniObdobi>
<pocatecniRok>2022</pocatecniRok>
<pocatecniMesic>1</pocatecniMesic>
<koncovyRok>2022</koncovyRok>
<koncovyMesic>12</koncovyMesic>
<strediska>
<stredisko>code:C</stredisko>
</strediska>
</parametry>
</prepocti>
</sestava>
</winstrom>

Example of using the umisteni-uctu sub-registry:

By sending a request using the GET method to the URL

/c/{firma}/sestava/code:VÝSLEDOVKA2016/umisteni-uctu.xml?detail=custom:ucet,vybranyRadek,moznosti(id,nazev) we get the following data:

<winstrom version="1.0">
<umisteni-uctu>
<ucet evidencePath="ucet">code:662001</ucet>
<vybranyRadek evidencePath="radek-sestavy">383</vybranyRadek>
<moznosti>
<radek-sestavy>
<id>383</id>
<nazev>Výnosové úroky a podobné výnosy - ovládaná nebo ovládající osoba</nazev>
</radek-sestavy>
<radek-sestavy>
<id>384</id>
<nazev>Ostatní výnosové úroky a podobné výnosy</nazev>
</radek-sestavy>
</moznosti>
</umisteni-uctu>
<umisteni-uctu>
<ucet evidencePath="ucet">code:562001</ucet>
<vybranyRadek evidencePath="radek-sestavy">387</vybranyRadek>
<moznosti>
<radek-sestavy>
<id>387</id>
<nazev>Nákladové úroky a podobné náklady - ovládaná nebo ovládající osoba</nazev>
</radek-sestavy>
<radek-sestavy>
<id>388</id>
<nazev>Ostatní nákladové úroky a podobné náklady</nazev>
</radek-sestavy>
</moznosti>
</umisteni-uctu>
</winstrom>

The following parametry of the recalculation can be specified in the element prepocti:

  • ucetniObdobi - identifier of the accounting period for which you want to recalculate the report (see registry ucetni-obdobi)

  • pocatecniRok - start year of the time interval within the specified accounting period

  • pocatecniMesic - start month of the time interval within the specified accounting period (values 1 to 12)

  • koncovyRok - end year of the time interval within the specified accounting period

  • koncovyMesic - end month of the time interval within the specified accounting period (values 1 to 12)

  • minuleUcetniObdobi - identifier of the previous accounting period for which you want to recalculate the report (see registry ucetni-obdobi). If this parameter is not specified, the period preceding the accounting period specified in the parameter ucetniObdobi is used automatically.

  • minulyPocatecniRok - start year of the time interval within the previous accounting period. If this parameter is not specified, the year preceding the one specified in the parameter pocatecniRok is used automatically.

  • minulyPocatecniMesic - start month of the time interval within the previous accounting period (values 1 to 12). If this parameter is not specified, the month specified in the parameter pocatecniMesic is used automatically.

  • minulyKoncovyRok - end year of the time interval within the previous accounting period. If this parameter is not specified, the year preceding the one specified in the parameter koncovyRok is used automatically.

  • minulyKoncovyMesic - end month of the time interval within the previous accounting period (values 1 to 12). If this parameter is not specified, the month specified in the parameter koncovyMesic is used automatically.

  • strediska - identifiers of cost centers for which you want to recalculate the report (see registry stredisko). If this parameter is not specified, the report will be recalculated for all cost centers.

  • zaokrouhlitNa - option to round the calculated amounts. If the parameter is not specified, the calculated amounts will not be rounded. The following values can be used:

    • TISICE - rounding to thousands

    • JEDNOTKY - rounding to units

    • NEZAOKROUHLOVAT - calculation without rounding (default value)

  • coZaokrouhlit - if the parameter zaokrouhlitNa is set, this parameter can be used to control what will be rounded. The following values can be used:

    • RADKY - the entire report row is rounded

    • SYNTETICKE_UCTY - the entire synthetic account is rounded, e.g. 211

    • ANALYTICKE_UCTY - each analytical account is rounded separately, e.g. 211001, 211002, etc.

Opening Account Balances

For a Balance Sheet type report, recalculation may be interrupted with the error: "Opening account balances are not correct. Debit side: 10.0, Credit side: 100.0, Difference: 90.0".

You can either correct these balances, or ignore them using the element ignorovatRozdilMdDal with the value true, for example as follows:

<winstrom version="1.0">
<sestava>
<prepocti>
<ignorovatRozdilMdDal>true</ignorovatRozdilMdDal>
<vybraneRadky>
<vybranyRadek>
<ucet>code:662001</ucet>
<radek>383</radek>
</vybranyRadek>
<vybranyRadek>
<ucet>code:562001</ucet>
<radek>387</radek>
</vybranyRadek>
</vybraneRadky>
<parametry>
<ucetniObdobi>code:2022</ucetniObdobi>
<pocatecniRok>2022</pocatecniRok>
<pocatecniMesic>1</pocatecniMesic>
<koncovyRok>2022</koncovyRok>
<koncovyMesic>12</koncovyMesic>
</parametry>
</prepocti>
</sestava>
</winstrom>

Rounding Error

During rounding, recalculation may be interrupted with an error:

Při výpočtu sestavy vznikla zaokrouhlovací chyba na řádku 55 - *** - Výsledek hospodaření za účetní období (+/-). Můžete vybrat řádek sestavy, do kterého se má vzniklý rozdíl připočítat. Rozdíl v aktuálním období (v tisících): 1.0 Rozdíl v minulém období (v tisících): -2.0

This situation can be resolved by adding the difference to a specific report row. Its identifier should be specified in the element radekProPricteniRozdilu. The rows that can be used can be found in the sub-registry pricteni-rozdilu.

Note: for a Balance Sheet type report, you must distinguish whether the rounding error occurred on the assets side or the liabilities side. If the rounding error occurs on the assets side, the identifier of the report row should be specified in the element radekProPricteniRozdilu; if the rounding error occurs on the liabilities side, the report row should be specified in the element radekProPricteniRozdilu2.

If a rounding error occurs on both the assets side and the liabilities side, both rows for adding the difference must be specified to resolve the situation.

By sending a request using the GET method to the URL

/c/{firma}/sestava/code:VÝSLEDOVKA2016/pricteni-rozdilu?detail=custom:moznosti(id,cisRad,oznaceni,nazev) we get the following data:

<winstrom version="1.0">
<pricteni-rozdilu>
<id>-1</id>
<moznosti>
<radek-sestavy>
<id>344</id>
<cisRad>1</cisRad>
<oznaceni>I.</oznaceni>
<nazev>Tržby z prodeje výrobků a služeb</nazev>
</radek-sestavy>
<radek-sestavy>
<id>345</id>
<cisRad>2</cisRad>
<oznaceni>II.</oznaceni>
<nazev>Tržby za prodej zboží</nazev>
</radek-sestavy>
</moznosti>
</pricteni-rozdilu>
</winstrom>

The required row should then be specified in the element radekProPricteniRozdilu, for example as follows:

<winstrom version="1.0">
<sestava>
<prepocti>
<radekProPricteniRozdilu>344</radekProPricteniRozdilu>
<vybraneRadky>
<vybranyRadek>
<ucet>code:662001</ucet>
<radek>383</radek>
</vybranyRadek>
<vybranyRadek>
<ucet>code:562001</ucet>
<radek>387</radek>
</vybranyRadek>
</vybraneRadky>
<parametry>
<ucetniObdobi>code:2022</ucetniObdobi>
<pocatecniRok>2022</pocatecniRok>
<pocatecniMesic>1</pocatecniMesic>
<koncovyRok>2022</koncovyRok>
<koncovyMesic>12</koncovyMesic>
</parametry>
</prepocti>
</sestava>
</winstrom>

Importing a Custom Report

Reports can also be imported, see the example below:

<?xml version="1.0" encoding="UTF-8" ?>
<winstrom>
<sestava>
<id>code:SESTAVA-T01-MIN</id>
<id>ext:sestava:t01:min</id>
<nazev>Testovací sestava 01</nazev>
<radkySestavy>
<radek-sestavy>
<id>ext:radek:r1</id>
<nazev>radek1</nazev>
<stdPredpisy>
<standardni-predpis>
<id>ext:stdp:01</id>
<zpusobVypK>zpusobVypo.stavKon</zpusobVypK>
<cisloUctuSyn>code:311</cisloUctuSyn>
</standardni-predpis>
</stdPredpisy>
</radek-sestavy>
<radek-sestavy>
<id>ext:radek:r2</id>
<nazev>radek2</nazev>
<stdPredpisy>
<standardni-predpis>
<id>ext:stdp:02</id>
<zpusobVypK>zpusobVypo.stavKon</zpusobVypK>
<cisloUctuSyn>code:321</cisloUctuSyn>
</standardni-predpis>
</stdPredpisy>
</radek-sestavy>
<radek-sestavy>
<id>ext:radek:r3</id>
<nazev>suma r1 + r2</nazev>
<sumace>
<sumace-sestavy>
<id>ext:sum:r3:r1</id>
<radekSum>ext:radek:r1</radekSum>
</sumace-sestavy>
<sumace-sestavy>
<id>ext:sum:r3:r2</id>
<radekSum>ext:radek:r2</radekSum>
</sumace-sestavy>
</sumace>
</radek-sestavy>
</radkySestavy>
</sestava>
</winstrom>

The response upon successful creation of the report is:

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<success>true</success>
<stats>
<created>1</created>
<updated>0</updated>
<deleted>0</deleted>
<skipped>0</skipped>
<failed>0</failed>
</stats>
<results>
<result>
<id>10002</id>
<request-id>ext:sestava:t01:min</request-id>
<request-id>code:SESTAVA-T01-MIN</request-id>
<ref>/c/testovaci_2/sestava/10002.xml</ref>
</result>
</results>
</winstrom>

Error Codes

  • sestavaVypocet.nesouhlasiMDaDalInfo - The opening debit and credit balances do not match. Fix this by correctly entering the opening balances so that the difference is 0.0.

  • sestavaVypocet.zaokrRadkaNevyplnena - A rounding error occurred during report calculation and no row was selected for adding the difference. Select the correct row (radekProPricteniRozdilu) and repeat the calculation.

  • sestavaVypocet.nesouhlasiAktivaPasiva - A discrepancy between assets and liabilities occurred during report calculation. Select the row into which the difference should be reflected (radekProPricteniRozdilu) and repeat the calculation. This occurs only when calculating a Balance Sheet type report.

  • sestavaVypocet.zaokrRadkaNevyresila - A rounding error occurred during report calculation and the selected row for adding the difference did not correct the error. Select a different row and repeat the calculation.

  • sestavaVypocet.zaokrRadkaRozbila - An error occurred on another row when selecting a row for adding the difference during report calculation. Select a different row and repeat the calculation.

Export to PDF

The API also allows you to print a given report, i.e. generate a PDF. The list of reports available for the /sestava registry can be found here.

List of available reports:

Identifier

Name

rozvaha$$SUM_ZAKL

Balance sheet – basic scope

rozvaha$$SUM

Balance sheet – simplified scope

rozvaha$$NES

Balance sheet – full scope

vysledovka$$SUM

Profit and loss statement – simplified scope

vysledovka$$NES

Profit and loss statement – full scope

cashFlow$$NES

Cash flow statement

cashFlow$$MIN_OBDOBI

Cash flow statement (including data for the previous period)

sesRadkyPort$$BEZ_ROZPADU

Report rows

sesRadkyPort$$ROZPAD_UCET

Report rows (Account breakdown)

sesRadkyPort$$ROZPAD_PREDPIS

Report rows (Standard definition, Custom definition)

sestavy$$SUM

Accounting reports

Example:

GET demo.flexibee.eu/c/demo/sestava/(kod='ROZVAHA2018').pdf?report-name=rozvaha$$SUM

GET demo.flexibee.eu/c/demo/sestava/(kod='VYSLEDOVKA').pdf?report-name=vysledovka$$NES

Any filtering can be applied.

Endpoint with structured data for forms

Endpoints have been added to the API that return the data needed for simple use of accounting reports in a form:

  • /sestava/form-data (complete list of reports),

  • /sestava/form-data/standard (standard reports)

  • /sestava/form-data/user (custom reports).

Did this answer your question?