Improve rounding taxes when the tax_rounding field is set to 'document'

accounting

(Bernat) #1

Rational

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.

Proposal

Calculate the tax amount of ‘Tax Lines’ using it base.

Implementation

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[0]['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.


(Cédric Krier) #2

I would say to not use document rounding if you do not want any rounding difference.


(Cédric Krier) #3

Your proposal will just move the rounding issue on the accounting as your base amount for the tax will not be the sum of the product lines. This should also not be accepted by authorities if they do not accept the other rounding difference. But it is bigger issue because you can no more proof with your accounting, your tax report.
Indeed what you want is that the base was not rounded on each line: modules/account: 9a9d55047b05 tax.py but only in _round_taxes.

Maybe what you would like is to group lines from an invoice that have the same accounting configuration (account, taxes etc.) and create a single line for it. That would be a valid option but I doubt it is doable without increasing a lot the complexity of account_invoice module.


(Sergi Almacellas Abellana) #4

I remember having this kind of request and implementing it with a customization module. With the current design it was possible without touching the account_invoice code.


(Cédric Krier) #5

In this case it could be a complementary standard module if the code is clean and maintainable.


(Bernat) #6

Cédric, grouping lines could a good solution.

Sergi if its possible, could you share the module? I will try it. And if all works well and Cédric agree with the code, we could add as a complementary standard modules as he said.