We detect too many decimals of difference when calculating ‘Tax Lines’ on invoices, with the tax_rounding field set to ‘document’, if you take the tax base and try to apply the tax rate directly. In some countries that different are not allowed. They need to be exactly and now we have found some invoices with 4 decimals of differences.
For example, if the currency is euro (2 decimals) and you have an invoice with 50 lines and all of them with the same tax and the unit price of each line has 3 or more decimals, the calculating of tax base and amount are not coherent, because on the one hand the base is rounded for each line to be consistent when creating the move lines and on the other the tax is rounded at the end. And this produces that if you take the final base and apply the rate, the result is too much different from the calculated.
Calculate the tax amount of ‘Tax Lines’ using it base.
A first approach could be something like that:
--- a/tax.py Sat Jan 26 01:12:50 2019 +0100 +++ b/tax.py Thu Feb 21 15:06:49 2019 +0100 @@ -1181,6 +1181,10 @@ if tax_rounding == 'line': self._round_taxes(taxes) if tax_rounding == 'document': + for taxline in taxes.itervalues(): + tax_compute = Tax.compute(Tax.browse([taxline['tax']]), + taxline['base'], 1) + taxline['amount'] = tax_compute['amount'] self._round_taxes(taxes) return taxes
I know it’s not the best way, but with this you could understand the problem better, I think.