Esempio n. 1
0
 /**
  * Recalculate row information for item based on children calculation
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @return  Mage_Tax_Model_Sales_Total_Quote_Subtotal
  */
 protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $price = 0;
     $basePrice = 0;
     $rowTotal = 0;
     $baseRowTotal = 0;
     $priceInclTax = 0;
     $basePriceInclTax = 0;
     $rowTotalInclTax = 0;
     $baseRowTotalInclTax = 0;
     foreach ($item->getChildren() as $child) {
         $price += $child->getPrice() * $child->getQty();
         $basePrice += $child->getBasePrice() * $child->getQty();
         $rowTotal += $child->getRowTotal();
         $baseRowTotal += $child->getBaseRowTotal();
         $priceInclTax += $child->getPriceInclTax() * $child->getQty();
         $basePriceInclTax += $child->getBasePriceInclTax() * $child->getQty();
         $rowTotalInclTax += $child->getRowTotalInclTax();
         $baseRowTotalInclTax += $child->getBaseRowTotalInclTax();
     }
     /**
      *
      * Customisation To make the custom price work with configurable items
      *
      **/
     if ($item->getCustomPrice()) {
         $customPrice = $item->getCustomPrice();
         $price = $customPrice;
         $basePrice = $customPrice;
         $rowTotal = $customPrice * $item->getQty();
         $baseRowTotal = $customPrice * $item->getQty();
         $priceInclTax = $customPrice;
         $basePriceInclTax = $customPrice;
         $rowTotalInclTax = $customPrice * $item->getQty();
         $baseRowTotalInclTax = $customPrice * $item->getQty();
     }
     $item->setConvertedPrice($price);
     $item->setPrice($basePrice);
     $item->setRowTotal($rowTotal);
     $item->setBaseRowTotal($baseRowTotal);
     $item->setPriceInclTax($priceInclTax);
     $item->setBasePriceInclTax($basePriceInclTax);
     $item->setRowTotalInclTax($rowTotalInclTax);
     $item->setBaseRowTotalInclTax($baseRowTotalInclTax);
     return $this;
 }
 /**
  * Recollect item price and row total using after taxes subtract.
  * Declare item price including tax attributes
  *
  * @deprecated after 1.4.1
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  *
  * @return  Mage_Tax_Model_Sales_Total_Quote_Subtotal
  */
 protected function _recollectItem($address, Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $store = $address->getQuote()->getStore();
     $request = $this->_getStoreTaxRequest($address);
     $request->setProductClassId($item->getProduct()->getTaxClassId());
     $rate = $this->_calculator->getRate($request);
     $qty = $item->getTotalQty();
     $price = $taxPrice = $item->getCalculationPriceOriginal();
     $basePrice = $baseTaxPrice = $item->getBaseCalculationPriceOriginal();
     $subtotal = $taxSubtotal = $item->getRowTotal();
     $baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal();
     if ($this->_config->discountTax($store)) {
         $item->setDiscountCalculationPrice($price);
         $item->setBaseDiscountCalculationPrice($basePrice);
     }
     /**
      * Use original price for tax calculation
      */
     if ($item->hasCustomPrice() && !$this->_helper->applyTaxOnCustomPrice($store)) {
         $taxPrice = $item->getOriginalPrice();
         $baseTaxPrice = $item->getBaseOriginalPrice();
         $taxSubtotal = $taxPrice * $qty;
         $baseTaxSubtotal = $baseTaxPrice * $qty;
     }
     if ($this->_areTaxRequestsSimilar) {
         $item->setRowTotalInclTax($subtotal);
         $item->setBaseRowTotalInclTax($baseSubtotal);
         $item->setPriceInclTax($price);
         $item->setBasePriceInclTax($basePrice);
         $item->setTaxCalcPrice($taxPrice);
         $item->setBaseTaxCalcPrice($baseTaxPrice);
         $item->setTaxCalcRowTotal($taxSubtotal);
         $item->setBaseTaxCalcRowTotal($baseTaxSubtotal);
     }
     $this->_subtotalInclTax += $subtotal;
     $this->_baseSubtotalInclTax += $baseSubtotal;
     if ($this->_config->getAlgorithm($store) == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
         $taxAmount = $this->_calculator->calcTaxAmount($taxPrice, $rate, true);
         $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxPrice, $rate, true);
         $unitPrice = $this->_calculator->round($price - $taxAmount);
         $baseUnitPrice = $this->_calculator->round($basePrice - $baseTaxAmount);
         $subtotal = $this->_calculator->round($unitPrice * $qty);
         $baseSubtotal = $this->_calculator->round($baseUnitPrice * $qty);
     } else {
         $taxAmount = $this->_calculator->calcTaxAmount($taxSubtotal, $rate, true, false);
         $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxSubtotal, $rate, true, false);
         $unitPrice = ($subtotal - $taxAmount) / $qty;
         $baseUnitPrice = ($baseSubtotal - $baseTaxAmount) / $qty;
         $subtotal = $this->_calculator->round($subtotal - $taxAmount);
         $baseSubtotal = $this->_calculator->round($baseSubtotal - $baseTaxAmount);
     }
     if ($item->hasCustomPrice()) {
         $item->setCustomPrice($unitPrice);
         $item->setBaseCustomPrice($baseUnitPrice);
     }
     $item->setPrice($baseUnitPrice);
     $item->setOriginalPrice($unitPrice);
     $item->setBasePrice($baseUnitPrice);
     $item->setRowTotal($subtotal);
     $item->setBaseRowTotal($baseSubtotal);
     return $this;
 }
Esempio n. 3
0
 /**
  * Recalculate row information for item based on children calculation
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @return  Mage_Tax_Model_Sales_Total_Quote_Subtotal
  */
 protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $price = 0;
     $basePrice = 0;
     $rowTotal = 0;
     $baseRowTotal = 0;
     $priceInclTax = 0;
     $basePriceInclTax = 0;
     $rowTotalInclTax = 0;
     $baseRowTotalInclTax = 0;
     foreach ($item->getChildren() as $child) {
         $price += $child->getPrice() * $child->getQty();
         $basePrice += $child->getBasePrice() * $child->getQty();
         $rowTotal += $child->getRowTotal();
         $baseRowTotal += $child->getBaseRowTotal();
         $priceInclTax += $child->getPriceInclTax() * $child->getQty();
         $basePriceInclTax += $child->getBasePriceInclTax() * $child->getQty();
         $rowTotalInclTax += $child->getRowTotalInclTax();
         $baseRowTotalInclTax += $child->getBaseRowTotalInclTax();
     }
     $item->setConvertedPrice($price);
     $item->setPrice($basePrice);
     $item->setRowTotal($rowTotal);
     $item->setBaseRowTotal($baseRowTotal);
     $item->setPriceInclTax($priceInclTax);
     $item->setBasePriceInclTax($basePriceInclTax);
     $item->setRowTotalInclTax($rowTotalInclTax);
     $item->setBaseRowTotalInclTax($baseRowTotalInclTax);
     return $this;
 }
 /**
  * Recalculate parent item amounts base on children data
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $calculationPrice = 0;
     $baseCalculationPrice = 0;
     $rowTaxAmount = 0;
     $baseRowTaxAmount = 0;
     $rowTotal = 0;
     $baseRowTotal = 0;
     foreach ($item->getChildren() as $child) {
         $calculationPrice += $child->getCalculationPrice();
         $baseCalculationPrice += $child->getBaseCalculationPrice();
         $rowTaxAmount += $child->getTaxAmount();
         $baseRowTaxAmount += $child->getBaseTaxAmount();
         $rowTotal += $child->getRowTotal();
         $baseRowTotal += $child->getBaseRowTotal();
     }
     $item->setOriginalPrice($calculationPrice);
     $item->setPrice($baseCalculationPrice);
     $item->setTaxAmount($rowTaxAmount);
     $item->setBaseTaxAmount($baseRowTaxAmount);
     $item->setRowTotal($rowTotal);
     $item->setBaseRowTotal($baseRowTotal);
     return $this;
 }
Esempio n. 5
0
 /**
  * Recalculate row information for item based on children calculation
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @return  Mage_Tax_Model_Sales_Total_Quote_Subtotal
  */
 protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $price = 0;
     $basePrice = 0;
     $rowTotal = 0;
     $baseRowTotal = 0;
     $priceInclTax = 0;
     $basePriceInclTax = 0;
     $rowTotalInclTax = 0;
     $baseRowTotalInclTax = 0;
     foreach ($item->getChildren() as $child) {
         $price += $child->getOriginalPrice();
         $basePrice += $child->getBaseOriginalPrice();
         $rowTotal += $child->getRowTotal();
         $baseRowTotal += $child->getBaseRowTotal();
         $priceInclTax += $child->getPriceInclTax();
         $basePriceInclTax += $child->getBasePriceInclTax();
         $rowTotalInclTax += $child->getRowTotalInclTax();
         $baseRowTotalInclTax += $child->getBaseRowTotalInclTax();
     }
     $item->setOriginalPrice($price);
     $item->setPrice($basePrice);
     $item->setRowTotal($rowTotal);
     $item->setBaseRowTotal($baseRowTotal);
     if ($this->_areTaxRequestsSimilar) {
         $item->setPriceInclTax($priceInclTax);
         $item->setBasePriceInclTax($basePriceInclTax);
         $item->setRowTotalInclTax($rowTotalInclTax);
         $item->setBaseRowTotalInclTax($baseRowTotalInclTax);
     }
     return $this;
 }