[sale_tax_include][account_tax_include] rounding error on taxed amount

Bug #510726 reported by Sébastien BEAU - http://www.akretion.com
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Won't Fix
Medium
Unassigned

Bug Description

I have a bug with account_tax_includ and sale_tax_include (purchase_tax_include don't work on my installation)

Create a new product with 9€ for the price and a include VAT tax of 19,6% (ex : sale French VAT)
Create a new sale order (or a new invoice, it's the same bug)
And add the product
Compute taxe

And... the result is
untaxed amount : 7,53€
taxed amount : 1,48€
total amount : 9,01€ !!!

The problem is simply, OpenERP have made a round on temporary untaxed amount :
untaxed amount = 9/1,196 = 7,525083612 ==> 7,53€
taxed amount = 7,53x1,196 = 9,00588 ==> 9,01€

So 9,00 = 9,01 ;)

The solution is to not round the tempory value of untaxed amount :
untaxed amount = 9/1,196 = 7,525083612
taxed amount = 7,525083612x1,196 = 9€

After calculating the taxe untaxe amount can be rounded without problem.
Moreover before returning value of untaxe amount and total amount are rounded (line 89-90)

I join a patch, if you disagree with the idea of deleting the round option in compute_inv, maybe we can add a optional parameter to compute_inv method to choose if we want a rounding value of tax amount or not; in the case of sale_tax_include and account_tax_include the optional parameter will be use to disable the rounding funtion.

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :
Changed in openobject-addons:
importance: Undecided → Medium
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Sebastien,

Are you sure this happens at your end?

I made Invoice and SO with the same configuration: I get 7.53,1.47 and 9.00.

Can you recheck? I checked with price_accuracy 2 3 4 too.

Thanks.

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello Jay,

I'm sorry, the bug report of Sebastien was incomplete indeed.
Watch carefully the described steps but also do the following:
The rounding bug will ONLY occurs
- IF your tax is set with the flag "Tax included in price" right on the tax object (not just on the order/invoice line)
- AND if you choose the order/invoice method as "Tax excluded" (it will be included anyway due to the tax setting)
use a unit price with 9 EUR and a sale VAT at 19.6% to make sure you'll see 9.01 EUR as the line subtotal.

For now there is that simple rounding issue to fix.

But yes, in the long run, this is awkward functionally speaking: once you parameter a tax to be included in price at the tax level, the order/invoice select box Tax excluded/Tax included is just useless except this will make that rounding bug show or not!

My view is that this option should be removed (as it is just less fined grained) from the order/invoice form and it should be re-factored into the core of OpenERP (so many accounting require included taxes) avoiding thus those brittle brutal override that do not call super and are thus very easily incompatible between modules and would generate an endless series of bugs. I think 5.2 is the opportunity to bite the bullet, I can't imagine this being all broken with broken modules on the top of it developing until mid 2011 if 5.2 is missed.

If you like you can read my comment and comment on the accounting expert list here:
https://launchpad.net/~openerp-expert-accounting
archive: http://n3.nabble.com/More-fun-with-taxes-included-and-rounding-issues-tc140823.html#a140823

Changed in openobject-addons:
status: Incomplete → New
Changed in openobject-addons:
status: New → Confirmed
Revision history for this message
JordiFS (jordi-figuerola) wrote :

Certainly, the tax calculations should have all decimals in its computation and at the end the roundup.

To achieve the total tax computation I have made the following changes:

1-In the database, table account_invoice_line I have modified the fields to store currencies to be numeric(16,8). I use eight decimals because PostgreSQL uses two bytes for every group of four decimals so I am able to see the real numbers.

2-Started the openerp-server with parameter: --price_accuracy=5.

3-Modified the source code for line tax and sum calculation with straight double precision since the roundup to currency precision should be made only at the end. I have attached the patch just in case you want to test.

I am aware that there is an effort to put-in some criteria on currency, price and computing calculation's precision for the next version to come (https://launchpad.net/~openerp-expert-accounting.)

There should be a more precise and close look to rounding of calculations, but this patch has helped me to achieve precise tax calculations of invoices for products with small values and many lines, that otherwise could lead to round per line to one cent or even to zero! so tax calculation is wrongly calculated.

I see it like -maybe- is not a coding bug itself but -maybe- a conceptual gap that looks like a bug; never-the-less the result is wrong. Good luck guys!

Revision history for this message
JordiFS (jordi-figuerola) wrote :
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Can you check with the trunk version?
Price_accuracy has been fixed with trunk version.
Thanks.

Changed in openobject-addons:
milestone: none → 5.0.11
milestone: 5.0.11 → 6.0
Revision history for this message
Jan Verlaan (jan-verlaan) wrote :

Any progress on this to include the patch in version 5?

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Won't fix: we rewrite everything in the trunk branch so that the sale_ta_include and account_tax_include modules are not usefull anymore. Everything is tax include/excluded by default in trunk according to the configuration of the taxes.

Changed in openobject-addons:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.