ZF-10549: Zend_Currency with exchange service results in incorrect currency-symbol when adding currencies
//Precondition: the locale is set to 'nl_NL', which has EUR as currency //original currency+value (USD0.0) $currency = new Zend_Currency( array( 'value' => 0.0, 'currency' => 'USD', ) ); $currency->setService(Zend_Registry::get('ZFCustom_Currency_ExchangeService')); $currency2 = new Zend_Currency( array( 'value' => 250, 'currency' => 'EUR', ) ); $currency->add($currency2);//EUR250 exchanged to USD347.08 echo $currency.'
'; //prints '€ 347,08' echo $currency->toCurrency(null, array('currency' => 'USD')).'
'; //prints 'US$ 347,08'
As can be seen in above example code, the original currency of $currency (USD) is ignored as the euro-sign is printed while the exchange rate is applied on the value. This is incorrect, if it prints euro then it should be the value 250. The expected result is be the original currency (USD) for $currency.
The second echo is the currency+value that is expected (US$ 347,08), but this is only to show the expected result for this example.
What is clear is that the behavior of Zend_Currency is incorrect in this scenario. Maybe the locale is the problem here but I am not sure.
It is important to have control on the currency and locale seperately as most real case scenario's will not change the currency while locale does (e.g. English translations of the website).