Skip to main content

API Reports in Accounting

How to generate accounting reports in the API?

Written by Petr Pech

In ABRA Flexi, you can create your own accounting reports. These reports can be generated, recalculated, and imported via the REST API.

For instructions on how to do this in the desktop application, see the List of Reports guide; creating your own reports is covered in the Custom Reports article.


How to work with an already recalculated report

Accounting reports can be found at the /sestava endpoint, i.e. using the GET method at /c/{firma}/sestava.xml. This address contains the 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 already been recalculated. Otherwise, they will not display any values.

To work with standard report definitions, use the /standardni-predpis record, for example GET at the address /c/{firma}/standardni-predpis.xml.

You can also obtain considerably more information about a report. The following table lists what information can be retrieved about a report and in what form:

Address

What it returns

/sestava.json

list of reports only

/sestava.json?detail=full

sestava → radkySestavy → stdPredpisy in full detail

/sestava.json?relations=radkySestavy

sestava → radkySestavy

/radek-sestavy.json

list of lines only

/radek-sestavy.json?detail=full

radek-sestavy → stdPredpisy in full detail

/radek-sestavy.json?relations=stdPredpisy

radek-sestavy → stdPredpisy

/standardni-predpis.json

list of standard definitions

/standardni-predpis.json?detail=full

list of standard definitions in full detail


Recalculating reports

Through the API, you can not only retrieve information and values for a given report — you can also recalculate the report. Unlike simply retrieving values as described above, a recalculation is triggered by sending a request using the PUT or POST method to the relevant address.

The prepocti element must contain vybraneRadky and the recalculation parameters. The selected lines must include the identifiers ucet and radek. You can find out which lines can be selected for which accounts in the umisteni-uctu sub-record. Lines must be selected for all accounts listed there.

Example of recalculating the Profit and Loss Statement report

A recalculation is triggered by sending a request using the PUT method to the address /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>

The umisteni-uctu sub-record

By sending a request using the GET method to the address /c/{firma}/sestava/code:VÝSLEDOVKA2016/umisteni-uctu.xml?detail=custom:ucet,vybranyRadek,moznosti(id,nazev), you obtain 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 vybranyRadek element contains the identifier of the line that was selected during the previous recalculation of this report.

💡 After recalculating the desired report, it is advisable to also recalculate its source report specified in the sestavaZdroj element. You can obtain the identifiers of source reports at the address /c/{firma}/sestava.xml?detail=custom:nazev,kod,sestavaZdroj.

Recalculation parameters

The following recalculation parameters can be specified in the prepocti element:

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

  • pocatecniRok — the starting year of the time interval within the specified accounting period

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

  • koncovyRok — the ending year of the time interval within the specified accounting period

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

  • minuleUcetniObdobi — the identifier of the previous accounting period for which you want to recalculate the report. If not specified, the period preceding the one from the ucetniObdobi parameter is used automatically.

  • minulyPocatecniRok — the starting year of the time interval within the previous accounting period. If not specified, the year preceding the one from the pocatecniRok parameter is used automatically.

  • minulyPocatecniMesic — the starting month of the time interval within the previous accounting period (values 1 to 12). If not specified, the month from the pocatecniMesic parameter is used.

  • minulyKoncovyRok — the ending year of the time interval within the previous accounting period. If not specified, the year preceding the one from the koncovyRok parameter is used automatically.

  • minulyKoncovyMesic — the ending month of the time interval within the previous accounting period (values 1 to 12). If not specified, the month from the koncovyMesic parameter is used.

  • strediska — the identifiers of the cost centers for which you want to recalculate the report (see the stredisko record). If not specified, the report will be recalculated for all cost centers.

  • zaokrouhlitNa — an option to round the calculated amounts. Values TISICE (rounded to thousands), JEDNOTKY (rounded to whole units), and NEZAOKROUHLOVAT (calculation without rounding, default value).

  • coZaokrouhlit — if you set the zaokrouhlitNa parameter, this parameter determines what gets rounded. Values RADKY (the entire report line is rounded), SYNTETICKE_UCTY (the entire synthetic account is rounded, e.g. 211), and ANALYTICKE_UCTY (each analytic account is rounded separately, e.g. 211001, 211002).

Opening account balances

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

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

<winstrom version="1.0">
<sestava>
<prepocti>
<ignorovatRozdilMdDal>true</ignorovatRozdilMdDal>
<vybraneRadky>
<vybranyRadek>
<ucet>code:662001</ucet>
<radek>383</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, the recalculation may be interrupted by the following 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 one of the report's lines. You specify its identifier in the radekProPricteniRozdilu element. The lines that can be used are found in the pricteni-rozdilu sub-record.

⚠️ For a Balance Sheet type report, you must distinguish whether the rounding error occurred on the assets side or the liabilities side. If the error is on the assets side, specify the line identifier in the radekProPricteniRozdilu element; if on the liabilities side, use the radekProPricteniRozdilu2 element. If the error occurs on both sides, both lines must be specified.

By sending a request using the GET method to the address /c/{firma}/sestava/code:VÝSLEDOVKA2016/pricteni-rozdilu?detail=custom:moznosti(id,cisRad,oznaceni,nazev), you obtain 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>

You then specify the required line in the radekProPricteniRozdilu element, for example like this:

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

Error codes

  • sestavaVypocet.nesouhlasiMDaDalInfo — the opening debit and credit balances do not match. Correct them so that the difference is zero.

  • sestavaVypocet.zaokrRadkaNevyplnena — a rounding error occurred while calculating the report, and no line was selected to add the difference to. For a Balance Sheet type report, select a line in radekProPricteniRozdilu if the for attribute of the error message has the value radekProPricteniRozdilu, or in radekProPricteniRozdilu2 if it has the value radekProPricteniRozdilu2, and repeat the calculation.

  • sestavaVypocet.nesouhlasiAktivaPasiva — a mismatch between assets and liabilities occurred while calculating the report. Select the line into which the difference should be reflected (according to the for attribute of the error message radekProPricteniRozdilu, or radekProPricteniRozdilu2), and repeat the calculation. This only occurs when calculating a Balance Sheet type report.

  • sestavaVypocet.zaokrRadkaNevyresila — the line selected for adding the difference did not fix the rounding error. Select a different one and repeat the calculation.

  • sestavaVypocet.zaokrRadkaRozbila — selecting a line to add the difference to caused an error on another line. Select a different one and repeat the calculation.


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>

If the report is created successfully, the response 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/{firma}/sestava/10002.xml</ref>
</result>
</results>
</winstrom>


Export to PDF

A given report can also be printed via the API, or rather, a PDF can be generated. The list of reports available for the /sestava record can be found at the address /c/{firma}/sestava/reports.xml.

List of available reports

Identifier

Name

rozvaha$$SUM_ZAKL

Balance Sheet in basic scope

rozvaha$$SUM

Balance Sheet in simplified scope

rozvaha$$NES

Balance Sheet in full scope

vysledovka$$SUM

Profit and Loss Statement in simplified scope

vysledovka$$NES

Profit and Loss Statement in full scope

cashFlow$$NES

Cash Flow Statement

cashFlow$$MIN_OBDOBI

Cash Flow Statement (including data for the previous period)

sesRadkyPort$$BEZ_ROZPADU

Report lines

sesRadkyPort$$ROZPAD_UCET

Report lines (Breakdown by accounts)

sesRadkyPort$$ROZPAD_PREDPIS

Report lines (Standard definition, Custom definition)

sestavy$$SUM

Accounting reports

Examples

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

Any filtering can be used.


Endpoints with structured data for forms

The API provides endpoints that return the data needed for easy use of accounting reports in a form:

  • /sestava/form-data.json — complete list of reports

  • /sestava/form-data/standard.json — standard reports

  • /sestava/form-data/user.json — custom reports

⚠️ For these endpoints, you must specify the format extension (.json or .xml). An address without an extension returns 404 with code adresaNeplatnaUrl.


Related

Did this answer your question?