Skip to main content

Locking Periods via REST API

How to Lock a Period in Flexi API?

Written by Petr Pech

The API includes the /zamek agenda, which offers the ability to lock periods in the same way as the desktop application. You can find the agenda here. A description of period locking in the desktop application can be found in this documentation.

Locks can be both read and sent via API requests. Data can be retrieved and submitted in XML or JSON format.

Reading Locks

Locks can be retrieved using a GET request to the agenda endpoint /zamek. When calling the endpoint, you can use the standard detail or filtering options. Below is an example of retrieving locks:

This returns a complete list of period locks in full detail in XML format:

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<!-- Zámky na období -->
<zamek>
<!-- ID (celé číslo) - -->
<id>3</id>
<!-- Poslední změna (datum a čas) - -->
<lastUpdate>2022-01-25T13:03:41.119+01:00</lastUpdate>
<!-- Zámek
Otevřeno - zamek.otevreno
Zamknuto mimo účetní - zamek.polozamceno
Zamknuto - zamek.zamceno -->
<zamekK showAs="Zamknuto mimo účetní">zamek.polozamceno</zamekK>
<!-- Od (datum) - -->
<platiOdData>2021-10-01+02:00</platiOdData>
<!-- Do (datum) - -->
<platiDoData>2021-12-31+01:00</platiDoData>
<!-- Faktury vydané (logická hodnota) - -->
<modulFav>true</modulFav>
<!-- Faktury přijaté (logická hodnota) - -->
<modulFap>false</modulFap>
...
<neucetni>true</neucetni>
</zamek>
</winstrom>

The lock type information is returned in the zamekK element. The response also includes a list of all modules with a true/false value indicating whether the module is locked.

Setting Locks

A lock request is sent using a POST method to the agenda endpoint /zamek.

The request body can be submitted in XML or JSON.

The mandatory elements when setting locks are as follows:

  • zamekK - defines the lock type; possible values are:

    • Open (zamek.otevreno)

    • Locked for non-accountants (zamek.polozamceno)

    • Locked (zamek.zamceno)

  • platiOdData - defines the start date of the lock in YYYY-MM-DD format

  • platiDoData - defines the end date of the lock in YYYY-MM-DD format

When calling the endpoint, you can also specify whether non-accounting documents should be locked as well:

  • neucetni - true/false; if set to true, non-accounting documents will also be locked; the default value is true

Additional elements represent the available modules that can be locked; they accept the value true to lock:

  • modulFav - Issued invoices

  • modulFap - Received invoices

  • modulPhl - Other receivables

  • modulZav - Other payables

  • modulBan - Bank

  • modulPok - Cash register

  • modulInt - Internal documents

  • modulSkl - Stock movements

  • modulPpp - Received inquiries

  • modulPpv - Issued inquiries

  • modulNap - Received offers

  • modulNav - Issued offers

  • modulObp - Received orders

  • modulObv - Issued orders

  • modulMaj - Assets

  • modulLea - Leasing

  • modulMzd - Payroll

If at least one module with the value true is not specified, no locking will occur.

Example of a POST call to the endpoint:

Request body that locks the received invoices module with a full lock:

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<zamek>
<zamekK>zamek.zamceno</zamekK>
<platiOdData>2022-01-01+02:00</platiOdData>
<platiDoData>2022-01-15+01:00</platiDoData>
<modulFap>true</modulFap>
</zamek>
</winstrom>

Deleting a Lock

A period lock can be deleted using a POST method and the delete action:

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<zamek action="delete">
<id>6</id>
</zamek>
</winstrom>

Removing a period lock does not unlock individual documents! Documents must be unlocked separately.

Did this answer your question?