Esempio n. 1
0
 /**
  * Add extension attribute fields to the \Magento\Tax\Model\Sales\Quote\ItemDetails object for the shipping record
  *
  * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterface $shippingDataObject
  * @param $storeId
  * @return $this
  */
 protected function addInfoToQuoteDetailsItemForShipping(\Magento\Tax\Api\Data\QuoteDetailsItemInterface $shippingDataObject, $storeId)
 {
     $itemCode = $this->config->getSkuShipping($storeId);
     $itemDescription = \ClassyLlama\AvaTax\Framework\Interaction\Line::SHIPPING_LINE_DESCRIPTION;
     $taxCode = $this->taxClassHelper->getAvataxTaxCodeForShipping();
     $this->addExtensionAttributesToTaxQuoteDetailsItem($shippingDataObject, $itemCode, $taxCode, $itemDescription);
     return $this;
 }
Esempio n. 2
0
 /**
  * Accepts an invoice or creditmemo and returns an \AvaTax\Line object
  *
  * @param \Magento\Sales\Api\Data\InvoiceInterface|\Magento\Sales\Api\Data\CreditmemoInterface $data
  * @param $credit
  * @return \AvaTax\Line|bool
  * @throws MetaData\ValidationException
  */
 public function getShippingLine($data, $credit)
 {
     $shippingAmount = $data->getBaseShippingAmount();
     // If shipping rate doesn't have cost associated with it, do nothing
     if ($shippingAmount <= 0) {
         return false;
     }
     if ($credit) {
         $shippingAmount *= -1;
     }
     $storeId = $data->getStoreId();
     $itemCode = $this->config->getSkuShipping($storeId);
     $data = ['No' => $this->getLineNumber(), 'ItemCode' => $itemCode, 'TaxCode' => $this->taxClassHelper->getAvataxTaxCodeForShipping(), 'Description' => self::SHIPPING_LINE_DESCRIPTION, 'Qty' => 1, 'Amount' => $shippingAmount, 'Discounted' => false];
     try {
         $data = $this->metaDataObject->validateData($data);
     } catch (ValidationException $e) {
         $this->avaTaxLogger->error('Error validating line: ' . $e->getMessage(), ['data' => var_export($data, true)]);
     }
     /** @var $line \AvaTax\Line */
     $line = $this->lineFactory->create();
     $this->populateLine($data, $line);
     return $line;
 }