View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003424 | OXID eShop (all versions) | 1.02. Price calculations (discounts, coupons, additional costs etc.) | public | 2011-12-08 16:16 | 2012-12-07 15:19 |
Reporter | tjungcl | Assigned To | |||
Priority | urgent | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 4.5.5 revision 40299 | ||||
Fixed in Version | 4.5.10 revision 44222 | ||||
Summary | 0003424: brut rounded in netMode | ||||
Description | in 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. | ||||
Tags | VAT | ||||
Theme | Both | ||||
Browser | All | ||||
PHP Version | any | ||||
Database Version | any | ||||
|
Removed price rounding from this function. All rounding operations (if needed) should be done in other functions. |
|
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); } } |
|
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); } } |