/** * Check if product prices inputed include tax * * @param null|int $store * @return bool */ public function priceIncludesTax($store = null) { if ($this->_getDataHelper()->isAvataxEnabled($store)) { return false; } return parent::priceIncludesTax($store); }
/** * Check if price include tax should be used for calculations. * We are using price include tax just in case when catalog prices are including tax * and customer tax request is same as store tax request * * @param $store * @return bool */ protected function _usePriceIncludeTax($store) { if ($this->_config->priceIncludesTax($store) || $this->_config->getNeedUsePriceExcludeTax()) { return $this->_areTaxRequestsSimilar; } return false; }
/** * Check if we need subtract store tax amount from item prices * * @deprecated after 1.4.1 * * @param Mage_Sales_Model_Quote_Address $address * * @return bool */ protected function _needSubtractTax($address) { $store = $address->getQuote()->getStore(); if ($this->_config->priceIncludesTax($store) || $this->_config->getNeedUsePriceExcludeTax()) { return true; } return false; }
/** * Add extra amount which should be taxable by regular tax * * @param Mage_Sales_Model_Quote_Item_Abstract $item * @param float $value * @param float $baseValue * @param float $rowValue * @param float $baseRowValue * @return Mage_Weee_Model_Total_Quote_Weee */ protected function _processTaxSettings($item, $value, $baseValue, $rowValue, $baseRowValue) { if ($this->_helper->isTaxable($this->_store) && $rowValue) { if (!$this->_config->priceIncludesTax($this->_store)) { $item->setExtraTaxableAmount($value)->setBaseExtraTaxableAmount($baseValue)->setExtraRowTaxableAmount($rowValue)->setBaseExtraRowTaxableAmount($baseRowValue); } $item->unsRowTotalInclTax()->unsBaseRowTotalInclTax()->unsPriceInclTax()->unsBasePriceInclTax(); $this->_isTaxAffected = true; } return $this; }
public function priceIncludesTax($store = null) { $bid_id = Mage::getSingleton('core/session')->getData('bid_id'); if (!$bid_id) { return parent::priceIncludesTax($store); } else { if ((int) Mage::getStoreConfig('auction/tax/is_included_tax') == 1) { return true; } else { return false; } } }
/** * Collect tax totals for quote address * * @param Mage_Sales_Model_Quote_Address $address * @return Mage_Tax_Model_Sales_Total_Quote */ public function collect(Mage_Sales_Model_Quote_Address $address) { parent::collect($address); $this->_roundingDeltas = array(); $this->_baseRoundingDeltas = array(); $this->_hiddenTaxes = array(); $address->setShippingTaxAmount(0); $address->setBaseShippingTaxAmount(0); $this->_store = $address->getQuote()->getStore(); $customer = $address->getQuote()->getCustomer(); if ($customer) { $this->_calculator->setCustomer($customer); } if (!$address->getAppliedTaxesReset()) { $address->setAppliedTaxes(array()); } $items = $this->_getAddressItems($address); if (!count($items)) { return $this; } $request = $this->_calculator->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $this->_store); if ($this->_config->priceIncludesTax($this->_store)) { $this->_areTaxRequestsSimilar = $this->_calculator->compareRequests($this->_calculator->getRateOriginRequest($this->_store), $request); } switch ($this->_config->getAlgorithm($this->_store)) { case Mage_Tax_Model_Calculation::CALC_UNIT_BASE: $this->_unitBaseCalculation($address, $request); break; case Mage_Tax_Model_Calculation::CALC_ROW_BASE: $this->_rowBaseCalculation($address, $request); break; case Mage_Tax_Model_Calculation::CALC_TOTAL_BASE: $this->_totalBaseCalculation($address, $request); break; default: break; } $this->_addAmount($address->getExtraTaxAmount()); $this->_addBaseAmount($address->getBaseExtraTaxAmount()); $this->_calculateShippingTax($address, $request); $this->_processHiddenTaxes(); return $this; }
/** * Aggregate row totals per tax rate in array * * @param Mage_Sales_Model_Quote_Item_Abstract $item * @param float $rate * @param array $taxGroups * @return Mage_Tax_Model_Sales_Total_Quote */ protected function _aggregateTaxPerRate($item, $rate, &$taxGroups, $taxId = null, $recalculateRowTotalInclTax = false) { $inclTax = $item->getIsPriceInclTax(); $rateKey = $taxId == null ? (string) $rate : $taxId; $taxSubtotal = $subtotal = $item->getTaxableAmount(); $baseTaxSubtotal = $baseSubtotal = $item->getBaseTaxableAmount(); $isWeeeEnabled = $this->_weeeHelper->isEnabled(); $isWeeeTaxable = $this->_weeeHelper->isTaxable(); if (!isset($taxGroups[$rateKey]['totals'])) { $taxGroups[$rateKey]['totals'] = array(); $taxGroups[$rateKey]['base_totals'] = array(); $taxGroups[$rateKey]['weee_tax'] = array(); $taxGroups[$rateKey]['base_weee_tax'] = array(); } $hiddenTax = null; $baseHiddenTax = null; $weeeTax = null; $baseWeeeTax = null; $discount = 0; $rowTaxBeforeDiscount = 0; $baseRowTaxBeforeDiscount = 0; $weeeRowTaxBeforeDiscount = 0; $baseWeeeRowTaxBeforeDiscount = 0; switch ($this->_helper->getCalculationSequence($this->_store)) { case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL: case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL: $rowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false); $baseRowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false); if ($isWeeeEnabled && $isWeeeTaxable) { $weeeRowTaxBeforeDiscount = $this->_calculateRowWeeeTax(0, $item, $rate, false); $baseWeeeRowTaxBeforeDiscount = $this->_calculateRowWeeeTax(0, $item, $rate); $rowTaxBeforeDiscount += $weeeRowTaxBeforeDiscount; $baseRowTaxBeforeDiscount += $baseWeeeRowTaxBeforeDiscount; $taxGroups[$rateKey]['weee_tax'][] = $this->_deltaRound($weeeRowTaxBeforeDiscount, $rateKey, $inclTax); $taxGroups[$rateKey]['base_weee_tax'][] = $this->_deltaRound($baseWeeeRowTaxBeforeDiscount, $rateKey, $inclTax); } $taxBeforeDiscountRounded = $rowTax = $this->_deltaRound($rowTaxBeforeDiscount, $rateKey, $inclTax); $baseTaxBeforeDiscountRounded = $baseRowTax = $this->_deltaRound($baseRowTaxBeforeDiscount, $rateKey, $inclTax, 'base'); $item->setTaxAmount($item->getTaxAmount() + max(0, $rowTax)); $item->setBaseTaxAmount($item->getBaseTaxAmount() + max(0, $baseRowTax)); break; case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL: case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL: if ($this->_helper->applyTaxOnOriginalPrice($this->_store)) { $discount = $item->getOriginalDiscountAmount(); $baseDiscount = $item->getBaseOriginalDiscountAmount(); } else { $discount = $item->getDiscountAmount(); $baseDiscount = $item->getBaseDiscountAmount(); } //We remove weee discount from discount if weee is not taxed if ($isWeeeEnabled && $this->_weeeHelper->includeInSubtotal()) { $discount = $discount - $item->getWeeeDiscount(); $baseDiscount = $baseDiscount - $item->getBaseWeeeDiscount(); } $taxSubtotal = max($subtotal - $discount, 0); $baseTaxSubtotal = max($baseSubtotal - $baseDiscount, 0); $rowTax = $this->_calculator->calcTaxAmount($taxSubtotal, $rate, $inclTax, false); $baseRowTax = $this->_calculator->calcTaxAmount($baseTaxSubtotal, $rate, $inclTax, false); if ($isWeeeEnabled && $this->_weeeHelper->isTaxable()) { $weeeTax = $this->_calculateRowWeeeTax($item->getWeeeDiscount(), $item, $rate, false); $rowTax += $weeeTax; $baseWeeeTax = $this->_calculateRowWeeeTax($item->getBaseWeeeDiscount(), $item, $rate); $baseRowTax += $baseWeeeTax; $taxGroups[$rateKey]['weee_tax'][] = $weeeTax; $taxGroups[$rateKey]['base_weee_tax'][] = $baseWeeeTax; } $rowTax = $this->_deltaRound($rowTax, $rateKey, $inclTax); $baseRowTax = $this->_deltaRound($baseRowTax, $rateKey, $inclTax, 'base'); $item->setTaxAmount($item->getTaxAmount() + max(0, $rowTax)); $item->setBaseTaxAmount($item->getBaseTaxAmount() + max(0, $baseRowTax)); //Calculate the Row taxes before discount $rowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false); $baseRowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false); if ($isWeeeTaxable) { $weeeRowTaxBeforeDiscount = $this->_calculateRowWeeeTax(0, $item, $rate, false); $rowTaxBeforeDiscount += $weeeRowTaxBeforeDiscount; $baseWeeeRowTaxBeforeDiscount = $this->_calculateRowWeeeTax(0, $item, $rate); $baseRowTaxBeforeDiscount += $baseWeeeRowTaxBeforeDiscount; } $taxBeforeDiscountRounded = max(0, $this->_deltaRound($rowTaxBeforeDiscount, $rateKey, $inclTax, 'tax_before_discount')); $baseTaxBeforeDiscountRounded = max(0, $this->_deltaRound($baseRowTaxBeforeDiscount, $rateKey, $inclTax, 'tax_before_discount_base')); if (!$item->getNoDiscount()) { if ($item->getWeeeTaxApplied()) { $item->setDiscountTaxCompensation($item->getDiscountTaxCompensation() + $taxBeforeDiscountRounded - max(0, $rowTax)); } } if ($inclTax && $discount > 0) { $roundedHiddenTax = $taxBeforeDiscountRounded - max(0, $rowTax); $baseRoundedHiddenTax = $baseTaxBeforeDiscountRounded - max(0, $baseRowTax); $this->_hiddenTaxes[] = array('rate_key' => $rateKey, 'qty' => 1, 'item' => $item, 'value' => $roundedHiddenTax, 'base_value' => $baseRoundedHiddenTax, 'incl_tax' => $inclTax); } break; } $rowTotalInclTax = $item->getRowTotalInclTax(); if (!isset($rowTotalInclTax) || $recalculateRowTotalInclTax) { if ($this->_config->priceIncludesTax($this->_store)) { $item->setRowTotalInclTax($subtotal); $item->setBaseRowTotalInclTax($baseSubtotal); } else { $item->setRowTotalInclTax($item->getRowTotalInclTax() + $taxBeforeDiscountRounded - $weeeRowTaxBeforeDiscount); $item->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax() + $baseTaxBeforeDiscountRounded - $baseWeeeRowTaxBeforeDiscount); } } $taxGroups[$rateKey]['totals'][] = max(0, $taxSubtotal); $taxGroups[$rateKey]['base_totals'][] = max(0, $baseTaxSubtotal); $taxGroups[$rateKey]['tax'][] = max(0, $rowTax); $taxGroups[$rateKey]['base_tax'][] = max(0, $baseRowTax); return $this; }
/** * Check if product prices inputted include tax * * @param mix $store * @return bool */ public function priceIncludesTax($store = null) { return $this->_config->priceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax(); }
/** * Calculate item price and row total including/excluding tax based on total price rounding level * * @param Mage_Sales_Model_Quote_Item_Abstract $item * @param Varien_Object $request * @return Mage_Tax_Model_Sales_Total_Quote_Subtotal */ protected function _totalBaseCalculation($item, $request) { $calc = $this->_calculator; $request->setProductClassId($item->getProduct()->getTaxClassId()); $rate = $calc->getRate($request); $qty = $item->getTotalQty(); $price = $taxPrice = $item->getCalculationPriceOriginal(); $basePrice = $baseTaxPrice = $item->getBaseCalculationPriceOriginal(); $subtotal = $taxSubtotal = $item->getRowTotal(); $baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal(); $taxOnOrigPrice = !$this->_helper->applyTaxOnCustomPrice($this->_store) && $item->hasCustomPrice(); if ($taxOnOrigPrice) { $origSubtotal = $item->getOriginalPrice() * $qty; $baseOrigSubtotal = $item->getBaseOriginalPrice() * $qty; } $item->setTaxPercent($rate); if ($this->_config->priceIncludesTax($this->_store)) { if ($this->_sameRateAsStore($request)) { if ($taxOnOrigPrice) { $rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, true, false), $rate, true); $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, true, false), $rate, true, 'base'); $taxable = $origSubtotal; $baseTaxable = $baseOrigSubtotal; } else { $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, true, false), $rate, true); $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, true, false), $rate, true, 'base'); $taxable = $subtotal; $baseTaxable = $baseSubtotal; } $taxPrice = $price; $baseTaxPrice = $basePrice; $taxSubtotal = $subtotal; $baseTaxSubtotal = $baseSubtotal; $subtotal = $subtotal - $rowTax; $baseSubtotal = $baseSubtotal - $baseRowTax; $price = $calc->round($subtotal / $qty); $basePrice = $calc->round($baseSubtotal / $qty); $isPriceInclTax = true; } else { $storeRate = $calc->getStoreRate($request, $this->_store); if ($taxOnOrigPrice) { $storeTax = $calc->calcTaxAmount($origSubtotal, $storeRate, true, false); $baseStoreTax = $calc->calcTaxAmount($baseOrigSubtotal, $storeRate, true, false); } else { $storeTax = $calc->calcTaxAmount($subtotal, $storeRate, true, false); $baseStoreTax = $calc->calcTaxAmount($baseSubtotal, $storeRate, true, false); } $subtotal = $calc->round($subtotal - $storeTax); $baseSubtotal = $calc->round($baseSubtotal - $baseStoreTax); $price = $calc->round($subtotal / $qty); $basePrice = $calc->round($baseSubtotal / $qty); $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true); $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base'); $taxSubtotal = $subtotal + $rowTax; $baseTaxSubtotal = $baseSubtotal + $baseRowTax; $taxPrice = $calc->round($taxSubtotal / $qty); $baseTaxPrice = $calc->round($baseTaxSubtotal / $qty); $taxable = $subtotal; $baseTaxable = $baseSubtotal; $isPriceInclTax = false; } } else { if ($taxOnOrigPrice) { $rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, false, false), $rate, true); $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, false, false), $rate, true, 'base'); $taxable = $origSubtotal; $baseTaxable = $baseOrigSubtotal; } else { $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true); $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base'); $taxable = $subtotal; $baseTaxable = $baseSubtotal; } $taxSubtotal = $subtotal + $rowTax; $baseTaxSubtotal = $baseSubtotal + $baseRowTax; $taxPrice = $calc->round($taxSubtotal / $qty); $baseTaxPrice = $calc->round($baseTaxSubtotal / $qty); $isPriceInclTax = false; } if ($item->hasCustomPrice()) { /** * Initialize item original price before declaring custom price */ $item->getOriginalPrice(); $item->setCustomPrice($price); $item->setBaseCustomPrice($basePrice); } else { $item->setConvertedPrice($price); } $item->setPrice($basePrice); $item->setBasePrice($basePrice); $item->setRowTotal($subtotal); $item->setBaseRowTotal($baseSubtotal); $item->setPriceInclTax($taxPrice); $item->setBasePriceInclTax($baseTaxPrice); $item->setRowTotalInclTax($taxSubtotal); $item->setBaseRowTotalInclTax($baseTaxSubtotal); $item->setTaxableAmount($taxable); $item->setBaseTaxableAmount($baseTaxable); $item->setIsPriceInclTax($isPriceInclTax); if ($this->_config->discountTax($this->_store)) { $item->setDiscountCalculationPrice($taxSubtotal / $qty); $item->setBaseDiscountCalculationPrice($baseTaxSubtotal / $qty); } elseif ($isPriceInclTax) { $item->setDiscountCalculationPrice($subtotal / $qty); $item->setBaseDiscountCalculationPrice($baseSubtotal / $qty); } return $this; }
/** * @magentoConfigFixture current_store tax/calculation/price_includes_tax 1 */ public function testPriceIncludesTaxNonDefault() { $this->assertTrue($this->_model->priceIncludesTax()); }
/** * Aggregate row totals per tax rate in array * * @param Mage_Sales_Model_Quote_Item_Abstract $item * @param float $rate * @param array $taxGroups * @return Mage_Tax_Model_Sales_Total_Quote */ protected function _aggregateTaxPerRate($item, $rate, &$taxGroups) { $inclTax = $item->getIsPriceInclTax(); $rateKey = (string) $rate; $taxSubtotal = $subtotal = $item->getTaxableAmount(); $baseTaxSubtotal = $baseSubtotal = $item->getBaseTaxableAmount(); $isWeeeEnabled = $this->_weeeHelper->isEnabled(); $isWeeeTaxable = $this->_weeeHelper->isTaxable(); $item->setTaxPercent($rate); if (!isset($taxGroups[$rateKey]['totals'])) { $taxGroups[$rateKey]['totals'] = array(); $taxGroups[$rateKey]['base_totals'] = array(); $taxGroups[$rateKey]['weee_tax'] = array(); $taxGroups[$rateKey]['base_weee_tax'] = array(); } $hiddenTax = null; $baseHiddenTax = null; switch ($this->_helper->getCalculationSequence($this->_store)) { case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL: case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL: $rowTax = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false); $baseRowTax = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false); if ($isWeeeEnabled && $isWeeeTaxable) { $weeeTax = $item->getWeeeTaxAppliedRowAmount() * $rate / 100; $baseWeeeTax = $item->getBaseWeeeTaxAppliedRowAmount() * $rate / 100; $rowTax += $weeeTax; $baseRowTax += $baseWeeeTax; $taxGroups[$rateKey]['weee_tax'][] = $this->_deltaRound($weeeTax, $rateKey, $inclTax); $taxGroups[$rateKey]['base_weee_tax'][] = $this->_deltaRound($baseWeeeTax, $rateKey, $inclTax); } break; case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL: case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL: if ($this->_helper->applyTaxOnOriginalPrice($this->_store)) { $discount = $item->getOriginalDiscountAmount(); $baseDiscount = $item->getBaseOriginalDiscountAmount(); } else { $discount = $item->getDiscountAmount(); $baseDiscount = $item->getBaseDiscountAmount(); } //weee discount should be removed when calculating hidden tax if ($isWeeeEnabled) { $discount = $discount - $item->getWeeeDiscount(); $baseDiscount = $baseDiscount - $item->getBaseWeeeDiscount(); } $taxSubtotal = max($subtotal - $discount, 0); $baseTaxSubtotal = max($baseSubtotal - $baseDiscount, 0); $rowTax = $this->_calculator->calcTaxAmount($taxSubtotal, $rate, $inclTax, false); $baseRowTax = $this->_calculator->calcTaxAmount($baseTaxSubtotal, $rate, $inclTax, false); if ($isWeeeEnabled && $this->_weeeHelper->isTaxable()) { $weeeTax = ($item->getWeeeTaxAppliedRowAmount() - $item->getWeeeDiscount()) * $rate / 100; $rowTax += $weeeTax; $baseWeeeTax = ($item->getBaseWeeeTaxAppliedRowAmount() - $item->getBaseWeeeDiscount()) * $rate / 100; $baseRowTax += $baseWeeeTax; $taxGroups[$rateKey]['weee_tax'][] = $weeeTax; $taxGroups[$rateKey]['base_weee_tax'][] = $baseWeeeTax; } if (!$item->getNoDiscount() && $item->getWeeeTaxApplied()) { $rowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false); $baseRowTaxBeforeDiscount = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false); if ($isWeeeTaxable) { $rowTaxBeforeDiscount += $item->getWeeeTaxAppliedRowAmount() * $rate / 100; $baseRowTaxBeforeDiscount += $item->getBaseWeeeTaxAppliedRowAmount() * $rate / 100; } } if ($inclTax && $discount > 0) { $hiddenTax = $this->_calculator->calcTaxAmount($discount, $rate, $inclTax, false); $baseHiddenTax = $this->_calculator->calcTaxAmount($baseDiscount, $rate, $inclTax, false); $this->_hiddenTaxes[] = array('rate_key' => $rateKey, 'qty' => 1, 'item' => $item, 'value' => $hiddenTax, 'base_value' => $baseHiddenTax, 'incl_tax' => $inclTax); } break; } $rowTax = $this->_deltaRound($rowTax, $rateKey, $inclTax); $baseRowTax = $this->_deltaRound($baseRowTax, $rateKey, $inclTax, 'base'); $item->setTaxAmount(max(0, $rowTax)); $item->setBaseTaxAmount(max(0, $baseRowTax)); if (isset($rowTaxBeforeDiscount) && isset($baseRowTaxBeforeDiscount)) { $taxBeforeDiscount = max(0, $this->_deltaRound($rowTaxBeforeDiscount, $rateKey, $inclTax, 'tax_before_discount')); $baseTaxBeforeDiscount = max(0, $this->_deltaRound($baseRowTaxBeforeDiscount, $rateKey, $inclTax, 'tax_before_discount_base')); $item->setDiscountTaxCompensation($taxBeforeDiscount - max(0, $rowTax)); $item->setBaseDiscountTaxCompensation($baseTaxBeforeDiscount - max(0, $baseRowTax)); } $rowTotalInclTax = $item->getRowTotalInclTax(); if (!isset($rowTotalInclTax)) { $weeeTaxBeforeDiscount = 0; $baseWeeeTaxBeforeDiscount = 0; if ($isWeeeTaxable) { $weeeTaxBeforeDiscount = $item->getWeeeTaxAppliedRowAmount() * $rate / 100; $baseWeeeTaxBeforeDiscount = $item->getBaseWeeeTaxAppliedRowAmount() * $rate / 100; } if ($this->_config->priceIncludesTax($this->_store)) { $item->setRowTotalInclTax($subtotal + $weeeTaxBeforeDiscount); $item->setBaseRowTotalInclTax($baseSubtotal + $baseWeeeTaxBeforeDiscount); } else { $taxCompensation = $item->getDiscountTaxCompensation() ? $item->getDiscountTaxCompensation() : 0; $item->setRowTotalInclTax($subtotal + $rowTax + $taxCompensation); $item->setBaseRowTotalInclTax($baseSubtotal + $baseRowTax + $item->getBaseDiscountTaxCompensation()); } } $taxGroups[$rateKey]['totals'][] = max(0, $taxSubtotal); $taxGroups[$rateKey]['base_totals'][] = max(0, $baseTaxSubtotal); return $this; }