本文整理汇总了PHP中Mage_Tax_Model_Config::discountTax方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Tax_Model_Config::discountTax方法的具体用法?PHP Mage_Tax_Model_Config::discountTax怎么用?PHP Mage_Tax_Model_Config::discountTax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Tax_Model_Config
的用法示例。
在下文中一共展示了Mage_Tax_Model_Config::discountTax方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discountTax
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
* Always apply discount first since AvaTax does not support line-level item discount amounts
*
* @param null|int $store
* @return bool
*/
public function discountTax($store = null)
{
if ($this->_getDataHelper()->isAvataxEnabled($store)) {
return false;
}
return parent::discountTax($store);
}
示例2: discountTax
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
* Always apply discount first since AvaTax does not support line-level item discount amounts
*
* @param null|int $store
* @return bool
*/
public function discountTax($store = null)
{
if (Mage::helper('avatax')->isAvataxEnabled($store)) {
return false;
}
return parent::discountTax($store);
}
示例3: collect
/**
* Collect totals information about shipping
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Shipping
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
parent::collect($address);
$calc = $this->_calculator;
$store = $address->getQuote()->getStore();
$storeTaxRequest = $calc->getRateOriginRequest($store);
$addressTaxRequest = $calc->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
$storeTaxRequest->setProductClassId($this->_config->getShippingTaxClass($store));
$addressTaxRequest->setProductClassId($this->_config->getShippingTaxClass($store));
$this->_areTaxRequestsSimilar = $calc->compareRequests($addressTaxRequest, $storeTaxRequest);
$shipping = $taxShipping = $address->getShippingAmount();
$baseShipping = $baseTaxShipping = $address->getBaseShippingAmount();
$rate = $calc->getRate($addressTaxRequest);
if ($this->_config->shippingPriceIncludesTax($store)) {
if ($this->_areTaxRequestsSimilar) {
$tax = $this->_round($calc->calcTaxAmount($shipping, $rate, true, false), $rate, true);
$baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, true, false), $rate, true, 'base');
$taxShipping = $shipping;
$baseTaxShipping = $baseShipping;
$shipping = $shipping - $tax;
$baseShipping = $baseShipping - $baseTax;
$taxable = $taxShipping;
$baseTaxable = $baseTaxShipping;
$isPriceInclTax = true;
} else {
$storeRate = $calc->getStoreRate($addressTaxRequest, $store);
$storeTax = $calc->calcTaxAmount($shipping, $storeRate, true, false);
$baseStoreTax = $calc->calcTaxAmount($baseShipping, $storeRate, true, false);
$shipping = $calc->round($shipping - $storeTax);
$baseShipping = $calc->round($baseShipping - $baseStoreTax);
$tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), false, $rate);
$baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
$taxShipping = $shipping + $tax;
$baseTaxShipping = $baseShipping + $baseTax;
$taxable = $shipping;
$baseTaxable = $baseShipping;
$isPriceInclTax = false;
}
} else {
$tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), false, $rate);
$baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
$taxShipping = $shipping + $tax;
$baseTaxShipping = $baseShipping + $baseTax;
$taxable = $shipping;
$baseTaxable = $baseShipping;
$isPriceInclTax = false;
}
$address->setTotalAmount('shipping', $shipping);
$address->setBaseTotalAmount('shipping', $baseShipping);
$address->setShippingInclTax($taxShipping);
$address->setBaseShippingInclTax($baseTaxShipping);
$address->setShippingTaxable($taxable);
$address->setBaseShippingTaxable($baseTaxable);
$address->setIsShippingInclTax($isPriceInclTax);
if ($this->_config->discountTax($store)) {
$address->setShippingAmountForDiscount($taxShipping);
$address->setBaseShippingAmountForDiscount($baseTaxShipping);
}
return $this;
}
示例4: discountTax
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
* Always apply discount first since AvaTax does not support line-level item discount amounts
*
* @param null|int $store
* @return bool
*/
public function discountTax($store = null)
{
if ($this->_getDataHelper()->isServiceEnabled($store)) {
if ($this->_getTaxDataHelper()->priceIncludesTax($store)) {
return true;
}
return false;
}
return parent::discountTax($store);
}
示例5: _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)
{
$store = $address->getQuote()->getStore();
$shippingTaxClass = $this->_config->getShippingTaxClass($store);
$shippingAmount = $address->getShippingAmount();
$baseShippingAmount = $address->getBaseShippingAmount();
$shippingDiscountAmount = $address->getShippingDiscountAmount();
$baseShippingDiscountAmount = $address->getBaseShippingDiscountAmount();
/**
* Subtract discount before calculate tax amount
*/
if ($this->_config->applyTaxAfterDiscount($store)) {
$calcAmount = $shippingAmount - $shippingDiscountAmount;
$baseCalcAmount = $baseShippingAmount - $baseShippingDiscountAmount;
} else {
$calcAmount = $shippingAmount;
$baseCalcAmount = $baseShippingAmount;
}
$shippingTax = 0;
$shippingBaseTax = 0;
if ($shippingTaxClass) {
$taxRateRequest->setProductClassId($shippingTaxClass);
$rate = $this->_calculator->getRate($taxRateRequest);
if ($rate) {
if ($this->_config->shippingPriceIncludesTax($store) && $this->_areTaxRequestsSimilar) {
$shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate, true);
$shippingBaseTax = $this->_calculator->calcTaxAmount($baseCalcAmount, $rate, true);
$shippingAmount -= $shippingTax;
$baseShippingAmount -= $shippingBaseTax;
} else {
$shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate);
$shippingBaseTax = $this->_calculator->calcTaxAmount($baseCalcAmount, $rate);
}
$address->setTotalAmount('shipping', $shippingAmount);
$address->setBaseTotalAmount('shipping', $baseShippingAmount);
/**
* Provide additional attributes for apply discount on price include tax
*/
if ($this->_config->discountTax($store)) {
$address->setShippingAmountForDiscount($shippingAmount + $shippingTax);
$address->setBaseShippingAmountForDiscount($baseShippingAmount + $shippingBaseTax);
}
$this->_addAmount($shippingTax);
$this->_addBaseAmount($shippingBaseTax);
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
$this->_saveAppliedTaxes($address, $applied, $shippingTax, $shippingBaseTax, $rate);
}
}
$address->setShippingTaxAmount($shippingTax);
$address->setBaseShippingTaxAmount($shippingBaseTax);
return $this;
}
示例6: _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;
}
示例7: discountTax
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
*
* @param null|int $store
* @return 0|1
*/
public function discountTax($store = null)
{
return $this->_config->discountTax($store);
}
示例8: collect
/**
* Collect totals information about shipping
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Shipping
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
parent::collect($address);
$calc = $this->_calculator;
$store = $address->getQuote()->getStore();
$storeTaxRequest = $calc->getRateOriginRequest($store);
$addressTaxRequest = $calc->getRateRequest($address, $address->getQuote()->getBillingAddress(), $address->getQuote()->getCustomerTaxClassId(), $store);
$shippingTaxClass = $this->_config->getShippingTaxClass($store);
$storeTaxRequest->setProductClassId($shippingTaxClass);
$addressTaxRequest->setProductClassId($shippingTaxClass);
$priceIncludesTax = $this->_config->shippingPriceIncludesTax($store);
if ($priceIncludesTax) {
if ($this->_helper->isCrossBorderTradeEnabled($store)) {
$this->_areTaxRequestsSimilar = true;
} else {
$this->_areTaxRequestsSimilar = $this->_calculator->compareRequests($storeTaxRequest, $addressTaxRequest);
}
}
$shipping = $taxShipping = $address->getShippingAmount();
$baseShipping = $baseTaxShipping = $address->getBaseShippingAmount();
$rate = $calc->getRate($addressTaxRequest);
if ($priceIncludesTax) {
if ($this->_areTaxRequestsSimilar) {
$tax = $this->_round($calc->calcTaxAmount($shipping, $rate, true, false), $rate, true);
$baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, true, false), $rate, true, 'base');
$taxShipping = $shipping;
$baseTaxShipping = $baseShipping;
$shipping = $shipping - $tax;
$baseShipping = $baseShipping - $baseTax;
$taxable = $taxShipping;
$baseTaxable = $baseTaxShipping;
$isPriceInclTax = true;
$address->setTotalAmount('shipping', $shipping);
$address->setBaseTotalAmount('shipping', $baseShipping);
} else {
$storeRate = $calc->getStoreRate($addressTaxRequest, $store);
$storeTax = $calc->calcTaxAmount($shipping, $storeRate, true, false);
$baseStoreTax = $calc->calcTaxAmount($baseShipping, $storeRate, true, false);
$shipping = $calc->round($shipping - $storeTax);
$baseShipping = $calc->round($baseShipping - $baseStoreTax);
$tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), $rate, true);
$baseTax = $this->_round($calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, true, 'base');
$taxShipping = $shipping + $tax;
$baseTaxShipping = $baseShipping + $baseTax;
$taxable = $taxShipping;
$baseTaxable = $baseTaxShipping;
$isPriceInclTax = true;
$address->setTotalAmount('shipping', $shipping);
$address->setBaseTotalAmount('shipping', $baseShipping);
}
} else {
$appliedRates = $calc->getAppliedRates($addressTaxRequest);
$taxes = array();
$baseTaxes = array();
foreach ($appliedRates as $appliedRate) {
$taxRate = $appliedRate['percent'];
$taxId = $appliedRate['id'];
$taxes[] = $this->_round($calc->calcTaxAmount($shipping, $taxRate, false, false), $taxId, false);
$baseTaxes[] = $this->_round($calc->calcTaxAmount($baseShipping, $taxRate, false, false), $taxId, false, 'base');
}
$tax = array_sum($taxes);
$baseTax = array_sum($baseTaxes);
$taxShipping = $shipping + $tax;
$baseTaxShipping = $baseShipping + $baseTax;
$taxable = $shipping;
$baseTaxable = $baseShipping;
$isPriceInclTax = false;
$address->setTotalAmount('shipping', $shipping);
$address->setBaseTotalAmount('shipping', $baseShipping);
}
$address->setShippingInclTax($taxShipping);
$address->setBaseShippingInclTax($baseTaxShipping);
$address->setShippingTaxable($taxable);
$address->setBaseShippingTaxable($baseTaxable);
$address->setIsShippingInclTax($isPriceInclTax);
if ($this->_config->discountTax($store)) {
$address->setShippingAmountForDiscount($taxShipping);
$address->setBaseShippingAmountForDiscount($baseTaxShipping);
}
return $this;
}
示例9: _totalBaseCalculation
//.........这里部分代码省略.........
$baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal();
$taxOnOrigPrice = !$this->_helper->applyTaxOnCustomPrice($this->_store) && $item->hasCustomPrice();
if ($taxOnOrigPrice) {
$origSubtotal = $item->getOriginalPrice() * $qty;
$baseOrigSubtotal = $item->getBaseOriginalPrice() * $qty;
}
$item->setTaxPercent($rate);
if ($this->_config->priceIncludesTax($this->_store)) {
if ($this->_sameRateAsStore($request)) {
if ($taxOnOrigPrice) {
$rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, true, false), $rate, true);
$baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, true, false), $rate, true, 'base');
$taxable = $origSubtotal;
$baseTaxable = $baseOrigSubtotal;
} else {
$rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, true, false), $rate, true);
$baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, true, false), $rate, true, 'base');
$taxable = $subtotal;
$baseTaxable = $baseSubtotal;
}
$taxPrice = $price;
$baseTaxPrice = $basePrice;
$taxSubtotal = $subtotal;
$baseTaxSubtotal = $baseSubtotal;
$subtotal = $subtotal - $rowTax;
$baseSubtotal = $baseSubtotal - $baseRowTax;
$price = $calc->round($subtotal / $qty);
$basePrice = $calc->round($baseSubtotal / $qty);
$isPriceInclTax = true;
} else {
$storeRate = $calc->getStoreRate($request, $this->_store);
if ($taxOnOrigPrice) {
$storeTax = $calc->calcTaxAmount($origSubtotal, $storeRate, true, false);
$baseStoreTax = $calc->calcTaxAmount($baseOrigSubtotal, $storeRate, true, false);
} else {
$storeTax = $calc->calcTaxAmount($subtotal, $storeRate, true, false);
$baseStoreTax = $calc->calcTaxAmount($baseSubtotal, $storeRate, true, false);
}
$subtotal = $calc->round($subtotal - $storeTax);
$baseSubtotal = $calc->round($baseSubtotal - $baseStoreTax);
$price = $calc->round($subtotal / $qty);
$basePrice = $calc->round($baseSubtotal / $qty);
$rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true);
$baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base');
$taxSubtotal = $subtotal + $rowTax;
$baseTaxSubtotal = $baseSubtotal + $baseRowTax;
$taxPrice = $calc->round($taxSubtotal / $qty);
$baseTaxPrice = $calc->round($baseTaxSubtotal / $qty);
$taxable = $subtotal;
$baseTaxable = $baseSubtotal;
$isPriceInclTax = false;
}
} else {
if ($taxOnOrigPrice) {
$rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, false, false), $rate, true);
$baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, false, false), $rate, true, 'base');
$taxable = $origSubtotal;
$baseTaxable = $baseOrigSubtotal;
} else {
$rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true);
$baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base');
$taxable = $subtotal;
$baseTaxable = $baseSubtotal;
}
$taxSubtotal = $subtotal + $rowTax;
$baseTaxSubtotal = $baseSubtotal + $baseRowTax;
$taxPrice = $calc->round($taxSubtotal / $qty);
$baseTaxPrice = $calc->round($baseTaxSubtotal / $qty);
$isPriceInclTax = false;
}
if ($item->hasCustomPrice()) {
/**
* Initialize item original price before declaring custom price
*/
$item->getOriginalPrice();
$item->setCustomPrice($price);
$item->setBaseCustomPrice($basePrice);
} else {
$item->setConvertedPrice($price);
}
$item->setPrice($basePrice);
$item->setBasePrice($basePrice);
$item->setRowTotal($subtotal);
$item->setBaseRowTotal($baseSubtotal);
$item->setPriceInclTax($taxPrice);
$item->setBasePriceInclTax($baseTaxPrice);
$item->setRowTotalInclTax($taxSubtotal);
$item->setBaseRowTotalInclTax($baseTaxSubtotal);
$item->setTaxableAmount($taxable);
$item->setBaseTaxableAmount($baseTaxable);
$item->setIsPriceInclTax($isPriceInclTax);
if ($this->_config->discountTax($this->_store)) {
$item->setDiscountCalculationPrice($taxSubtotal / $qty);
$item->setBaseDiscountCalculationPrice($baseTaxSubtotal / $qty);
} elseif ($isPriceInclTax) {
$item->setDiscountCalculationPrice($subtotal / $qty);
$item->setBaseDiscountCalculationPrice($baseSubtotal / $qty);
}
return $this;
}