ZF-6560: Zend_Currency::toCurrency(): precision bug with positive values
Description
I have a small test for checking the new behaviour of Zend_Currency with Zend_Locale_Format. There is a bug in Zend_Locale_Format::toNumber(). Here is a small snippet to test the bug:
(I cannot write euro sign, so I use EUR instead!
require_once 'Zend/Currency.php';
$currency = new Zend_Currency(null, 'de_DE');
Zend_Debug::dump($currency->toCurrency(74.95, array('currency' => 'EUR', 'precision' => 2))); // returns 74,95 EUR
Zend_Debug::dump($currency->toCurrency(74.95, array('currency' => 'EUR', 'precision' => 3))); // returns 74,950EUR
Zend_Debug::dump($currency->toCurrency(74.95, array('currency' => 'EUR', 'precision' => 4))); // returns 74,9500 // No euro sign !
Zend_Debug::dump($currency->toCurrency(74.95, array('currency' => 'EUR', 'precision' => 4))); // returns 74,95000 // No euro sign
I have found out that on line 444, Zend/Locale/Format.php will return (bool)false instead of an integer value with precision higher than 3. When this happens, the euro sign lefts (or its placeholder in $format).
This results in teh bug, that there is a missing space between the value and the euro sign. In ZF 1.7.7, the method Zend_Locale_Format::toNumber() is different at this point.
Comments
Posted by Thomas Weidner (thomas) on 2009-05-16T07:31:59.000+0000
Fixed with r15607