Skip to main content

Initializing an Accounting Period via REST API

How to Close a Period and Initiate the Next One Using the Flexi REST API?

Written by Petr Pech

The Flexi REST API offers an equivalent to invoking the menu "Accounting > Initialize Next Period". The initialization can be called repeatedly, just as in the desktop application.

The basic API request uses the GET method

GET server/c/firma/ucetni-obdobi/inicializace-noveho-obdobi.json

If the next accounting period does not exist, the following error is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Neexistuje následující účetní období. Prosím založte ho."
}
}

If some document types have non-standard rounding settings, the following error occurs:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Následující typy dokladů mají nestandardně nastavené zaokrouhlení DPH (očekávané je zaokrouhlení na setiny nebo jednotky, viz § 37 ZDPH):\nFAKTURA: nastaveno \"0.1\"\nOBP: nastaveno \"0.1\"\nNásledující typy dokladů mají nestandardně nastavený způsob zaokrouhlení DPH (očekávané je zaokrouhlení matematicky, viz § 37 ZDPH):\nFAKTURA: nastaveno \"nahoru\"\nOBP: nastaveno \"nahoru\"\nZÁLOHA: nastaveno \"nahoru\""
}
}

This error can be suppressed using the parameter kontrolaZaokrouhleni=false (equivalent to clicking Yes in the desktop application), or by correcting the rounding settings on the document types.

Required parameters for period initialization via API

  • ucetOtv - Opening account for the accounting ledger (druhUctuK="druhUctu.otevknih")

  • ucetZav - Closing account for the accounting ledger (druhUctuK="druhUctu.uzavknih")

  • ucetPre - account code for transferring the profit/loss result (the account must have the type druhUctuK="druhUctu.prhosvys" set)

  • ucetVys - account code for profit/loss under approval proceedings (the account must have the type druhUctuK="druhUctu.pasivhvy" set)

The expected values are account codes from the Chart of Accounts that have the corresponding druhUctuK value (e.g. ucetZav=702000). For more information about account types, see the Chart of Accounts register.

Note: For companies using cash-basis accounting (daňová evidence), the double-entry accounting account parameters are not required.

If any of the parameters are missing, the following error is returned (for example):

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"K provedení operace je vyžadován parametr 'ucetOtv'"
}
}

If an incorrect account was selected (e.g. ucetZav=701000), the following error is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Parametr 'ucetZav' má nepodporovanou hodnotu! Zvolte jednu z následujících možností: [Zvolený účet musí mít druhUctuK 'druhUctu.uzavknih']"
}
}

Optional parameters for period initialization via API

  • ucetniObdobi - code of the accounting period you want to close (if not specified, the current period is closed)

  • preceneni - Revalue unpaid documents (true/false)

  • prevodSkladu - Carry over inventory (true/false)

  • vynechatNulove - Skip cards with a zero balance (true/false)

  • dnyBezPohybu - Number of days without movement for exclusion (integer)

  • zrusitStare - Remove unused old cards in the new accounting period (true/false)

  • typDokl - Document type for generating lease installment payables (document type id).

The default values for all boolean parameters are false.

If payables exist for the next accounting period, the typDokl parameter is required.

The "Confirm card exclusion" option available in the desktop application is not supported by the REST API.

If it is not provided in this case, the corresponding error is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"K provedení operace je vyžadován parametr 'typDokl'"
}
}

The selected document type must have a document series saved; otherwise, the following error is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Vyplněný typu dokladu nemá zadanou řadu dokladu a žádná není specifikovaná."
}
}

The document type series must have an annual numbering series entry saved for the next accounting period; otherwise, the following error is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Vybraná řada typu dokladu nemá zadanou roční položku číselné řady k následujícímu účetnímu období."
}
}

Exchange rate check for revaluation

If revaluation of documents is enabled via the parameter ?preceneni=true, an exchange rate check for revaluation is performed. Before calling the initialization, you can call the subresource:
GET https://demo.flexibee.eu/c/demo/ucetni-obdobi/meny-pro-preceneni.json (optional parameter ?ucetniObdobi=IDENTIFIKÁTOR_OBDOBÍ),
which returns a list of currencies with the exchange rate that will be used for revaluation.

If the exchange rate or rate quantity for any currency is missing (is 0.0), it must be provided during the period initialization.

Example response

{
"meny-pro-preceneni":{
"datumPreceneni":"2023-12-31T00:00:00+01:00",
"meny":{
"mena":[
{
"symbol":"",
"kod":"DEM",
"kurz":"0.0",
"kurzMnozstvi":"1.0"
},
{
"symbol":"€",
"kod":"EUR",
"kurz":"24.725",
"kurzMnozstvi":"1.0"
},
{
"symbol":"",
"kod":"THB",
"kurz":"65.107",
"kurzMnozstvi":"100.0"
}
]
}
}
}

During initialization, the system will attempt to download revaluation exchange rates from the central bank. It is also possible to define the exchange rate using URL parameters:

?kurz[KOD_MENY]=HODNOTA_KURZU&kurzMnozstvi[KOD_MENY]=HODNOTA_KURZ_MNOZSTVI

Example:

https://demo.flexibee.eu/c/demo/ucetni-obdobi/inicializace-noveho-obdobi.json?(parametry s účty)&preceneni=true &kurz[EUR]=24.52&kurzMnozstvi[EUR]=1.0&kurz[HUF]=6.12&kurzMnozství[HUF]=100.0

For each currency, both values must be provided: the exchange rate and the rate quantity. These values will be saved as a new exchange rate in the resource:

https://demo.flexibee.eu/c/demo/kurz-pro-preceneni/(platiOdData, mena)

If any exchange rates are missing during initialization, the following is returned:

status 400 { "winstrom": { "@version": 1, "success": false, ... } }

{
"winstrom":{
"@version":1,
"success":false,
"message":"Nebyly zadány všechny potřebné kurzy platné k poslednímu dni účetního období,\nkteré jsou nutné pro přecenění neuhrazených pohledávek/závazků."
}
}

Movements in incorrect currency

If revaluation of bank accounts and cash registers is enabled via the parameter ?preceneni=true or ?preceneniBankAPokladen=true, all movements in the revalued bank accounts and cash registers are checked.

If a movement is found in a currency other than the domestic currency or the currency in which the bank account or cash register is maintained, the following error occurs:

{
"winstrom":{
"@version":1,
"success":false,
"message":"Následující bankovní účty a pokladny nelze přecenit:\n• <seznam všech chybných bank nebo pokladen>\nPřeceňovány mohou být pouze bankovní účty a pokladny, které mají pohyb v měně, ve které jsou vedeny nebo v tuzemské měně."
}
}

This error can be suppressed using the parameter preceneniVynechatBanAPokSChybnouMenou=true, which will exclude all affected bank accounts and cash registers from the revaluation calculation.

Example call no. 1

1. First, retrieve the currencies for revaluation:

2. If the query returns currencies, perform the revaluation

An example of saving data to the Exchange Rates register may look as follows:

{
"winstrom":
{
"kurzy": {
"platiOdData": "2020-12-31T00:00:00+01:00",
"nbStred": "25.75",
"kurzMnozstvi": 1,
"mena": "code:EUR"
}
}
}

3. Then perform the initialization

If the initialization has all the required data, it starts a background thread and returns status 202 Accepted.

Example call no. 2

1. Perform the initialization directly, including the exchange rate:

If the initialization has all the required data, it starts a background thread and returns status 202 Accepted.

In the Accounting Periods register, you can check whether the initialization has completed (the lastUpdate property of the current accounting period is updated).

Result

If the initialization has all the required data, it starts a background process and returns status 202 Accepted. On the resource /c/{firma}/ucetni-obdobi, you can check whether the initialization has completed (the lastUpdate property of the current accounting period).

Did this answer your question?