If you don't specify an exchange rate when importing a document in a foreign currency, ABRA Flexi will automatically fetch one (e.g., from the CNB or ECB). However, the rate may differ by small amounts (hundredths/thousandths) from the official rate. This is intentional behavior.
Why the rate is adjusted
The foreign currency amount, the domestic currency amount, and the exchange rate must always be "in balance" (multiplying or dividing two of them must yield the third). The problem is that amounts are rounded to two decimal places, which creates a certain inaccuracy.
Let's say we have an amount of EUR 1.4 and an exchange rate of 25.265. Multiplying gives us CZK 35.371, which after rounding becomes 35.37. But 35.37 / 25.265 is no longer 1.4, but 1.39996041955.
We make sure the amounts always match, and to do so, we adjust ("sacrifice") the exchange rate, which we round to six decimal places (allowing us to store it "more precisely"). In this case, we recalculate it as 35.37 / 1.4 = 25.264286.
ℹ️ Since the inaccuracy is different each time, the resulting exchange rate will also always be slightly different. For example, for an amount of EUR 5.95, the domestic currency amount after rounding is 150.33, and the exchange rate that makes the amounts match comes out to 25.265546.
Why we do this at all
These are usually small discrepancies that would be resolved by rounding the amounts anyway, but we've also encountered a case where the difference was CZK 1 (e.g., the foreign currency amount was 2599.0 and the exchange rate was 0.0038), which is unacceptable. That's why we do this.
📝 We could perhaps be smarter about it and only do this when it's truly necessary, but for now, this is how it works.
What this means for integration
Don't rely on the exchange rate saved on a document being exactly the official one — comparing document-by-document exchange rates against the exchange rate table doesn't make sense.
If you want a specific exchange rate on a document, specify it explicitly in the import and calculate the amounts yourself so that they balance.
Before saving, check the final result using a test save (dry run) — in the
<content />tag, you'll see the exchange rate and amounts exactly as they would be saved.
