← 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

 

Hello Carlos,

Yes, we got a same problem as per your scenario because of the exchange
rate.

First I want to say this is not a bug, but sometimes it's happening with
inconsistency due to exchange rate.

Let me explain in detail.
For 2nd scenario You have put a exchange rate = 0.001942 (1/515). Now the calculation is like.

1 CRC = 0.001942 USD
(?) CRC = 1500 USD , So 1500USD = 1500/0.001942 CRC = 772,399.59 CRC. which is the value you got on your 2nd scenario.

As in 1st scenario you got a value 772,500 CRC (1500*515 USD), So the
difference is become more than 100CRC due to some decimal values.

You said that "I can't just set the CRC to rate 1 and USD to the
according rate (for 515 it would be aprox 0.001942) " but the correct
value is (1/515) = 0.001941748. If you put this exchange rate on USD
then you will got a correct result on both secnario.

But the problem is we can't give more than 6 digits on decimal point because we have set a digits=(12,6) on rate field. If we have set a digit =(16,10), this is allow to set a  0.001941748 on exchange rate and return the following result on 2nd scenario.
1500/ 0.001941748 = 772499.830050037 which is totally nearest to your result.
 
So as per my "Opinion" we have to change the digits of rate field on res.currency.rate object like (12,6).

What do your think?

Thanks and waiting for your reply!

-- 
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):
  New

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


Follow ups

References