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


PHP Config::applyTaxAfterDiscount方法代码示例

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


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

示例1: applyTaxAfterDiscount

 /**
  * Check what taxes should be applied after discount
  *
  * @param   null|int|string|Store $store
  * @return  bool
  */
 public function applyTaxAfterDiscount($store = null)
 {
     return $this->_config->applyTaxAfterDiscount($store);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:10,代码来源:Data.php

示例2: totalBaseCalculation

 /**
  * Calculate item price and row total including/excluding tax based on total price rounding level
  *
  * @param QuoteDetailsItem $item
  * @param \Magento\Framework\Object $taxRateRequest
  * @param int $storeId
  * @return TaxDetailsItem
  */
 protected function totalBaseCalculation(QuoteDetailsItem $item, \Magento\Framework\Object $taxRateRequest, $storeId)
 {
     /** @var  \Magento\Tax\Service\V1\Data\TaxDetails\AppliedTax[] $appliedTaxes */
     $appliedTaxes = [];
     $appliedTaxBuilder = $this->taxDetailsItemBuilder->getAppliedTaxBuilder();
     $appliedTaxRateBuilder = $appliedTaxBuilder->getAppliedTaxRateBuilder();
     $taxRateRequest->setProductClassId($item->getTaxClassId());
     $appliedRates = $this->calculator->getAppliedRates($taxRateRequest);
     $rate = $this->calculator->getRate($taxRateRequest);
     $quantity = $this->getTotalQuantity($item);
     $price = $priceInclTax = $this->calculator->round($item->getUnitPrice());
     $rowTotal = $rowTotalInclTax = $taxableAmount = $this->calcRowTotal($item);
     $discountAmount = $item->getDiscountAmount();
     $applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($storeId);
     $discountTaxCompensationAmount = 0;
     $isTotalBasedCalculation = $this->config->getAlgorithm($storeId) == Calculation::CALC_TOTAL_BASE;
     if ($item->getTaxIncluded()) {
         if ($taxRateRequest->getSameRateAsStore()) {
             $rowTaxExact = $this->calculator->calcTaxAmount($rowTotalInclTax, $rate, true, false);
             if ($isTotalBasedCalculation) {
                 $rowTax = $this->deltaRound($rowTaxExact, $rate, true);
             } else {
                 $rowTax = $this->calculator->round($rowTaxExact);
             }
             $rowTotal = $rowTotalInclTax - $rowTax;
             $price = $this->calculator->round($rowTotal / $quantity);
         } else {
             $storeRate = $this->calculator->getStoreRate($taxRateRequest, $storeId);
             $priceInclTax = $this->calculatePriceInclTax($price, $storeRate, $rate);
             $rowTotalInclTax = $priceInclTax * $quantity;
             $taxableAmount = $rowTotalInclTax;
             if ($isTotalBasedCalculation) {
                 $rowTax = $this->deltaRound($this->calculator->calcTaxAmount($rowTotalInclTax, $rate, true, false), $rate, true);
             } else {
                 $rowTax = $this->calculator->calcTaxAmount($rowTotalInclTax, $rate, true, true);
             }
             $rowTotal = $rowTotalInclTax - $rowTax;
             $price = $this->calculator->round($rowTotal / $quantity);
         }
         //Handle discount
         if ($discountAmount && $applyTaxAfterDiscount) {
             //TODO: handle originalDiscountAmount
             $taxableAmount = max($taxableAmount - $discountAmount, 0);
             $rowTaxAfterDiscount = $this->calculator->calcTaxAmount($taxableAmount, $rate, true, false);
             if ($isTotalBasedCalculation) {
                 //Round the row tax using a different type so that we don't pollute the rounding deltas
                 $rowTaxAfterDiscount = $this->deltaRound($rowTaxAfterDiscount, $rate, true, self::KEY_TAX_AFTER_DISCOUNT_DELTA_ROUNDING);
             } else {
                 $rowTaxAfterDiscount = $this->calculator->round($rowTaxAfterDiscount);
             }
             // Set discount tax compensation
             $discountTaxCompensationAmount = $rowTax - $rowTaxAfterDiscount;
             $rowTax = $rowTaxAfterDiscount;
         }
         //save applied taxes
         $appliedTaxes = $this->getAppliedTaxes($appliedTaxBuilder, $rowTax, $rate, $appliedRates);
     } else {
         //catalog price does not include tax
         $appliedRates = $this->calculator->getAppliedRates($taxRateRequest);
         $rowTaxes = [];
         $rowTaxesBeforeDiscount = [];
         //Apply each tax rate separately
         foreach ($appliedRates as $appliedRate) {
             $taxId = $appliedRate['id'];
             $taxRate = $appliedRate['percent'];
             if ($isTotalBasedCalculation) {
                 $rowTaxPerRate = $this->deltaRound($this->calculator->calcTaxAmount($rowTotal, $taxRate, false, false), $taxId, false);
             } else {
                 $rowTaxPerRate = $this->calculator->calcTaxAmount($rowTotal, $taxRate, false, true);
             }
             $rowTaxAfterDiscount = $rowTaxPerRate;
             //Handle discount
             if ($discountAmount && $applyTaxAfterDiscount) {
                 //TODO: handle originalDiscountAmount
                 $rowTaxAfterDiscount = $this->calculator->calcTaxAmount(max($rowTotal - $discountAmount, 0), $taxRate, false, false);
                 if ($isTotalBasedCalculation) {
                     //Round the row tax using a different type so that we don't pollute the rounding deltas
                     $rowTaxAfterDiscount = $this->deltaRound($rowTaxAfterDiscount, $taxRate, false, self::KEY_TAX_AFTER_DISCOUNT_DELTA_ROUNDING);
                 } else {
                     $rowTaxAfterDiscount = $this->calculator->round($rowTaxAfterDiscount);
                 }
             }
             $appliedTaxes[$appliedRate['id']] = $this->getAppliedTax($appliedTaxBuilder, $rowTaxAfterDiscount, $appliedRate);
             $rowTaxes[] = $rowTaxAfterDiscount;
             $rowTaxesBeforeDiscount[] = $rowTaxPerRate;
         }
         $rowTax = array_sum($rowTaxes);
         $rowTaxBeforeDiscount = array_sum($rowTaxesBeforeDiscount);
         $rowTotalInclTax = $rowTotal + $rowTaxBeforeDiscount;
         $priceInclTax = $this->calculator->round($rowTotalInclTax / $quantity);
     }
     $this->taxDetailsItemBuilder->setCode($item->getCode());
//.........这里部分代码省略.........
开发者ID:Atlis,项目名称:docker-magento2,代码行数:101,代码来源:TaxCalculationService.php

示例3: checkDiscountSettings

 /**
  * Check if tax discount settings are compatible
  *
  * Matrix for invalid discount settings is as follows:
  *      Before Discount / Excluding Tax
  *      Before Discount / Including Tax
  *
  * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
  * @return bool
  */
 public function checkDiscountSettings($store = null)
 {
     return $this->taxConfig->applyTaxAfterDiscount($store);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Notifications.php


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