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


PHP Mage_Sales_Model_Quote_Address::setAppliedTaxes方法代码示例

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


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

示例1: _saveAppliedTaxes

 protected function _saveAppliedTaxes(Mage_Sales_Model_Quote_Address $address, $applied, $amount, $baseAmount, $rate)
 {
     $previouslyAppliedTaxes = $address->getAppliedTaxes();
     $process = count($previouslyAppliedTaxes);
     foreach ($applied as $row) {
         if (!isset($previouslyAppliedTaxes[$row['id']])) {
             $row['process'] = $process;
             $row['amount'] = 0;
             $row['base_amount'] = 0;
             $previouslyAppliedTaxes[$row['id']] = $row;
         }
         if (!is_null($row['percent'])) {
             $row['percent'] = $row['percent'] ? $row['percent'] : 1;
             $rate = $rate ? $rate : 1;
             $appliedAmount = $amount;
             $baseAppliedAmount = $baseAmount;
         } else {
             $appliedAmount = 0;
             $baseAppliedAmount = 0;
             foreach ($row['rates'] as $rate) {
                 $appliedAmount += $rate['amount'];
                 $baseAppliedAmount += $rate['base_amount'];
             }
         }
         if ($appliedAmount || $previouslyAppliedTaxes[$row['id']]['amount']) {
             $previouslyAppliedTaxes[$row['id']]['amount'] = $appliedAmount;
             $previouslyAppliedTaxes[$row['id']]['base_amount'] = $baseAppliedAmount;
         } else {
             unset($previouslyAppliedTaxes[$row['id']]);
         }
     }
     $address->setAppliedTaxes($previouslyAppliedTaxes);
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:33,代码来源:Discount.php

示例2: _saveAppliedTax

 /**
  * Save applied tax
  *
  * @param Mage_Sales_Model_Quote_Address $address
  */
 protected function _saveAppliedTax($address, $summary)
 {
     $fullInfo = array();
     $store = $address->getQuote()->getStore();
     foreach ($summary as $key => $row) {
         $id = $row['name'];
         $fullInfo[$id] = array('rates' => array(array('code' => $row['name'], 'title' => $row['name'], 'percent' => $row['rate'], 'position' => $key, 'priority' => $key, 'rule_id' => 0)), 'percent' => $row['rate'], 'id' => $id, 'process' => 0, 'amount' => $store->convertPrice($row['amt']), 'base_amount' => $row['amt']);
     }
     $address->setAppliedTaxes($fullInfo);
 }
开发者ID:onepica,项目名称:avatax,代码行数:15,代码来源:Tax.php

示例3: collect

 /**
  * Does nothing, calculates no taxes.
  *
  * @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();
     $address->setTaxAmount(0);
     $address->setBaseTaxAmount(0);
     //$address->setShippingTaxAmount(0);
     //$address->setBaseShippingTaxAmount(0);
     $address->setAppliedTaxes(array());
     return $this;
 }
开发者ID:Eximagen,项目名称:pfizer,代码行数:17,代码来源:Tax.php

示例4: collect

 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setPaymentCharge(0);
     $address->setBasePaymentCharge(0);
     $storeId = Mage::app()->getStore()->getId();
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $paymentMethod = $address->getQuote()->getPayment()->getMethod();
     $quote = $address->getQuote();
     if ($paymentMethod && substr($paymentMethod, 0, 11) == 'pay_payment') {
         $baseAmount = Mage::helper('pay_payment')->getPaymentCharge($paymentMethod, $address->getQuote());
         $amount = Mage::helper('directory')->currencyConvert($baseAmount, Mage::app()->getWebsite()->getConfig('currency/options/default'), Mage::app()->getStore()->getCurrentCurrencyCode());
         $address->setPaymentCharge($amount);
         $address->setBasePaymentCharge($baseAmount);
         $taxClass = Mage::helper('pay_payment')->getPaymentChargeTaxClass($paymentMethod);
         $taxCalculationModel = Mage::getSingleton('tax/calculation');
         $request = $taxCalculationModel->getRateRequest($quote->getShippingAddress(), $quote->getBillingAddress(), null, $storeId);
         $request->setStore(Mage::app()->getStore());
         $rate = $taxCalculationModel->getRate($request->setProductClassId($taxClass));
         //$rate = 21;
         if ($rate > 0) {
             //                $includesTax = Mage::getStoreConfig('tax/calculation/price_includes_tax');
             $baseChargeTax = round($address->getBasePaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
             $chargeTax = round($address->getPaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
         } else {
             $baseChargeTax = 0;
             $chargeTax = 0;
         }
         $rates = array();
         $applied = false;
         foreach ($address->getAppliedTaxes() as $arrRate) {
             // maximaal 1 keer de btw voor de extra kosten toevoegen
             if ($arrRate['percent'] == $rate && !$applied) {
                 $applied = true;
                 $arrRate['amount'] = $arrRate['amount'] + $chargeTax;
                 $arrRate['base_amount'] = $arrRate['base_amount'] + $baseChargeTax;
             }
             $rates[] = $arrRate;
         }
         $address->setAppliedTaxes($rates);
         $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseChargeTax);
         $address->setTaxAmount($address->getTaxAmount() + $chargeTax);
         $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
     }
     return $this;
 }
开发者ID:paynl,项目名称:magento-plugin,代码行数:49,代码来源:Paymentcharge.php

示例5: collect

 /**
  * @version 1.3.2.2
  * @param Mage_Sales_Model_Quote_Address $address
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $store = $address->getQuote()->getStore();
     $address->setTaxAmount(0);
     $address->setBaseTaxAmount(0);
     //$address->setShippingTaxAmount(0);
     //$address->setBaseShippingTaxAmount(0);
     $address->setAppliedTaxes(array());
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
     $taxCalculationModel = Mage::getSingleton('tax/calculation');
     /* @var $taxCalculationModel Mage_Tax_Model_Calculation */
     $request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
     foreach ($items as $item) {
         /**
          * Child item's tax we calculate for parent
          */
         if ($item->getParentItemId()) {
             continue;
         }
         /**
          * We calculate parent tax amount as sum of children's tax amounts
          */
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $this->_setRequestVendor($store, $child, $request);
                 //UDROPSHIP
                 $discountBefore = $item->getDiscountAmount();
                 $baseDiscountBefore = $item->getBaseDiscountAmount();
                 $rate = $taxCalculationModel->getRate($request->setProductClassId($child->getProduct()->getTaxClassId()));
                 $child->setTaxPercent($rate);
                 $child->calcTaxAmount();
                 if ($discountBefore != $item->getDiscountAmount()) {
                     $address->setDiscountAmount($address->getDiscountAmount() + ($item->getDiscountAmount() - $discountBefore));
                     $address->setBaseDiscountAmount($address->getBaseDiscountAmount() + ($item->getBaseDiscountAmount() - $baseDiscountBefore));
                     $address->setGrandTotal($address->getGrandTotal() - ($item->getDiscountAmount() - $discountBefore));
                     $address->setBaseGrandTotal($address->getBaseGrandTotal() - ($item->getBaseDiscountAmount() - $baseDiscountBefore));
                 }
                 $this->_saveAppliedTaxes($address, $taxCalculationModel->getAppliedRates($request), $child->getTaxAmount(), $child->getBaseTaxAmount(), $rate);
             }
             $address->setTaxAmount($address->getTaxAmount() + $item->getTaxAmount());
             $address->setBaseTaxAmount($address->getBaseTaxAmount() + $item->getBaseTaxAmount());
         } else {
             $this->_setRequestVendor($store, $item, $request);
             //UDROPSHIP
             $discountBefore = $item->getDiscountAmount();
             $baseDiscountBefore = $item->getBaseDiscountAmount();
             $rate = $taxCalculationModel->getRate($request->setProductClassId($item->getProduct()->getTaxClassId()));
             $item->setTaxPercent($rate);
             $item->calcTaxAmount();
             if ($discountBefore != $item->getDiscountAmount()) {
                 $address->setDiscountAmount($address->getDiscountAmount() + ($item->getDiscountAmount() - $discountBefore));
                 $address->setBaseDiscountAmount($address->getBaseDiscountAmount() + ($item->getBaseDiscountAmount() - $baseDiscountBefore));
                 $address->setGrandTotal($address->getGrandTotal() - ($item->getDiscountAmount() - $discountBefore));
                 $address->setBaseGrandTotal($address->getBaseGrandTotal() - ($item->getBaseDiscountAmount() - $baseDiscountBefore));
             }
             $address->setTaxAmount($address->getTaxAmount() + $item->getTaxAmount());
             $address->setBaseTaxAmount($address->getBaseTaxAmount() + $item->getBaseTaxAmount());
             $applied = $taxCalculationModel->getAppliedRates($request);
             $this->_saveAppliedTaxes($address, $applied, $item->getTaxAmount(), $item->getBaseTaxAmount(), $rate);
         }
     }
     $shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $store);
     $shippingTax = 0;
     $shippingBaseTax = 0;
     if ($shippingTaxClass) {
         if ($rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass))) {
             if (!Mage::helper('tax')->shippingPriceIncludesTax()) {
                 $shippingTax = $address->getShippingAmount() * $rate / 100;
                 $shippingBaseTax = $address->getBaseShippingAmount() * $rate / 100;
             } else {
                 $shippingTax = $address->getShippingTaxAmount();
                 $shippingBaseTax = $address->getBaseShippingTaxAmount();
             }
             $shippingTax = $store->roundPrice($shippingTax);
             $shippingBaseTax = $store->roundPrice($shippingBaseTax);
             $address->setTaxAmount($address->getTaxAmount() + $shippingTax);
             $address->setBaseTaxAmount($address->getBaseTaxAmount() + $shippingBaseTax);
             $this->_saveAppliedTaxes($address, $taxCalculationModel->getAppliedRates($request), $shippingTax, $shippingBaseTax, $rate);
         }
     }
     if (!Mage::helper('tax')->shippingPriceIncludesTax()) {
         $address->setShippingTaxAmount($shippingTax);
         $address->setBaseShippingTaxAmount($shippingBaseTax);
     }
     $address->setGrandTotal($address->getGrandTotal() + $address->getTaxAmount());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseTaxAmount());
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:96,代码来源:Total.php


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