View Issue Details

IDProjectCategoryView StatusLast Update
0003424OXID eShop (all versions)1.02. Price calculations (discounts, coupons, additional costs etc.)public2012-12-07 15:19
Reportertjungcl 
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.5.5 revision 40299 
Target VersionFixed in Version4.5.10 revision 44222 
Summary0003424: brut rounded in netMode
Descriptionin oxprice in _recalculate there is a line, where the brut is rounded.

this was a few versions earlier done always (outside the if case) at meanwhile only in the netmode-case:

    protected function _recalculate()
    {
        if ( $this->_blNetPriceMode ) {
            // rounding base price in netto mode
            $this->_dNetto = oxUtils::getInstance()->fRound( $this->_dNetto );
            $this->_dBrutto = self::netto2Brutto($this->_dNetto, $this->_dVat);

            // rounding brutto price value after each operation
            $this->_dBrutto = oxUtils::getInstance()->fRound( $this->_dBrutto );
        } else {
            $this->_dBrutto = oxUtils::getInstance()->fRound( $this->_dBrutto );
            $this->_dNetto = self::brutto2Netto($this->_dBrutto, $this->_dVat);
        }
    }

=> in NetMode the netto gets rounded. If the brut is rounded too, the vatAmount = brut - net is therefore a rounded result and adding rounded var-amounts gives a wrong total-vat-sum in the basket.

If you just disable the brut-round-line in the netMode case all works fine.



TagsVAT
ThemeBoth
BrowserAll
PHP Versionany
MySQL Versionany

Activities

mindaugas.rimgaila

2012-03-27 15:35

reporter   ~0006099

Removed price rounding from this function. All rounding operations (if needed) should be done in other functions.

tjungcl

2012-04-19 16:45

reporter   ~0006356

Now it rounds the brutto outside the if-case, so it rounds brutto in netto-mode still:

protected function _recalculate()
    {
        if ( $this->_blNetPriceMode ) {
            $this->_dBrutto = self::netto2Brutto($this->_dNetto, $this->_dVat);
        } else {
            $this->_dNetto = self::brutto2Netto($this->_dBrutto, $this->_dVat);
        }
        $this->_dBrutto = oxUtils::getInstance()->fRound($this->_dBrutto);
    }

Plus, rounding the netto in net-mode before calculating the brutto from it was right, why did you change it?
Same with round the brutto before calculating the netto from it in brutto-mode.

As I originially wrote, the correct _recalculate should be:

    protected function _recalculate(){
        if ( $this->_blNetPriceMode ){
            $this->_dNetto = oxUtils::getInstance()->fRound( $this->_dNetto );
            $this->_dBrutto = self::netto2Brutto($this->_dNetto, $this->_dVat);
        }else{
            $this->_dBrutto = oxUtils::getInstance()->fRound( $this->_dBrutto );
            $this->_dNetto = self::brutto2Netto($this->_dBrutto, $this->_dVat);
        }
    }

mindaugas.rimgaila

2012-04-19 17:27

reporter   ~0006359

Thanks for your comments. I checked the function one more time and slightly modified it. Wrote the comment, how rounding should be made.

    /**
     * Calculates price depending on price entering mode.
     * Round only displayed price to the user, other leave as accurate as possible:
     * in Brutto mode: round Brutto price before calculations;
     * in Netto mode: round Brutto price after calculations;
     *
     * @access protected
     *
     * @return null
     */
    protected function _recalculate()
    {
        if ( $this->_blNetPriceMode ) {
            $this->_dBrutto = self::netto2Brutto($this->_dNetto, $this->_dVat);
            $this->_dBrutto = oxUtils::getInstance()->fRound($this->_dBrutto);
        } else {
            $this->_dBrutto = oxUtils::getInstance()->fRound($this->_dBrutto);
            $this->_dNetto = self::brutto2Netto($this->_dBrutto, $this->_dVat);
        }
    }