← Back to team overview

openerp-india team mailing list archive

[Bug 980967] Re: [6.1] [account_voucher] exchange rate calculation is not working if company currency isn't rate 1

 

Hi Ravish,

Thank you for your fast reply.

I don't agree with you. As I explained in comment #1, the point is to
have a company currency with a currency rate different than 1.

For example:

I set USD to rate 1.
I have a company in CRC with rates changing every day at about 515.

I can't just set the CRC to rate 1 and USD to the according rate (for
515 it would be aprox 0.001942) because there are divisions involved,
and divisions lose data. With these rates, if you convert $1500 using
515 CRC per 1 USD you have 772,500 CRC, which is expected in our
economy. If you do it with 0.001942 USD per 1 CRC you have 772,399.59
CRC: 100.41 CRC less than it should be. This kind of error is not
acceptable, and in the normal operation could lead to mistakes of
several hundred USD per month.

There are several countries where this case applies, when you have an
economy indexed to USD, but with a local currency that is very
devaluated. Also this case applies if you have a multi-company
configuración on different countries, where you need to set different
currencies per company. You will have some companies with currencies
with rates other than 1.

So the solution you are providing is just a special case of use for the
multi-currency configuration, not the correct way to do it. Please look
at my merge proposal, I think my code fixes the error.

Thanks

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/980967

Title:
  [6.1] [account_voucher] exchange rate calculation is not working if
  company currency isn't rate 1

Status in OpenERP Addons (modules):
  Incomplete

Bug description:
  In the account_voucher module, the currency rate is not well
  calculated. The method that write the account move line is not
  correct. It starts at line 227 in account_voucher.py:

      def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None):
          if not ids: return {}
          res = {}
          rate = 1.0
          for voucher in self.browse(cr, uid, ids, context=context):
              if voucher.currency_id:
                  if voucher.company_id.currency_id.id == voucher.payment_rate_currency_id.id:
                      rate =  1 / voucher.payment_rate
                  else:
                      ctx = context.copy()
                      ctx.update({'date': voucher.date})
                      voucher_rate = self.browse(cr, uid, voucher.id, context=ctx).currency_id.rate
                      company_currency_rate = voucher.company_id.currency_id.rate
                      rate = voucher_rate * company_currency_rate
              res[voucher.id] =  voucher.amount / rate
          return res

  This should be (diff output):

           for voucher in self.browse(cr, uid, ids, context=context):
               if voucher.currency_id:
                   if voucher.company_id.currency_id.id == voucher.payment_rate_currency_id.id:
  -                    rate =  1 / voucher.payment_rate
  +                    rate =  voucher.payment_rate
                   else:
                       ctx = context.copy()
                       ctx.update({'date': voucher.date})
                       voucher_rate = self.browse(cr, uid, voucher.id, context=ctx).currency_id.rate
                       company_currency_rate = voucher.company_id.currency_id.rate
  -                    rate = voucher_rate * company_currency_rate
  -            res[voucher.id] =  voucher.amount / rate
  +                    rate = company_currency_rate / voucher_rate
  +            res[voucher.id] =  voucher.amount * rate
           return res

  
  I am posting a merge proposal with this change in a couple of minutes.

  There is also a wrong currency_amount value calculation even if you
  apply the previous patch. This wrong calculation apply to only some
  lines of the move. I will get back on this bug about this later.

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


References