当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount方法的具体用法?PHP Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount怎么用?PHP Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Quote_Item_Abstract的用法示例。


在下文中一共展示了Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _calcUnitTaxAmount

 /**
  * Calculate unit tax anount based on unit price
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate)
 {
     $extra = $item->getExtraTaxableAmount();
     $baseExtra = $item->getBaseExtraTaxableAmount();
     $qty = $item->getTotalQty();
     $inclTax = $item->getIsPriceInclTax();
     $price = $item->getTaxableAmount();
     $basePrice = $item->getBaseTaxableAmount();
     $item->setTaxPercent($rate);
     $hiddenTax = null;
     $baseHiddenTax = null;
     switch ($this->_config->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:
             $unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
             break;
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $discountAmount = $item->getDiscountAmount() / $qty;
             $baseDiscountAmount = $item->getBaseDiscountAmount() / $qty;
             $unitTax = $this->_calculator->calcTaxAmount(max($price - $discountAmount, 0), $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount(max($basePrice - $baseDiscountAmount, 0), $rate, $inclTax);
             if ($inclTax && $discountAmount > 0) {
                 $hiddenTax = $price - $unitTax - $item->getConvertedPrice();
                 $baseHiddenTax = $basePrice - $unitTax - $item->getBasePrice();
             } elseif ($discountAmount > $price) {
                 // case with 100% discount on price incl. tax
                 $hiddenTax = $discountAmount - $price;
                 $baseHiddenTax = $baseDiscountAmount - $basePrice;
             }
             break;
     }
     $item->setTaxAmount($this->_store->roundPrice(max(0, $qty * $unitTax)));
     $item->setBaseTaxAmount($this->_store->roundPrice(max(0, $qty * $baseUnitTax)));
     $item->setHiddenTaxAmount(max(0, $qty * $hiddenTax));
     $item->setBaseHiddenTaxAmount(max(0, $qty * $baseHiddenTax));
     return $this;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:47,代码来源:Tax.php

示例2: _calcUnitTaxAmount

 /**
  * Calculate unit tax anount based on unit price
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate)
 {
     $qty = $item->getTotalQty();
     $inclTax = $item->getIsPriceInclTax();
     $price = $item->getTaxableAmount() + $item->getExtraTaxableAmount();
     $basePrice = $item->getBaseTaxableAmount() + $item->getBaseExtraTaxableAmount();
     $rateKey = (string) $rate;
     $item->setTaxPercent($rate);
     $hiddenTax = null;
     $baseHiddenTax = null;
     switch ($this->_config->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:
             $unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $discountAmount = $item->getDiscountAmount() / $qty;
             $baseDiscountAmount = $item->getBaseDiscountAmount() / $qty;
             $unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
             $discountRate = $unitTax / $price * 100;
             $unitTaxDiscount = $this->_calculator->calcTaxAmount($discountAmount, $discountRate, $inclTax, false);
             $unitTax = max($unitTax - $unitTaxDiscount, 0);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
             $baseDiscountRate = $baseUnitTax / $basePrice * 100;
             $baseUnitTaxDiscount = $this->_calculator->calcTaxAmount($baseDiscountAmount, $baseDiscountRate, $inclTax, false);
             $baseUnitTax = max($baseUnitTax - $baseUnitTaxDiscount, 0);
             if ($inclTax && $discountAmount > 0) {
                 $hiddenTax = $this->_calculator->calcTaxAmount($discountAmount, $rate, $inclTax, false);
                 $baseHiddenTax = $this->_calculator->calcTaxAmount($baseDiscountAmount, $rate, $inclTax, false);
                 $this->_hiddenTaxes[] = array('rate_key' => $rateKey, 'qty' => $qty, 'item' => $item, 'value' => $hiddenTax, 'base_value' => $baseHiddenTax, 'incl_tax' => $inclTax);
             } elseif ($discountAmount > $price) {
                 // case with 100% discount on price incl. tax
                 $hiddenTax = $discountAmount - $price;
                 $baseHiddenTax = $baseDiscountAmount - $basePrice;
                 $this->_hiddenTaxes[] = array('rate_key' => $rateKey, 'qty' => $qty, 'item' => $item, 'value' => $hiddenTax, 'base_value' => $baseHiddenTax, 'incl_tax' => $inclTax);
             }
             break;
     }
     $item->setTaxAmount($this->_store->roundPrice(max(0, $qty * $unitTax)));
     $item->setBaseTaxAmount($this->_store->roundPrice(max(0, $qty * $baseUnitTax)));
     return $this;
 }
开发者ID:redesignMob,项目名称:extensii,代码行数:51,代码来源:Tax.php

示例3: _calcUnitTaxAmount

 /**
  * Calculate unit tax anount based on unit price
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calcUnitTaxAmount(Mage_Sales_Model_Quote_Item_Abstract $item, $rate)
 {
     $store = $item->getStore();
     $inclTax = $this->_usePriceIncludeTax($store);
     $extra = $item->getExtraTaxableAmount();
     $baseExtra = $item->getBaseExtraTaxableAmount();
     if ($inclTax) {
         $price = $store->roundPrice($item->getTaxCalcPrice()) + $extra;
         $basePrice = $store->roundPrice($item->getBaseTaxCalcPrice()) + $baseExtra;
     } else {
         if ($item->hasCustomPrice() && $this->_helper->applyTaxOnCustomPrice($store)) {
             $price = $store->roundPrice($item->getCalculationPrice()) + $extra;
             $basePrice = $store->roundPrice($item->getBaseCalculationPrice()) + $baseExtra;
         } else {
             $price = $store->roundPrice($item->getOriginalPrice()) + $item->getExtraTaxableAmount();
             $basePrice = $store->roundPrice($item->getBaseOriginalPrice()) + $item->getBaseExtraTaxableAmount();
         }
     }
     $discountAmount = $item->getDiscountAmount();
     $baseDiscountAmount = $item->getBaseDiscountAmount();
     $qty = $item->getTotalQty();
     $item->setTaxPercent($rate);
     $rate = $rate / 100;
     $calculationSequence = $this->_config->getCalculationSequence($store);
     switch ($calculationSequence) {
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL:
             $unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL:
             $unitTax = $this->_calculator->calcTaxAmount($price, $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax);
             if ($inclTax) {
                 $item->setDiscountCalculationPrice($price);
                 $item->setBaseDiscountCalculationPrice($basePrice);
             } else {
                 $item->setDiscountCalculationPrice($price + $unitTax);
                 $item->setBaseDiscountCalculationPrice($basePrice + $baseUnitTax);
             }
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $unitTax = $this->_calculator->calcTaxAmount($price - $discountAmount / $qty, $rate, $inclTax);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice - $baseDiscountAmount / $qty, $rate, $inclTax);
             break;
     }
     $totalTax = $store->roundPrice($qty * $unitTax);
     $totalBaseTax = $store->roundPrice($qty * $baseUnitTax);
     /**
      * Renew item amounts in case if we are working with price include tax
      */
     if ($inclTax) {
         if ($item->hasCustomPrice()) {
             $item->setCustomPrice($item->getPriceInclTax() - $unitTax);
             $item->setBaseCustomPrice($item->getBasePriceInclTax() - $baseUnitTax);
         } else {
             $item->setOriginalPrice($item->getPriceInclTax() - $unitTax);
             $item->setPrice($item->getBasePriceInclTax() - $baseUnitTax);
             $item->setBasePrice($item->getBasePriceInclTax() - $baseUnitTax);
         }
         $item->setRowTotal($item->getRowTotalInclTax() - $totalTax);
         $item->setBaseRowTotal($item->getBaseRowTotalInclTax() - $totalBaseTax);
     }
     $item->setTaxAmount($totalTax);
     $item->setBaseTaxAmount($totalBaseTax);
     return $this;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:74,代码来源:Tax.php


注:本文中的Mage_Sales_Model_Quote_Item_Abstract::getExtraTaxableAmount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。