ZF-9522: Zend_Currency::_exchangeCurrency() requires 1/$rate from Zend_Currency_CurrencyInterface::getRate() instead of real rate value
Description
Current usage of Zend_Currency_CurrencyInterface::getRate() requires to return 1/$rate instead of $rate
Code:
class ExchangerService implements Zend_Currency_CurrencyInterface
{
public function getRate($from, $to)
{
if ('RUB' == $from && 'USD' == $to)
return 0.033333;
elseif ('USD' == $from && 'RUB' == $to)
return 30;
return 1;
}
}
$zc = new Zend_Currency('RUB', 'ru_RU');
$zc->setService(new ExchangerService());
$zc->setValue(100, 'USD'); // expected exchange 100 USD to 3000 RUB (rate is 30 from USD to RUB)
echo $zc->toCurrency();
Result:
3,33 руб.
Expected value:
3 000,00 руб.
Comments
Posted by Thomas Weidner (thomas) on 2010-03-25T14:00:26.000+0000
Implemented with r21647.