When the Changes API is enabled, ABRA Flexi records all changes made to the company database in a changelog and allows the list of changes to be retrieved retroactively.
Changes are numbered in ascending order, so the company has a well-defined global version at any given moment.
Version numbers do not have to follow consecutively — there may be gaps in the sequence for technical reasons. However, version numbers are always unique and increasing. This can be used for automated synchronization of external systems with ABRA Flexi and also forms the basis for the instant change notification feature (Web Hooks).
The ABRA Flexi license must have an active REST API with at least read access. All new paid licenses include this by default.
Checking the status and enabling/disabling can most easily be done in the web interface at the following address: /c/{firma}/changes/control
Alternatively, it can be enabled with a PUT request to the address /c/{firma}/changes/enable.xml and disabled likewise with a PUT request to the address /c/{firma}/changes/disable.xml.
In addition to PUT, you can also use POST. If you do not have an active REST API for reading or writing, the response will be 403 Forbidden.
Example of activation using the curl command:
curl -k -L -u jmeno:heslo -X PUT https://localhost:5434/c/{firma}/changes/enable.xml -H Content-Length:0
Retrieving the current global version
The current global version can be added to any XML (or JSON) export obtained via the REST API by appending the parameter ?add-global-version=true. The response will look like this:
<?xml version="1.0"?><winstrom version="1.0" globalVersion="6">
...
</winstrom>
Retrieving change records
The address /c/firma/changes.xml contains a list of all changes since tracking began.
The output looks like this:
<?xml version="1.0"?><winstrom version="1.0" globalVersion="6"> <faktura-vydana in-version="3" operation="create" timestamp="2019-01-01 00:00:00.0"> <id>1</id> </faktura-vydana> <faktura-vydana-polozka in-version="4" operation="create" timestamp="2019-06-07 12:34:56.7"> <id>1</id> </faktura-vydana-polozka> <faktura-vydana in-version="5" operation="update" timestamp="2019-06-07 12:34:56.7"> <id>1</id> <id>code:VF1-0001/2012</id> </faktura-vydana> <next>6</next></winstrom>
Each entry includes the numeric ID of the object (<id>1</id>) and its code (<id>code:KÓD</id>); if the object had any external IDs at the time the operation was performed, those are also included (<id>ext:...</id>).
The attributes of each element indicate the version in which the operation occurred (in-version) and the type of operation (operation; possible values are create, update, and delete).
The attribute globalVersion is always present. The last element in the output is always next, which indicates the version number from which this output would continue, or none if there are no further changes.
The output can be modified using the following parameters:
| The version from which to start listing (inclusive); defaults to the beginning of tracking. |
| The number of records to return; default is 100, maximum is 1000. |
| Which agendas to include changes for; can be specified multiple times; if not specified, all agendas are included. |
In JSON format, changes look like this:
{ "winstrom": { "@globalVersion": "8", "changes": [ { "@evidence": "faktura-vydana", "@in-version": "3", "@operation": "create", "@timestamp": "2019-01-01 00:00:00.0", "id": "1", "external-ids": [] }, { "@evidence": "faktura-vydana-polozka", "@in-version": "4", "@operation": "create", "@timestamp": "2019-06-07 12:34:56.7", "id": "1", "external-ids": [] }, { "@evidence": "faktura-vydana", "@in-version": "5", "@operation": "update", "@timestamp": "2019-06-07 12:34:56.7", "id": "1", "external-ids": [ "code:VF1-0001\/2012" ] } ], "next": "6" }}
Checking the Changes API enabled status
You can check the enabled status via the web interface at /c/{firma}/changes/control. From there you can also enable or disable the Changes API.
If you need to check the status programmatically, use GET /c/firma/changes/status.xml. If the response is true, the Changes API is enabled. If the response is false or an error (if the REST API is not enabled), the Changes API is disabled.
Synchronizing external systems with ABRA Flexi
Versioned changes can be easily used for efficient synchronization of external systems with ABRA Flexi (as opposed to last modified date). The process is as follows:
Initial data load:
Retrieve the current data including its version (
?add-global-version=true)Save the data
Store the version (from the
globalVersionattribute)
Differential synchronization:
Download changes since the last stored version (
?start=)Download the changed data and save it, or delete any removed data
Store the version (from the
nextelement, or from theglobalVersionattribute)GOTO 1
ERROR: could not obtain lock on relation „????"
If you see the error ERROR: could not obtain lock on relation "????", do not worry. For performance reasons, the database functions that handle the Changes API are not added at all initially. When the Changes API is activated, they are added to the system — which requires an exclusive lock on the entire database.
The solution is to log out of ABRA Flexi — both from the web interface and the client application. After that, the activation will proceed successfully.
Example error:
ERROR: could not obtain lock on relation "drady" Kde: SQL statement "LOCK TABLE drady IN ACCESS EXCLUSIVE MODE NOWAIT"
Endpoints logged in Changes API
Address book and contacts
Agenda | Endpoint |
Address book |
|
Bank account (address book) |
|
Contact |
|
Destination |
|
ZIP code |
|
Company group |
|
Financial institution |
|
Country |
|
Activity type |
|
Cost type |
|
Price list and products
Agenda | Endpoint |
Attribute |
|
Price level |
|
Price list |
|
Supplier |
|
Bill of materials |
|
Unit of measure |
|
Customer |
|
Related products |
|
Fee |
|
Accessories |
|
Kits and bundles |
|
Price list group |
|
Product group |
|
Attribute type |
|
Attribute group |
|
Price list status |
|
Documents — invoices and receivables
Agenda | Endpoint |
Purchase invoice |
|
Purchase invoice — line item |
|
Sales invoice |
|
Sales invoice — line item |
|
Sales receipt * |
|
Sales receipt — line item * |
|
Receivable |
|
Receivable — line item |
|
Payable |
|
Payable — line item |
|
Purchase invoice type |
|
Sales invoice type |
|
Sales receipt type * |
|
Receivable type |
|
Payable type |
|
Documents — bank, cash, internal documents
Agenda | Endpoint |
Bank * |
|
Bank — line item |
|
Mutual offset * |
|
Bank type * |
|
Mutual offset type * |
|
Cash transaction |
|
Cash transaction — line item |
|
Cash transaction type |
|
Internal document |
|
Internal document — line item |
|
Internal document type |
|
Documents — commercial
Agenda | Endpoint |
Purchase quote |
|
Purchase quote — line item |
|
Sales quote |
|
Sales quote — line item |
|
Purchase order |
|
Purchase order — line item |
|
Sales order |
|
Sales order — line item |
|
Purchase inquiry |
|
Purchase inquiry — line item |
|
Sales inquiry |
|
Sales inquiry — line item |
|
Purchase quote type |
|
Sales quote type |
|
Purchase order type |
|
Sales order type |
|
Purchase inquiry type |
|
Sales inquiry type |
|
Commercial document status |
|
Shipping method |
|
Payment method |
|
Sales receipt payment |
|
Payment method — accounting |
|
Documents — warehouse
Agenda | Endpoint |
Stock movement |
|
Stock movement — line item |
|
Stock movement type |
|
Stock card |
|
Inventory count |
|
Inventory count — line item |
|
Reservation |
|
Warehouse mapping |
|
Warehouse location — room * |
|
Warehouse location — rack * |
|
Warehouse location — shelf * |
|
Serial number |
|
Documents — contracts
Agenda | Endpoint |
Contract * |
|
Supplier contract * |
|
Contract — line item |
|
Contract type * |
|
Supplier contract type * |
|
Contract status |
|
Payment orders and payment code lists
Agenda | Endpoint |
Payment order |
|
Bank account |
|
Cash register |
|
Warehouse |
|
Package number |
|
Constant symbol |
|
Electronic banking format |
|
Accounting
Agenda | Endpoint |
Chart of accounts |
|
Account |
|
Accounting period |
|
Turnover |
|
VAT return line |
|
VAT rate |
|
VAT breakdown |
|
Reverse charge VAT |
|
Activity |
|
Cost center |
|
Project |
|
Project type |
