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


PHP Mage_Core_Model_Store::roundPrice方法代码示例

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


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

示例1: deltaRound

 /**
  * Round price considering delta
  *
  * @param float $price
  * @param bool $negative Indicates if we perform addition (true) or subtraction (false) of rounded value
  * @return float
  */
 public function deltaRound($price, $negative = false)
 {
     $roundedPrice = $price;
     if ($roundedPrice) {
         if ($negative) {
             $this->_delta = -$this->_delta;
         }
         $price += $this->_delta;
         $roundedPrice = $this->_store->roundPrice($price);
         $this->_delta = $price - $roundedPrice;
         if ($negative) {
             $this->_delta = -$this->_delta;
         }
     }
     return $roundedPrice;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:23,代码来源:Calculator.php

示例2: _roundWithDeltasForBase

 /**
  * Round the amount with deltas collected
  *
  * @param string $key
  * @param float $amount
  * @param Mage_Core_Model_Store $store
  * @return float
  */
 protected function _roundWithDeltasForBase($key, $amount, $store)
 {
     $delta = isset($this->_baseRoundingDeltas[$key]) ? $this->_roundingDeltas[$key] : 0;
     $this->_baseRoundingDeltas[$key] = $store->roundPrice($amount + $delta) - $amount;
     return $store->roundPrice($amount + $delta);
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:14,代码来源:Validator.php

示例3: _calculatePriceInclTax

 /**
  * Given a store price that includes tax at the store rate, this function will back out the store's tax, and add in
  * the customer's tax.  Returns this new price which is the customer's price including tax.
  *
  * @param float $storePriceInclTax
  * @param float $storePercent
  * @param float $customerPercent
  * @param Mage_Core_Model_Store $store
  * @return float
  */
 protected function _calculatePriceInclTax($storePriceInclTax, $storePercent, $customerPercent, $store)
 {
     $priceExclTax = $this->_calculatePrice($storePriceInclTax, $storePercent, false, false);
     $customerTax = $this->getCalculator()->calcTaxAmount($priceExclTax, $customerPercent, false, false);
     $customerPriceInclTax = $store->roundPrice($priceExclTax + $customerTax);
     return $customerPriceInclTax;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:17,代码来源:Data.php

示例4: _calcUnitTaxAmount

 /**
  * Calculate unit tax anount based on unit price
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @param   array $taxGroups
  * @param   string $taxId
  * @param   boolean $recalculateRowTotalInclTax
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calcUnitTaxAmount($item, $rate, &$taxGroups = null, $taxId = null, $recalculateRowTotalInclTax = false)
 {
     $qty = $item->getTotalQty();
     $inclTax = $item->getIsPriceInclTax();
     $price = $item->getTaxableAmount();
     $basePrice = $item->getBaseTaxableAmount();
     $rateKey = $taxId == null ? (string) $rate : $taxId;
     $isWeeeEnabled = $this->_weeeHelper->isEnabled();
     $isWeeeTaxable = $this->_weeeHelper->isTaxable();
     $hiddenTax = null;
     $baseHiddenTax = null;
     $weeeTax = null;
     $baseWeeeTax = null;
     $unitTaxBeforeDiscount = null;
     $weeeTaxBeforeDiscount = null;
     $baseUnitTaxBeforeDiscount = null;
     $baseWeeeTaxBeforeDiscount = 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:
             $unitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($price, $rate, $inclTax, false);
             $baseUnitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax, false);
             if ($isWeeeEnabled && $isWeeeTaxable) {
                 $weeeTaxBeforeDiscount = $this->_calculateWeeeTax(0, $item, $rate, false);
                 $unitTaxBeforeDiscount += $weeeTaxBeforeDiscount;
                 $baseWeeeTaxBeforeDiscount = $this->_calculateWeeeTax(0, $item, $rate);
                 $baseUnitTaxBeforeDiscount += $baseWeeeTaxBeforeDiscount;
             }
             $unitTaxBeforeDiscount = $unitTax = $this->_calculator->round($unitTaxBeforeDiscount);
             $baseUnitTaxBeforeDiscount = $baseUnitTax = $this->_calculator->round($baseUnitTaxBeforeDiscount);
             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;
             //We want to remove weee
             if ($isWeeeEnabled && $this->_weeeHelper->includeInSubtotal()) {
                 $discountAmount = $discountAmount - $item->getWeeeDiscount() / $qty;
                 $baseDiscountAmount = $baseDiscountAmount - $item->getBaseWeeeDiscount() / $qty;
             }
             $unitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($price, $rate, $inclTax, false);
             $unitTaxDiscount = $this->_calculator->calcTaxAmount($discountAmount, $rate, $inclTax, false);
             $unitTax = $this->_calculator->round(max($unitTaxBeforeDiscount - $unitTaxDiscount, 0));
             $baseUnitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax, false);
             $baseUnitTaxDiscount = $this->_calculator->calcTaxAmount($baseDiscountAmount, $rate, $inclTax, false);
             $baseUnitTax = $this->_calculator->round(max($baseUnitTaxBeforeDiscount - $baseUnitTaxDiscount, 0));
             if ($isWeeeEnabled && $this->_weeeHelper->isTaxable()) {
                 $weeeTax = $this->_calculateRowWeeeTax($item->getWeeeDiscount(), $item, $rate, false);
                 $weeeTax = $weeeTax / $qty;
                 $unitTax += $weeeTax;
                 $baseWeeeTax = $this->_calculateRowWeeeTax($item->getBaseWeeeDiscount(), $item, $rate);
                 $baseWeeeTax = $baseWeeeTax / $qty;
                 $baseUnitTax += $baseWeeeTax;
             }
             $unitTax = $this->_calculator->round($unitTax);
             $baseUnitTax = $this->_calculator->round($baseUnitTax);
             //Calculate the weee taxes before discount
             $weeeTaxBeforeDiscount = 0;
             $baseWeeeTaxBeforeDiscount = 0;
             if ($isWeeeTaxable) {
                 $weeeTaxBeforeDiscount = $this->_calculateWeeeTax(0, $item, $rate, false);
                 $unitTaxBeforeDiscount += $weeeTaxBeforeDiscount;
                 $baseWeeeTaxBeforeDiscount = $this->_calculateWeeeTax(0, $item, $rate);
                 $baseUnitTaxBeforeDiscount += $baseWeeeTaxBeforeDiscount;
             }
             $unitTaxBeforeDiscount = max(0, $this->_calculator->round($unitTaxBeforeDiscount));
             $baseUnitTaxBeforeDiscount = max(0, $this->_calculator->round($baseUnitTaxBeforeDiscount));
             if ($inclTax && $discountAmount > 0) {
                 $hiddenTax = $unitTaxBeforeDiscount - $unitTax;
                 $baseHiddenTax = $baseUnitTaxBeforeDiscount - $baseUnitTax;
                 $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);
             }
             // calculate discount compensation
             // We need the discount compensation when dont calculate the hidden taxes
             // (when product does not include taxes)
             if (!$item->getNoDiscount() && $item->getWeeeTaxApplied()) {
                 $item->setDiscountTaxCompensation($item->getDiscountTaxCompensation() + $unitTaxBeforeDiscount * $qty - max(0, $unitTax) * $qty);
             }
             break;
     }
     $rowTax = $this->_store->roundPrice(max(0, $qty * $unitTax));
     $baseRowTax = $this->_store->roundPrice(max(0, $qty * $baseUnitTax));
     $item->setTaxAmount($item->getTaxAmount() + $rowTax);
     $item->setBaseTaxAmount($item->getBaseTaxAmount() + $baseRowTax);
     if (is_array($taxGroups)) {
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:101,代码来源:Tax.php

示例5: _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();
     $basePrice = $item->getBaseTaxableAmount();
     $rateKey = (string) $rate;
     $item->setTaxPercent($rate);
     $isWeeeEnabled = $this->_weeeHelper->isEnabled();
     $isWeeeTaxable = $this->_weeeHelper->isTaxable();
     $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, false);
             $baseUnitTax = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax, false);
             if ($isWeeeEnabled && $isWeeeTaxable) {
                 $unitTax += $item->getWeeeTaxAppliedAmount() * $rate / 100;
                 $baseUnitTax += $item->getBaseWeeeTaxAppliedAmount() * $rate / 100;
             }
             $unitTax = $this->_calculator->round($unitTax);
             $baseUnitTax = $this->_calculator->round($baseUnitTax);
             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;
             if ($isWeeeEnabled) {
                 $discountAmount = $discountAmount - $item->getWeeeDiscount() / $qty;
                 $baseDiscountAmount = $baseDiscountAmount - $item->getBaseWeeeDiscount() / $qty;
             }
             $unitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($price, $rate, $inclTax, false);
             $unitTaxDiscount = $this->_calculator->calcTaxAmount($discountAmount, $rate, $inclTax, false);
             $unitTax = $this->_calculator->round(max($unitTaxBeforeDiscount - $unitTaxDiscount, 0));
             $baseUnitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($basePrice, $rate, $inclTax, false);
             $baseUnitTaxDiscount = $this->_calculator->calcTaxAmount($baseDiscountAmount, $rate, $inclTax, false);
             $baseUnitTax = $this->_calculator->round(max($baseUnitTaxBeforeDiscount - $baseUnitTaxDiscount, 0));
             if ($isWeeeEnabled && $this->_weeeHelper->isTaxable()) {
                 $weeeTax = ($item->getWeeeTaxAppliedRowAmount() - $item->getWeeeDiscount()) * $rate / 100;
                 $weeeTax = $weeeTax / $qty;
                 $unitTax += $weeeTax;
                 $baseWeeeTax = ($item->getBaseWeeeTaxAppliedRowAmount() - $item->getBaseWeeeDiscount()) * $rate / 100;
                 $baseWeeeTax = $baseWeeeTax / $qty;
                 $baseUnitTax += $baseWeeeTax;
             }
             $unitTax = $this->_calculator->round($unitTax);
             $baseUnitTax = $this->_calculator->round($baseUnitTax);
             if ($inclTax && $discountAmount > 0) {
                 $hiddenTax = $this->_calculator->round($unitTaxBeforeDiscount) - $unitTax;
                 $baseHiddenTax = $this->_calculator->round($baseUnitTaxBeforeDiscount) - $baseUnitTax;
                 $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);
             }
             // calculate discount compensation
             if (!$item->getNoDiscount() && $item->getWeeeTaxApplied()) {
                 $unitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($price, $rate, $inclTax, false);
                 $baseUnitTaxBeforeDiscount = $this->_calculator->calcTaxAmount($price, $rate, $inclTax, false);
                 if ($isWeeeTaxable) {
                     $unitTaxBeforeDiscount += $item->getWeeeTaxAppliedAmount() * $rate / 100;
                     $baseUnitTaxBeforeDiscount += $item->getBaseWeeeTaxAppliedAmount() * $rate / 100;
                 }
                 $unitTaxBeforeDiscount = max(0, $this->_calculator->round($unitTaxBeforeDiscount));
                 $baseUnitTaxBeforeDiscount = max(0, $this->_calculator->round($baseUnitTaxBeforeDiscount));
                 $item->setDiscountTaxCompensation($unitTaxBeforeDiscount * $qty - max(0, $unitTax) * $qty);
                 $item->setBaseDiscountTaxCompensation($baseUnitTaxBeforeDiscount * $qty - max(0, $baseUnitTax) * $qty);
             }
             break;
     }
     $item->setTaxAmount($this->_store->roundPrice(max(0, $qty * $unitTax)));
     $item->setBaseTaxAmount($this->_store->roundPrice(max(0, $qty * $baseUnitTax)));
     $rowTotalInclTax = $item->getRowTotalInclTax();
     if (!isset($rowTotalInclTax)) {
         if ($this->_config->priceIncludesTax($this->_store)) {
             $weeeTaxBeforeDiscount = 0;
             $baseWeeeTaxBeforeDiscount = 0;
             if ($isWeeeTaxable) {
                 $weeeTaxBeforeDiscount = $item->getWeeeTaxAppliedRowAmount() * $rate / 100;
                 $baseWeeeTaxBeforeDiscount = $item->getBaseWeeeTaxAppliedRowAmount() * $rate / 100;
             }
             $item->setRowTotalInclTax($price * $qty + $weeeTaxBeforeDiscount);
             $item->setBaseRowTotalInclTax($basePrice * $qty + $baseWeeeTaxBeforeDiscount);
         } else {
             $taxCompensation = $item->getDiscountTaxCompensation() ? $item->getDiscountTaxCompensation() : 0;
             $item->setRowTotalInclTax($price * $qty + $unitTax * $qty + $taxCompensation);
             $item->setBaseRowTotalInclTax($basePrice * $qty + $baseUnitTax * $qty + $item->getBaseDiscountTaxCompensation());
         }
     }
     return $this;
//.........这里部分代码省略.........
开发者ID:blazeriaz,项目名称:youguess,代码行数:101,代码来源:Tax.php


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