Closed ChristianVermeulen closed 2 years ago
Hi @ChristianVermeulen,
Thanks for your PR! I agree with your comments, better to round just once at the end.
Instead of always rounding to 2 decimals, I've added a few changes so that the rounding matrix from the invoice instance is taken into account when:
UblWriter
)$invoice->getTotals()
as some users may rely on this method to get the invoice totals before exporting itLet me know your thoughts.
Case:
Imagine a document with the following line (quantity = 2, price excl. = € 15,7025, vat = 21%)
Problem
We've been having issues where the xml has differences with the actual pdf document being sent to the customer. Due to this, the amount paid by the customer is different from the amount being booked into the book keeping software. As it turns out, this is due to the fact that amounts are rounded too soon.
The XML turns out like this:
As you can see, the total is
€ 38,01
instead of€ 38,00
. This means our customer needs to change it back to € 38,00 because that is what their customer has actually paid from the original invoice.Solution
Normally when bookkeeping you are not allowed to round your numbers until the very end. So basically only once you start to visualise the number. Therefore I have moved the
round
calls to the very end in theUblWriter
. This will make sure all calculations are done with the best precision before being outputted in XML.