Skip to main content

Work for Centers - REST API

How to Use the Flexi API for Employee Work Center Time Tracking?

Written by Petr Pech

Just as in the application, it is possible to split work assignments across cost centers for employees. This documentation describes how to use this API.

Calling Method

You can use the HTTP method: POST, GET, PUT.

The endpoint for regular work assignments per cost center is available at: /c/{firma}/prace.{pripona}, where {firma} is the database company identifier.

The endpoint for work assignments per cost center in the current month is available at: /c/{firma}/prace-mesic.{pripona}, where {firma} is the database company identifier.

A complete description of the records can be found here:

The supported output formats when retrieving data using the GET method are XML, JSON, and others.

Parameters

To retrieve data from the records, you can use the standard API filtering and detail level.

Data import requires no parameters. For data import, you can use external identifiers.

Import Example

In this example, we will demonstrate work for cost center C, where an employee works 30% of shifts on a specific job order in 2023.

First, you need to identify the employment contract to which the cost center work assignment is linked, using its ID (or external identifier). The list of employment contracts can be retrieved using GET for the given person:

https://demo.flexibee.eu:5434/c/demo/pracovni-pomer/(osoba="code:U123021").xml?detail=custom:id,kod

The retrieved ID can then be used when saving the cost center work assignment:

<winstrom version="1.0">
<prace>
<!-- Externí identifikátor -->
<id>ext:MZDSW:123</id>
<!-- Datum začátku práce pro středisko -->
<datumOd>2023-01-01</datumOd>
<!-- Datum konce práce pro středisko -->
<datumDo>2023-12-31</datumDo>
<!-- % část směny alokovaná na středisko -->
<procento>30.0</procento>
<!-- Identifikace dané osoby z personalistky - identifikace osoby není nutná, automaticky se doplní ze zadaného pracovního poměru -->
<osoba>code:U123021</osoba>
<!-- Identifikace pracovního poměru pomocí ID -->
<pracPom>1</pracPom>
<!-- Identifikace střediska -->
<stredisko>code:C</stredisko>
<!-- Identifikace zakázky -->
<zakazka>code:ZAKAZKA0821</zakazka>
<!-- Identifikace činnosti -->
<cinnost>code:A123</cinnost>
</prace>
</winstrom>

Similarly for .json

{
"winstrom": {
"prace": {
"id": "ext:MZDSW:123",
"datumOd": "2023-12-01",
"datumDo": "2023-12-12",
"procento": "30.0",
"osoba": "code:U123021",
"pracPom": "1",
"stredisko": "code:C",
"zakazka": "code:ZAKAZKA0821",
"cinnost": "code:A123"
}
}
}

Work assignments for cost centers in the current month are imported in the same way. In this example, we will demonstrate work for cost center C, where an employee worked 22 hours on a specific job order in December 2023.

<winstrom>
<prace-mesic>
<id>ext:MZDSW:123</id>
<rok>2023</rok>
<mesic>12</mesic>
<hodin>22.0</hodin>
<osoba>code:U123021</osoba>
<pracPom>1</pracPom>
<stredisko>code:C</stredisko>
<zakazka>code:ZAKAZKA0821</zakazka>
<cinnost/>
</prace-mesic>
</winstrom>

Similarly for .json

{
"winstrom": {
"prace-mesic": {
"id": "ext:MZDSW:123",
"rok": "2023",
"mesic": "12",
"hodin": "22.0",
"osoba": "code:U123021",
"pracPom": "1",
"stredisko": "code:C",
"zakazka": "code:ZAKAZKA0821",
"cinnost": ""
}
}
}

Export Example

Alternatively, data can be retrieved using the GET method:


Result of the call:

<winstrom>
<prace-mesic>
<id>ext:MZDSW:123</id>
<id>8</id>
<lastUpdate>2023-12-29T09:53:24.433+01:00</lastUpdate>
<rok>2023</rok>
<mesic>12</mesic>
<hodin>22.0</hodin>
<poznam/>
<osoba showAs="U123021: Pavel Procházka">5</osoba>
<pracPom showAs="1-STANDARD: Standardní pracovní poměr">code:1-STANDARD</pracPom>
<stredisko showAs="C: Centrála">code:C</stredisko>
<zakazka showAs="ZAKAZKA0821: Přeprava 08/23">code:ZAKAZKA0821</zakazka>
<cinnost/>
</prace-mesic>
</winstrom>

Examples of Invalid Calls

When the service executes successfully, HTTP status 200 is returned along with the response body in the requested XML or PDF format.

In the case of invalid calls, the response body contains an error description.

1. Invalid employment contract

The error result is an HTTP Status 400 Bad Request response with the following error description:

<error path="prace[temporary-id=null].pracPom" code="PROP" for="pracPom" value="code:1-STANDARAD">Zadaný text 'code:1-STANDARAD' musí identifikovat objekt [PraceStred -1]</error>

2. Working time fund exceeded

The error result is an HTTP Status 400 Bad Request response with the following error description:

 <error path="prace[temporary-id=null].procento" code="INVALID" for="procento">V některém období je rozděleno víc než sto procent fondu pracovní doby. [PraceStred -1]</error>

3. Missing required field

The error result is an HTTP Status 400 Bad Request response with the following error description:

 <error>Pole 'Měsíc' musí být vyplněno. [ext:MZDSW:123]</error>

4. Inconsistent specification of employment contract and person

The error result is an HTTP Status 400 Bad Request response with the following error description:

<error>Definovaná osoba (U123021: Pavel Procházka) se liší od osoby pracovního poměru (KN0329231: Nováková Jana). [ext:MZDSW:AC]</error>

FAQ

Where can the cost center work assignment breakdown for a given employee be found?

In the individual liabilities or internal documents generated from payroll (social insurance, etc.), the document line items will be broken down by the respective cost centers.


Need help?

If you have any questions about the application, please contact us at podporaflexi@abra.eu or via the chat window in the bottom right corner.

Did this answer your question?