← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 670307] Re: res.currency rounding error

 

I closed the bug as it seems to work fine in trunk.
Can you reopen if you have a problem in trunk ?

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/670307

Title:
  res.currency rounding error

Status in OpenObject Server:
  Invalid

Bug description:
  The round function of res.currency is making some rounding error:

With euro for instance, the rounding factor is 0.01
The rounding function (in version 5 and trunk) is:
    round(amount / currency.rounding) * currency.rounding

Let's take an invoice line with qty = 4.35 and price = 5.70
    4.35 * 5.70 = 24.795 ~ 24.80€
When rounded with res.currency the result is 24.79€

in python terminal:
>>> a = 4.35*5.7
>>> b = 0.01
>>> a/b
2479.4999999999995
>>> round(a/b)
2479.0
>>> round(a/b)*b
24.789999999999999

This bug is quite problematic since with receive a supplier invoice billed 24.80€ and we compute 24.79€. Legally, we must store in accounting the exact amount!
This could be solved by using Decimal but it would be more costly...





References