← Back to team overview

openerp-expert-accounting team mailing list archive

[Bug 865387] Re: wrong currency rounding

 

Hi,

We don't use Decimal for OpenERP, our floating point calculations are all performed with floats, and we have appropriate solutions for all cases based on floats. So for consistency, please do not introduce the use of Decimal in patches.
For more info on the everlasting Float vs. Decimal discussion, see [1].

Here the problem is the equality comparison in account_voucher. For checking that 2 amounts are equal with regard to an appropriate precision, the 2 amounts should be subtracted and checked with res.currency.is_zero().
You can see other examples of how this is done in other places in the code, for example [2].

Thanks!

[1] https://lists.launchpad.net/openerp-expert-accounting/msg00067.html
[2] http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/5493/account_voucher/account_voucher.py#L940

** Changed in: openobject-addons
   Importance: Low => Medium

-- 
You received this bug notification because you are a member of OpenERP
Accounting Experts, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/865387

Title:
  wrong currency rounding

Status in OpenERP Addons (modules):
  Confirmed

Bug description:
  openobject-addons/6.0 revno 4863

  Steps:

   - Configure 'account' module using EUR currency
   - Configure a bank journal for USD currency
   - Create a new rate for USD currency, with date 2011-10-01
   - Create a new invoice, with date 2011-09-01, selecting USD currency and inserting one line of 3638.97 amount
   - Pay the invoice selecting 'Reconcile with Write-Off' (with today's date)

  The write.off entry is not created (it should be produced by the different currency rates).
  This is because of line 88 of base/res/res_currency.py :

  round(amount / currency.rounding) * currency.rounding
  3638.9700000000003

  and this makes false the line 719 of account_voucher.py (line.amount
  == line.amount_unreconciled)

  
  I think the line

  return round(amount / currency.rounding) * currency.rounding

  should be replaced by something like

  float(Decimal(str(amount)).quantize(Decimal(str(currency.rounding)),
  rounding=ROUND_HALF_UP))

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/865387/+subscriptions


Follow ups