Пример #1
0
 /**
  * Clear tax related total values in address
  *
  * @param Address\Total $total
  * @return void
  */
 protected function clearValues(Address\Total $total)
 {
     $total->setTotalAmount('subtotal', 0);
     $total->setBaseTotalAmount('subtotal', 0);
     $total->setTotalAmount('tax', 0);
     $total->setBaseTotalAmount('tax', 0);
     $total->setTotalAmount('discount_tax_compensation', 0);
     $total->setBaseTotalAmount('discount_tax_compensation', 0);
     $total->setTotalAmount('shipping_discount_tax_compensation', 0);
     $total->setBaseTotalAmount('shipping_discount_tax_compensation', 0);
     $total->setSubtotalInclTax(0);
     $total->setBaseSubtotalInclTax(0);
 }
 /**
  * Process product items in the quote.
  * Set the following aggregated values in the quote object:
  * subtotal, subtotalInclTax, tax, discount_tax_compensation,
  *
  * @param ShippingAssignmentInterface $shippingAssignment
  * @param array $itemTaxDetails
  * @param QuoteAddress\Total $total
  * @return $this
  */
 protected function processProductItems(ShippingAssignmentInterface $shippingAssignment, array $itemTaxDetails, QuoteAddress\Total $total)
 {
     $store = $shippingAssignment->getShipping()->getAddress()->getQuote()->getStore();
     /** @var AbstractItem[] $keyedAddressItems */
     $keyedAddressItems = [];
     foreach ($shippingAssignment->getItems() as $addressItem) {
         $keyedAddressItems[$addressItem->getTaxCalculationItemId()] = $addressItem;
     }
     $subtotal = $baseSubtotal = 0;
     $discountTaxCompensation = $baseDiscountTaxCompensation = 0;
     $tax = $baseTax = 0;
     $subtotalInclTax = $baseSubtotalInclTax = 0;
     foreach ($itemTaxDetails as $code => $itemTaxDetail) {
         /** @var TaxDetailsItemInterface $taxDetail */
         $taxDetail = $itemTaxDetail[self::KEY_ITEM];
         /** @var TaxDetailsItemInterface $baseTaxDetail */
         $baseTaxDetail = $itemTaxDetail[self::KEY_BASE_ITEM];
         $quoteItem = $keyedAddressItems[$code];
         $this->updateItemTaxInfo($quoteItem, $taxDetail, $baseTaxDetail, $store);
         //Update aggregated values
         if ($quoteItem->getHasChildren() && $quoteItem->isChildrenCalculated()) {
             //avoid double counting
             continue;
         }
         $subtotal += $taxDetail->getRowTotal();
         $baseSubtotal += $baseTaxDetail->getRowTotal();
         $discountTaxCompensation += $taxDetail->getDiscountTaxCompensationAmount();
         $baseDiscountTaxCompensation += $baseTaxDetail->getDiscountTaxCompensationAmount();
         $tax += $taxDetail->getRowTax();
         $baseTax += $baseTaxDetail->getRowTax();
         $subtotalInclTax += $taxDetail->getRowTotalInclTax();
         $baseSubtotalInclTax += $baseTaxDetail->getRowTotalInclTax();
     }
     //Set aggregated values
     $total->setTotalAmount('subtotal', $subtotal);
     $total->setBaseTotalAmount('subtotal', $baseSubtotal);
     $total->setTotalAmount('tax', $tax);
     $total->setBaseTotalAmount('tax', $baseTax);
     $total->setTotalAmount('discount_tax_compensation', $discountTaxCompensation);
     $total->setBaseTotalAmount('discount_tax_compensation', $baseDiscountTaxCompensation);
     $total->setSubtotalInclTax($subtotalInclTax);
     $total->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
     $total->setBaseSubtotalInclTax($baseSubtotalInclTax);
     return $this;
 }
Пример #3
0
 /**
  * Process row amount based on FPT total amount configuration setting
  *
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  * @param float $rowValueExclTax
  * @param float $baseRowValueExclTax
  * @param float $rowValueInclTax
  * @param float $baseRowValueInclTax
  * @return $this
  */
 protected function processTotalAmount($total, $rowValueExclTax, $baseRowValueExclTax, $rowValueInclTax, $baseRowValueInclTax)
 {
     if ($this->weeeData->includeInSubtotal($this->_store)) {
         $total->addTotalAmount('subtotal', $rowValueExclTax);
         $total->addBaseTotalAmount('subtotal', $baseRowValueExclTax);
     } else {
         $total->addTotalAmount('weee', $rowValueExclTax);
         $total->addBaseTotalAmount('weee', $baseRowValueExclTax);
     }
     $total->setSubtotalInclTax($total->getSubtotalInclTax() + $rowValueInclTax);
     $total->setBaseSubtotalInclTax($total->getBaseSubtotalInclTax() + $baseRowValueInclTax);
     return $this;
 }
Пример #4
0
 /**
  * Process row amount based on FPT total amount configuration setting
  *
  * @param   \Magento\Quote\Model\Quote\Address\Total $total
  * @param   float $rowValueExclTax
  * @param   float $baseRowValueExclTax
  * @param   float $rowValueInclTax
  * @param   float $baseRowValueInclTax
  * @return  $this
  */
 protected function processTotalAmount($total, $rowValueExclTax, $baseRowValueExclTax, $rowValueInclTax, $baseRowValueInclTax)
 {
     if (!$this->weeeData->isTaxable($this->_store)) {
         //Accumulate the values.  Will be used later in the 'weee tax' collector
         $this->weeeTotalExclTax += $this->priceCurrency->round($rowValueExclTax);
         $this->weeeBaseTotalExclTax += $this->priceCurrency->round($baseRowValueExclTax);
     }
     //This value is used to calculate shipping cost; it will be overridden by tax collector
     $total->setSubtotalInclTax($total->getSubtotalInclTax() + $this->priceCurrency->round($rowValueInclTax));
     $total->setBaseSubtotalInclTax($total->getBaseSubtotalInclTax() + $this->priceCurrency->round($baseRowValueInclTax));
     return $this;
 }
Пример #5
0
 /**
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  */
 protected function clearValues(\Magento\Quote\Model\Quote\Address\Total $total)
 {
     // $enabled = $this->helperData->isModuleEnabled();
     // $minimumOrderAmount = $this->helperData->getMinimumOrderAmount();
     // $subtotal = $total->getTotalAmount('subtotal');
     $total->setTotalAmount('subtotal', 0);
     $total->setBaseTotalAmount('subtotal', 0);
     $total->setTotalAmount('tax', 0);
     $total->setBaseTotalAmount('tax', 0);
     $total->setTotalAmount('discount_tax_compensation', 0);
     $total->setBaseTotalAmount('discount_tax_compensation', 0);
     $total->setTotalAmount('shipping_discount_tax_compensation', 0);
     $total->setBaseTotalAmount('shipping_discount_tax_compensation', 0);
     $total->setSubtotalInclTax(0);
     $total->setBaseSubtotalInclTax(0);
 }