Payroll components with specific data about hours worked are not updated from scratch via the REST API — Flexi generates them itself for each month based on the employee's fixed payroll components. The integration's task, then, is to find the correct payroll component and fill in the relevant values, typically hours or days worked.
Prerequisites
A person — i.e., the employee to whom the payroll components belong — must already exist. A person can be created either in HR records or via the REST API; sample XML can be found in the XML file examples as mzdy-osoba.xml.
The person must have fixed payroll components assigned — their setup is described in the HR records documentation.
Only after this can you proceed to actually transferring attendance data to ABRA Flexi.
Getting the payroll component ID
First, you need to determine the ID of the payroll components that will be updated — these are always specific components for a specific month. Filtering by component, year, and month is helpful here; you can use any level of detail:
GET /mzdova-slozka/(cisMzdSloz = 'code:HODINOVÁ MZDA' and rok = 2022 and mesic = 1).xml?detail=custom:id,osoba(osbCis,jmeno,prijmeni,titul),hodiny,zmenaCasu,zmenaCastMzd,castkaHod,castMzd&includes=/mzdova-slozka/osoba&limit=0
Instead of the hourly wage, you can of course select another component from the payroll component catalog. If it's an absence, it is looked up in the nepritomnost records by validity period:
GET /nepritomnost/(cisMzdSloz = 'code:NEMOC' and (platiOd >= '2022-01-01' and platiOd <= '2022-01-31' or platiDo >= '2022-01-01' and platiDo <= '2022-01-31')).xml?detail=full
The retrieved XML for the payroll component might then look like this:
<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<mzdova-slozka>
<id>9258</id>
<osoba>
<osoba-hlavicka>
<id>4</id>
<osbCis>432423423</osbCis>
<jmeno>Karel</jmeno>
<prijmeni>Novák</prijmeni>
<titul>Ing.</titul>
</osoba-hlavicka>
</osoba>
<hodiny>0.0</hodiny>
<zmenaCasu>false</zmenaCasu>
<zmenaCastMzd>false</zmenaCastMzd>
<castkaHod>0.0</castkaHod>
<castMzd>0.0</castMzd>
</mzdova-slozka>
</winstrom>
Filling in the values
Now you fill in the relevant value into the retrieved payroll component — in our example, hours worked. Days are filled in the same way; what each component expects is determined by its setup in the payroll component catalog.
The part of the XML containing the person can be omitted when writing it back, since we only want to change the hours:
<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<mzdova-slozka>
<id>9258</id>
<hodiny>100.0</hodiny>
<zmenaCasu>false</zmenaCasu>
<zmenaCastMzd>false</zmenaCastMzd>
<castkaHod>0.0</castkaHod>
<castMzd>0.0</castMzd>
</mzdova-slozka>
</winstrom>
Send the XML using the POST or PUT method to the /mzdova-slozka endpoint. On success, the API returns the standard import result, and the payroll component will be updated:
<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<success>true</success>
<stats>
<created>0</created>
<updated>1</updated>
<deleted>0</deleted>
<skipped>0</skipped>
<failed>0</failed>
</stats>
<results>
<result>
<id>9258</id>
<request-id>9258</request-id>
<ref>/c/demo/mzdova-slozka/9258.xml</ref>
</result>
</results>
</winstrom>
ℹ️ The value updated is the only reliable confirmation that the component was actually changed. Once the attendance data has been filled in, you still need to run the payroll calculation.
