Beispiel #1
0
 /**
  * Process row amount based on FPT total amount configuration setting
  *
  * @param   \Magento\Sales\Model\Quote\Address $address
  * @param   float $rowValueExclTax
  * @param   float $baseRowValueExclTax
  * @param   float $rowValueInclTax
  * @param   float $baseRowValueInclTax
  * @return  $this
  */
 protected function processTotalAmount($address, $rowValueExclTax, $baseRowValueExclTax, $rowValueInclTax, $baseRowValueInclTax)
 {
     if ($this->weeeData->includeInSubtotal($this->_store)) {
         $address->addTotalAmount('subtotal', $rowValueExclTax);
         $address->addBaseTotalAmount('subtotal', $baseRowValueExclTax);
     } else {
         $address->addTotalAmount('weee', $rowValueExclTax);
         $address->addBaseTotalAmount('weee', $baseRowValueExclTax);
     }
     $address->setSubtotalInclTax($address->getSubtotalInclTax() + $rowValueInclTax);
     $address->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax() + $baseRowValueInclTax);
     return $this;
 }
Beispiel #2
0
 /**
  * Process row amount based on FPT total amount configuration setting
  *
  * @param   \Magento\Sales\Model\Quote\Address $address
  * @param   float $rowValueExclTax
  * @param   float $baseRowValueExclTax
  * @param   float $rowValueInclTax
  * @param   float $baseRowValueInclTax
  * @return  $this
  */
 protected function _processTotalAmount($address, $rowValueExclTax, $baseRowValueExclTax, $rowValueInclTax, $baseRowValueInclTax)
 {
     //TODO: use tax service to calculate tax
     if ($this->_weeeData->includeInSubtotal($this->_store)) {
         $address->setExtraSubtotalAmount($this->_store->roundPrice($rowValueExclTax));
         $address->setBaseExtraSubtotalAmount($this->_store->roundPrice($baseRowValueExclTax));
     } else {
         $address->addTotalAmount('weee', $rowValueExclTax);
         $address->addBaseTotalAmount('weee', $baseRowValueExclTax);
     }
     $address->setExtraTaxAmount($rowValueInclTax - $rowValueExclTax);
     $address->setBaseExtraTaxAmount($baseRowValueInclTax - $baseRowValueExclTax);
     $address->setSubtotalInclTax($address->getSubtotalInclTax() + $this->_store->roundPrice($rowValueInclTax));
     $address->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax() + $this->_store->roundPrice($baseRowValueInclTax));
     return $this;
 }
Beispiel #3
0
 /**
  * Update tax related fields for shipping
  *
  * @param Address $address
  * @param \Magento\Tax\Service\V1\Data\TaxDetails\Item $shippingTaxDetails
  * @param \Magento\Tax\Service\V1\Data\TaxDetails\Item $baseShippingTaxDetails
  * @return $this
  */
 protected function processShippingTaxInfo(Address $address, $shippingTaxDetails, $baseShippingTaxDetails)
 {
     $address->setTotalAmount('shipping', $shippingTaxDetails->getRowTotal());
     $address->setBaseTotalAmount('shipping', $baseShippingTaxDetails->getRowTotal());
     $address->setTotalAmount('shipping_hidden_tax', $shippingTaxDetails->getDiscountTaxCompensationAmount());
     $address->setBaseTotalAmount('shipping_hidden_tax', $baseShippingTaxDetails->getDiscountTaxCompensationAmount());
     $address->setShippingInclTax($shippingTaxDetails->getRowTotalInclTax());
     $address->setBaseShippingInclTax($baseShippingTaxDetails->getRowTotalInclTax());
     $address->setShippingTaxAmount($shippingTaxDetails->getRowTax());
     $address->setBaseShippingTaxAmount($baseShippingTaxDetails->getRowTax());
     //Add the shipping tax to total tax amount
     $address->addTotalAmount('tax', $shippingTaxDetails->getRowTax());
     $address->addBaseTotalAmount('tax', $baseShippingTaxDetails->getRowTax());
     if ($this->_config->discountTax($address->getQuote()->getStore())) {
         $address->setShippingAmountForDiscount($shippingTaxDetails->getRowTotalInclTax());
         $address->setBaseShippingAmountForDiscount($baseShippingTaxDetails->getRowTotalInclTax());
     }
     return $this;
 }
Beispiel #4
0
 /**
  * Process everything other than product or shipping, save the result in quote
  *
  * @param Address $address
  * @param array $itemsByType
  * @return $this
  */
 protected function processExtraTaxables(Address $address, array $itemsByType)
 {
     $extraTaxableDetails = [];
     foreach ($itemsByType as $itemType => $itemTaxDetails) {
         if ($itemType != self::ITEM_TYPE_PRODUCT and $itemType != self::ITEM_TYPE_SHIPPING) {
             foreach ($itemTaxDetails as $itemCode => $itemTaxDetail) {
                 /** @var ItemTaxDetails $taxDetails */
                 $taxDetails = $itemTaxDetail[self::KEY_ITEM];
                 /** @var ItemTaxDetails $baseTaxDetails */
                 $baseTaxDetails = $itemTaxDetail[self::KEY_BASE_ITEM];
                 $appliedTaxes = $taxDetails->getAppliedTaxes();
                 $baseAppliedTaxes = $baseTaxDetails->getAppliedTaxes();
                 $associatedItemCode = $taxDetails->getAssociatedItemCode();
                 $appliedTaxesArray = $this->convertAppliedTaxes($appliedTaxes, $baseAppliedTaxes);
                 $extraTaxableDetails[$itemType][$associatedItemCode][] = [self::KEY_TAX_DETAILS_TYPE => $taxDetails->getType(), self::KEY_TAX_DETAILS_CODE => $taxDetails->getCode(), self::KEY_TAX_DETAILS_PRICE_EXCL_TAX => $taxDetails->getPrice(), self::KEY_TAX_DETAILS_PRICE_INCL_TAX => $taxDetails->getPriceInclTax(), self::KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX => $baseTaxDetails->getPrice(), self::KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX => $baseTaxDetails->getPriceInclTax(), self::KEY_TAX_DETAILS_ROW_TOTAL => $taxDetails->getRowTotal(), self::KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX => $taxDetails->getRowTotalInclTax(), self::KEY_TAX_DETAILS_BASE_ROW_TOTAL => $baseTaxDetails->getRowTotal(), self::KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX => $baseTaxDetails->getRowTotalInclTax(), self::KEY_TAX_DETAILS_TAX_PERCENT => $taxDetails->getTaxPercent(), self::KEY_TAX_DETAILS_ROW_TAX => $taxDetails->getRowTax(), self::KEY_TAX_DETAILS_BASE_ROW_TAX => $baseTaxDetails->getRowTax(), self::KEY_TAX_DETAILS_APPLIED_TAXES => $appliedTaxesArray];
                 $address->addTotalAmount('tax', $taxDetails->getRowTax());
                 $address->addBaseTotalAmount('tax', $baseTaxDetails->getRowTax());
                 //TODO: save applied taxes for the item
             }
         }
     }
     $address->setExtraTaxableDetails($extraTaxableDetails);
     return $this;
 }