Multi-Currency Method

Does anybody know where is the code located that converts currencies using / I want to replace it with * so I can get the right conversion between two currencies with huge value differences, Doli can’t handle more than 10 decimals. Thanks!

Are you using API to update currency rate.

If yes, try to use only manual to check if the rates reflects correctly.

No, then check on Multicurrency/class/multicurrency.class.php, should be there…

Everything is working fine, the problem is both currencies have huge amount differences between them so Doli can’t give the exact amount due to decimals division. So I think is better to change the operation method from division to multiplication. I’m not using the API because rates are not even close from the legal ones in my country.

I have taken a look already at that file without success, I’ve changed a couple of lines but proposals seems to have their own conversion method when you proceed to calculate between prices. Any other idea where could it be? Thanks!!!

In that file in line 562 I’ve found this code if ($way == ‘dolibarr’) return $amount * $multicurrency_tx; else return $amount / $multicurrency_tx; but after interchange the / and the * nothing happens in proposals.

Solved… If you want to change the calculation method you have to change line 159 $pu = $pu_devise * $multicurrency_tx; to $pu = $pu_devise / $multicurrency_tx; and line 169 $pu_devise = $pu / $multicurrency_tx; to $pu_devise = $pu * $multicurrency_tx;

This is in case you have a currency with huge amount difference with external currency. In my case COP = 0.0003333333 USD. (decimals where not enough to get a precise conversion)

Maybe this can help you

fetchAllCurrencyRate()
MultiCurrency::fetchAllCurrencyRate ( )
Load all rates in object from the database.

Returns
int <0 if KO, >=0 if OK
Definition at line 238 of file multicurrency.class.php.

Hi,
The post is very useful for me, shares with more information. Thank you.