[CRITICAL BUG] Wrong calculated price at the rate of exchange (Virtuemart 2.0.8)

Started by serapol, June 30, 2012, 00:09:30 AM

Previous topic - Next topic

serapol

I noticed a serious bug in Virtuemart 2.0.8. Wrong price is calculated at the rate of exchange. Price is not multiplied by the exchange rate, and share and, accordingly, all prices are displayed incorrectly.

An error occurred in the file administrator/components/com_virtuemart/helpers/currencydisplay.php in lines 461 and 463. Necessary signs of multiplication and division to swap.

It must be so

                        if($shop){
$price = $price * $exchangeRate;
} else {
$price = $price / $exchangeRate;
}


After the changes will be correctly calculated price and will work correctly calculating the cost function

jjk

The bug was in previous versions, where price quotation and quantity quotation were mixed up (i.e. the calculation rules used one method and the currency converter module the other one. See this wikipedia link for an explanation. Look at the "Quotations" article: http://en.wikipedia.org/wiki/Exchange_rate

Since quite a while,  VM2 automatically pulls the exchange rates from the European Central Bank (http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html), which are supplied as 'indirect quotation' ('quantity quotation') - in case you leave the exchange rate field empty (actually set to "0.0", which also is the default setting)
Example: EUR 1.00 = USD 1.35991

If you entered an exchange rate manually, the reason why your calculation looks wrong now, probably is that you used the 'direct quotation' ('price quotation').
Example: EUR 0.735342 = USD 1.00

So if you want to use the same fixed exchange rate (not automatically updated) as before, you have to go to the VM2 'Configuration' - 'Currency' and reverse the quotation. (Taking the numbers from the example above, type 1 / 0.735342 into your electronic calculator to and it will give you the quantity quotation = 1.35991, which you have to enter as the exchange rate. **

Thereafter you should have your old prices back  ;)

** Alternatively, when you enter "0.0", VM2 will adjust the exchange rate and your calculated prices automatically when your currency's exchange rate goes up or down.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

serapol

In this case, the developers had to provide for such changes, because the people to upgrade, and all prices will be displayed incorrectly.

And as for me is not very convenient to count a course back to fix the rates. In our country, it is assumed that in Example 1 USD = 8.15 UAH. And I think, not only in my country. That is, the course is calculated relative to the national currency, rather than relative to the euro.

It would be logical to specify which format to make a fixed rate or add a reverse conversion directly into your code.

Milbo

Serapol, we use the standard european notation sent by the bank itself. The error was before and funny is that no one noticed that the notation of the manual entered rates is the reciprocal value
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/