View Issue Details

IDProjectCategoryView StatusLast Update
0006348OXID eShop (all versions)2.2. Shop settingspublic2024-03-13 15:11
Reportersebastian.bauer Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version4.9.7 / 5.2.7 
Summary0006348: After fixing 0006319 the 'smarty_function_oxprice' got an undefined input case and responds a rounded price
DescriptionThe price calculation rounds on special cases (brutto/netto). After fixing the bug 0006319, the smarty_function_oxprice i saw, that there is a case (we don't give in a currency and the settings currencies array (this could be the case, if the user doesn't fills the admin input field)) where the
smarty function rounds, but shouldn't round.
Steps To ReproduceAdd the following test into the file /tests/unit/maintenance/pluginsmartyoxpriceTest.php, to have a running prove for this bug:

    /**
     * Test, that the oxprice smarty plugin will only print the price as a number (with german ".," notation),
     * if there is no value set in the currencies admin input and no currency given into the smarty plugin function.
     */
    public function testNoCurrencyObjectAsParameterAndNotInConfig() {
        $oConfig = oxRegistry::getConfig();
        $oConfig->setConfigParam('aCurrencies', array());

        $aParams = array(
            'price' => new oxPrice(1992.45),
        );

        $oSmarty = new Smarty();

        // we utf8 decode here to make the test more robust against shop settings
        $this->assertEquals(utf8_decode('1.992,45'), utf8_decode(smarty_function_oxprice($aParams, $oSmarty)));
    }
TagsInternationalization Rework, Product domain and basket rewrite
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

sebastian.bauer

2016-05-20 16:01

reporter   ~0011598

Add the following test into the file /tests/unit/maintenance/pluginsmartyoxpriceTest.php, to have a running prove for this bug:

    /**
     * Test, that the oxprice smarty plugin will only print the price as a number (with german ".," notation),
     * if there is no value set in the currencies admin input and no currency given into the smarty plugin function.
     */
    public function testNoCurrencyObjectAsParameterAndNotInConfig() {
        $oConfig = oxRegistry::getConfig();
        $oConfig->setConfigParam('aCurrencies', array());

        $aParams = array(
            'price' => new oxPrice(1992.45),
        );

        $oSmarty = new Smarty();

        // we utf8 decode here to make the test more robust against shop settings
        $this->assertEquals(utf8_decode('1.992,45'), utf8_decode(smarty_function_oxprice($aParams, $oSmarty)));
    }

preethi

2016-10-19 15:49

reporter   ~0011844

The following behavior is because no currency/precision information is given. When the below code in the steps to Reproduce-

$oConfig->setConfigParam('aCurrencies', array());

is replaced with-

$oConfig->setConfigParam('aCurrencies', array('EUR@ 1.00@ ,@ .@ @ 2'));

then the test case passes without any error.

When no precision for currency is provided then the default precision value in PHP(namely 0) is used.

QA

2016-10-20 15:04

administrator   ~0011845

A new variable with default currency settings could be used, when no values are set in "Admin->Master Settings->Core Settings->Settings->Other Settings->Add or remove currencies"