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


PHP Mage_Tax_Model_Config::getAlgorithm方法代码示例

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


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

示例1: _calculateShippingTax

 /**
  * Tax caclulation for shipping price
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @param   Varien_Object $taxRateRequest
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calculateShippingTax(Mage_Sales_Model_Quote_Address $address, $taxRateRequest)
 {
     $taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
     $rate = $this->_calculator->getRate($taxRateRequest);
     $inclTax = $address->getIsShippingInclTax();
     $shipping = $address->getShippingTaxable();
     $baseShipping = $address->getBaseShippingTaxable();
     $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:
             $tax = $this->_calculator->calcTaxAmount($shipping, $rate, $inclTax, false);
             $baseTax = $this->_calculator->calcTaxAmount($baseShipping, $rate, $inclTax, false);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $discountAmount = $address->getShippingDiscountAmount();
             $baseDiscountAmount = $address->getBaseShippingDiscountAmount();
             $tax = $this->_calculator->calcTaxAmount($shipping - $discountAmount, $rate, $inclTax, false);
             $baseTax = $this->_calculator->calcTaxAmount($baseShipping - $baseDiscountAmount, $rate, $inclTax, false);
             break;
     }
     if ($this->_config->getAlgorithm($this->_store) == Mage_Tax_Model_Calculation::CALC_TOTAL_BASE) {
         $tax = $this->_deltaRound($tax, $rate, $inclTax);
         $baseTax = $this->_deltaRound($baseTax, $rate, $inclTax, 'base');
     } else {
         $tax = $this->_calculator->round($tax);
         $baseTax = $this->_calculator->round($baseTax);
     }
     if ($inclTax && !empty($discountAmount)) {
         $hiddenTax = $shipping - $tax - $address->getShippingAmount();
         $baseHiddenTax = $baseShipping - $baseTax - $address->getBaseShippingAmount();
     }
     $this->_addAmount(max(0, $tax));
     $this->_addBaseAmount(max(0, $baseTax));
     $address->setShippingTaxAmount(max(0, $tax));
     $address->setBaseShippingTaxAmount(max(0, $baseTax));
     $address->setShippingHiddenTaxAmount(max(0, $hiddenTax));
     $address->setBaseShippingHiddenTaxAmount(max(0, $baseHiddenTax));
     $address->addTotalAmount('shipping_hidden_tax', $hiddenTax);
     $address->addBaseTotalAmount('shipping_hidden_tax', $baseHiddenTax);
     $applied = $this->_calculator->getAppliedRates($taxRateRequest);
     $this->_saveAppliedTaxes($address, $applied, $tax, $baseTax, $rate);
     return $this;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:53,代码来源:Tax.php

示例2: _processItem

 /**
  * Caclulate item price and row total with configured rounding level
  *
  * @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 _processItem($item, $taxRequest)
 {
     switch ($this->_config->getAlgorithm($this->_store)) {
         case Mage_Tax_Model_Calculation::CALC_UNIT_BASE:
             $this->_unitBaseCalculation($item, $taxRequest);
             break;
         case Mage_Tax_Model_Calculation::CALC_ROW_BASE:
             $this->_rowBaseCalculation($item, $taxRequest);
             break;
         case Mage_Tax_Model_Calculation::CALC_TOTAL_BASE:
             $this->_totalBaseCalculation($item, $taxRequest);
             break;
         default:
             break;
     }
     return $this;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:24,代码来源:Subtotal.php

示例3: collect

 /**
  * 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);
     $store = $address->getQuote()->getStore();
     $customer = $address->getQuote()->getCustomer();
     if ($customer) {
         $this->_calculator->setCustomer($customer);
     }
     if (!$address->getAppliedTaxesReset()) {
         $address->setAppliedTaxes(array());
     }
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $request = $this->_calculator->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
     $this->_areTaxRequestsSimilar = $this->_calculator->compareRequests($this->_calculator->getRateOriginRequest($address->getQuote()->getStore()), $request);
     switch ($this->_config->getAlgorithm($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;
     }
     /**
      * Subtract taxes from subtotal amount if prices include tax
      */
     if ($this->_usePriceIncludeTax($store)) {
         $subtotal = $address->getSubtotalInclTax() - $address->getTotalAmount('tax');
         $baseSubtotal = $address->getBaseSubtotalInclTax() - $address->getBaseTotalAmount('tax');
         $address->setTotalAmount('subtotal', $subtotal);
         $address->setBaseTotalAmount('subtotal', $baseSubtotal);
     }
     $this->_addAmount($address->getExtraTaxAmount());
     $this->_addBaseAmount($address->getBaseExtraTaxAmount());
     $this->_calculateShippingTax($address, $request);
     return $this;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:50,代码来源:Tax.php

示例4: _calculateWeeeAmountInclTax

 /**
  * Calculates the weeeAmountInclTax for display purpose
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @param array $appliedRates
  * @param bool $base
  */
 protected function _calculateWeeeAmountInclTax($item, $appliedRates, $base = true)
 {
     foreach ($this->_weeeHelper->getApplied($item) as $tax) {
         $weeeAmountInclTax = 0;
         $weeeAmountExclTax = 0;
         if ($base) {
             $weeeAmountInclTax = isset($tax['base_amount_incl_tax']) ? $tax['base_amount_incl_tax'] : 0;
             $weeeAmountExclTax = isset($tax['base_amount']) ? $tax['base_amount'] : 0;
             $weeeRowAmountInclTax = isset($tax['base_row_amount_incl_tax']) ? $tax['base_row_amount_incl_tax'] : 0;
             $weeeRowAmountExclTax = isset($tax['base_row_amount']) ? $tax['base_row_amount'] : 0;
         } else {
             $weeeAmountInclTax = isset($tax['amount_incl_tax']) ? $tax['amount_incl_tax'] : 0;
             $weeeAmountExclTax = isset($tax['amount']) ? $tax['amount'] : 0;
             $weeeRowAmountInclTax = isset($tax['row_amount_incl_tax']) ? $tax['row_amount_incl_tax'] : 0;
             $weeeRowAmountExclTax = isset($tax['row_amount']) ? $tax['row_amount'] : 0;
         }
         $weeeTax = array();
         $weeeRowTax = array();
         foreach ($appliedRates as $appliedRate) {
             $rate = $appliedRate['percent'];
             $weeeTax[] = $this->_getWeeeTax($rate, $item, 0, $weeeAmountInclTax, $weeeAmountExclTax);
             $weeeRowTax[] = $this->_getWeeeTax($rate, $item, 0, $weeeRowAmountInclTax, $weeeRowAmountExclTax);
         }
         //We want to update the tax calculated on Weee to the Item with out discount for display purpose
         $weeeAmountInclTax = array_sum($weeeTax) + $weeeAmountExclTax;
         $weeeRowAmountInclTax = array_sum($weeeRowTax) + $weeeRowAmountExclTax;
         $calculationMethod = $this->_config->getAlgorithm($this->_store);
         if ($calculationMethod == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
             $weeeRowAmountInclTax = $this->_calculator->round($weeeAmountInclTax * $item->getQty());
         } else {
             $weeeAmountInclTax = $this->_calculator->round($weeeRowAmountInclTax / $item->getQty());
         }
         if ($base) {
             $this->_weeeHelper->setWeeeTaxesAppliedProperty($item, $tax['title'], 'base_amount_incl_tax', $weeeAmountInclTax);
             $this->_weeeHelper->setWeeeTaxesAppliedProperty($item, $tax['title'], 'base_row_amount_incl_tax', $weeeRowAmountInclTax);
         } else {
             $this->_weeeHelper->setWeeeTaxesAppliedProperty($item, $tax['title'], 'amount_incl_tax', $weeeAmountInclTax);
             $this->_weeeHelper->setWeeeTaxesAppliedProperty($item, $tax['title'], 'row_amount_incl_tax', $weeeRowAmountInclTax);
         }
     }
     return;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:49,代码来源:Tax.php

示例5: _recollectItem

 /**
  * 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;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:73,代码来源:Subtotal.php

示例6: getCalculationAgorithm

 /**
  * Get tax calculation algorithm code
  *
  * @param   null|int $store
  * @return  string
  */
 public function getCalculationAgorithm($store = null)
 {
     return $this->_config->getAlgorithm($store);
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:10,代码来源:Data.php


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