Beispiel #1
0
 /**
  * Adds minimal tax information to the "total" data structure
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param Address\Total $total
  * @return null
  */
 protected function enhanceTotalData(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
 {
     $taxAmount = 0;
     $shippingTaxAmount = 0;
     $discountTaxCompensation = 0;
     $subtotalInclTax = $total->getSubtotalInclTax();
     $computeSubtotalInclTax = true;
     if ($total->getSubtotalInclTax() > 0) {
         $computeSubtotalInclTax = false;
     }
     /** @var \Magento\Quote\Model\Quote\Address $address */
     foreach ($quote->getAllAddresses() as $address) {
         $taxAmount += $address->getTaxAmount();
         $shippingTaxAmount += $address->getShippingTaxAmount();
         $discountTaxCompensation += $address->getDiscountTaxCompensationAmount();
         if ($computeSubtotalInclTax) {
             $subtotalInclTax += $address->getSubtotalInclTax();
         }
     }
     $total->setTaxAmount($taxAmount);
     $total->setShippingTaxAmount($shippingTaxAmount);
     $total->setDiscountTaxCompensationAmount($discountTaxCompensation);
     // accessed via 'discount_tax_compensation'
     $total->setSubtotalInclTax($subtotalInclTax);
     return;
 }
 /**
  * Update tax related fields for shipping
  *
  * @param ShippingAssignmentInterface $shippingAssignment
  * @param QuoteAddress\Total $total
  * @param TaxDetailsItemInterface $shippingTaxDetails
  * @param TaxDetailsItemInterface $baseShippingTaxDetails
  * @return $this
  */
 protected function processShippingTaxInfo(ShippingAssignmentInterface $shippingAssignment, QuoteAddress\Total $total, $shippingTaxDetails, $baseShippingTaxDetails)
 {
     $total->setTotalAmount('shipping', $shippingTaxDetails->getRowTotal());
     $total->setBaseTotalAmount('shipping', $baseShippingTaxDetails->getRowTotal());
     $total->setTotalAmount('shipping_discount_tax_compensation', $shippingTaxDetails->getDiscountTaxCompensationAmount());
     $total->setBaseTotalAmount('shipping_discount_tax_compensation', $baseShippingTaxDetails->getDiscountTaxCompensationAmount());
     $total->setShippingInclTax($shippingTaxDetails->getRowTotalInclTax());
     $total->setBaseShippingInclTax($baseShippingTaxDetails->getRowTotalInclTax());
     $total->setShippingTaxAmount($shippingTaxDetails->getRowTax());
     $total->setBaseShippingTaxAmount($baseShippingTaxDetails->getRowTax());
     //Add the shipping tax to total tax amount
     $total->addTotalAmount('tax', $shippingTaxDetails->getRowTax());
     $total->addBaseTotalAmount('tax', $baseShippingTaxDetails->getRowTax());
     if ($this->_config->discountTax($shippingAssignment->getShipping()->getAddress()->getQuote()->getStore())) {
         $total->setShippingAmountForDiscount($shippingTaxDetails->getRowTotalInclTax());
         $total->setBaseShippingAmountForDiscount($baseShippingTaxDetails->getRowTotalInclTax());
     }
     return $this;
 }