/** * 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 getGiftWrapCardLine($data, $credit) { $giftWrapCardAmount = $data->getGwCardBasePrice(); if ($giftWrapCardAmount <= 0) { return false; } if ($credit) { $giftWrapCardAmount *= -1; } $storeId = $data->getStoreId(); $itemCode = $this->config->getSkuShippingGiftWrapCard($storeId); $data = ['No' => $this->getLineNumber(), 'ItemCode' => $itemCode, 'TaxCode' => $this->taxClassHelper->getAvataxTaxCodeForGiftOptions($storeId), 'Description' => self::GIFT_WRAP_CARD_LINE_DESCRIPTION, 'Qty' => 1, 'Amount' => $giftWrapCardAmount, '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; }