1. Overview

July 18, 2022


Articles in this section explain how Erply back office and APIs calculate the totals of sales documents.

Things to keep in mind:

There is no global invoice calculation standard, and hence there is no "right" way to do things. Each software may have its own rules, therefore you may get discrepancies when exchanging documents between systems.

The differences typically boil down to 1) order of operations and 2) whether rounding is applied at certain steps. When possible, try to exchange documents in a way that the exact totals would not matter.

We cannot guarantee that such situations are necessarily solvable. In these articles you will find information about "algorithm versions" — but these have been developed for internal reasons (in accordance with specific requests from Erply's customers), not to achieve interoperability with other software. Unless you dig to the bottom and find out what exactly is the difference between Erply and the other system, and it has been documented that a particular version addresses exactly that, please do not request a version change at random. "Correctness" is not always a matter of "precision" and the versions do not neatly sit on a scale from "less precision" to "more precision". The reality is more nuanced.

Please avoid re-implementing the algorithm when possible. Defer calculations to API call calculateShoppingCart: it will return the result calculated by Erply's algorithm, and when saving the items (quantities and prices) with saveSalesDocument, you are guaranteed to get the same total.