/** * Calculate the Weee tax based on the discount and rate * * @param float $rate * @param Mage_Sales_Model_Quote_Item_Abstract $item * @param float $discountAmount * @param float $weeeAmountIncludingTax * @param float $weeeAmountExclTax * @return mixed */ private function _getWeeeTax($rate, $item, $discountAmount, $weeeAmountIncludingTax, $weeeAmountExclTax) { $isWeeeTaxAlreadyIncluded = $this->_weeeHelper->isTaxIncluded($this->_store); if ($rate == $this->_calculator->getStoreRateForItem($item) && $isWeeeTaxAlreadyIncluded) { if (!$discountAmount || $discountAmount <= 0) { //We want to skip the re calculation and return the difference return max($weeeAmountIncludingTax - $weeeAmountExclTax, 0); } else { return $this->_calculator->calcTaxAmount($weeeAmountIncludingTax - $discountAmount, $rate, true, true); } } $discountAmount = !$discountAmount ? 0 : $discountAmount; ///Regular case where weee does not have the tax and we want to calculate the tax return $this->_calculator->calcTaxAmount($weeeAmountExclTax - $discountAmount, $rate, false, true); }