Issues

ZF-9522: Zend_Currency::_exchangeCurrency() requires 1/$rate from Zend_Currency_CurrencyInterface::getRate() instead of real rate value

Issue Type: Bug Created: 2010-03-23T15:20:00.000+0000 Last Updated: 2010-03-25T14:00:28.000+0000 Status: Resolved Fix version(s): - 1.10.3 (01/Apr/10)

Reporter: Sergey Kolosov (m17) Assignee: Thomas Weidner (thomas) Tags: - Zend_Currency

Related issues: Attachments:

Description

Current usage of Zend_Currency_CurrencyInterface::getRate() requires to return 1/$rate instead of $rate

Code:

<pre class="highlight">
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:

<pre class="highlight">
3,33 руб.

Expected value:

<pre class="highlight">
3 000,00 руб.

Comments

Posted by Thomas Weidner (thomas) on 2010-03-25T14:00:26.000+0000

Implemented with r21647.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts