Example #1
0
 /**
  * Makes a Line object from a product item object
  *
  * @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
  * @param bool $credit
  * @return null|bool
  */
 protected function _newLine($item, $credit = false)
 {
     if ($this->isProductCalculated($item->getOrderItem())) {
         return false;
     }
     if ($item->getQty() == 0) {
         return false;
     }
     $lineNumber = $this->_getNewLineCode();
     $storeId = $this->_retrieveStoreIdFromItem($item);
     $line = $this->_getNewDocumentRequestLineObject();
     $price = $item->getBaseRowTotal();
     if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
         $line->setTaxIncluded('true');
         $price = $item->getBaseRowTotalInclTax();
     }
     if ($this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId)) {
         $price -= $item->getBaseDiscountAmount();
     }
     //@startSkipCommitHooks
     $price = $credit ? -1 * $price : $price;
     //@finishSkipCommitHooks
     $line->setLineCode($lineNumber);
     $line->setItemCode($this->_getCalculationHelper()->getItemCode($this->_getProductForItemCode($item), $storeId, $item));
     $line->setItemDescription($item->getName());
     $line->setNumberOfItems($item->getQty());
     $line->setlineAmount($price);
     $line->setDiscounted($item->getBaseDiscountAmount() && $this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId) ? 'true' : 'false');
     $productData = $this->_getLineProductData($item, $storeId);
     $line->setAvalaraGoodsAndServicesType($productData->getTaxCode());
     $line->setMetadata($productData->getMetaData());
     $this->_lineToItemId[$lineNumber] = $item->getOrderItemId();
     $this->_lines[$lineNumber] = $line;
 }
Example #2
0
 /**
  * Makes a Line object from a product item object
  *
  * @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
  * @param bool $credit
  * @return null
  */
 protected function _newLine($item, $credit = false)
 {
     if ($this->isProductCalculated($item->getOrderItem())) {
         return false;
     }
     if ($item->getQty() == 0) {
         return false;
     }
     $storeId = $this->_retrieveStoreIdFromItem($item);
     $product = $this->_getProductByProductId($item->getProductId());
     $taxClass = $this->_getTaxClassCodeByProduct($product);
     $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
     if ($credit) {
         //@startSkipCommitHooks
         $price *= -1;
         //@finishSkipCommitHooks
     }
     $line = new Line();
     $line->setNo(count($this->_lines));
     $line->setItemCode($this->_getItemCode($this->_getProductForItemCode($item), $item, $storeId));
     $line->setDescription($item->getName());
     $line->setQty($item->getQty());
     $line->setAmount($price);
     $line->setDiscounted($item->getBaseDiscountAmount() ? true : false);
     if ($taxClass) {
         $line->setTaxCode($taxClass);
     }
     $ref1Value = $this->_getRefValueByProductAndNumber($product, 1, $storeId);
     if ($ref1Value) {
         $line->setRef1($ref1Value);
     }
     $ref2Value = $this->_getRefValueByProductAndNumber($product, 2, $storeId);
     if ($ref2Value) {
         $line->setRef2($ref2Value);
     }
     $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
     $this->_lines[] = $line;
 }
Example #3
0
 /**
  * Makes a Line object from a product item object
  *
  * @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
  * @param bool $credit
  * @return null
  */
 protected function _newLine($item, $credit = false)
 {
     if ($this->isProductCalculated($item->getOrderItem())) {
         return false;
     }
     if ($item->getQty() == 0) {
         return false;
     }
     $line = new Line();
     $storeId = $this->_retrieveStoreIdFromItem($item);
     $price = $item->getBaseRowTotal();
     if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
         $line->setTaxIncluded(true);
         $price = $item->getBaseRowTotalInclTax();
     }
     if ($this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId)) {
         $price -= $item->getBaseDiscountAmount();
     }
     if ($credit) {
         //@startSkipCommitHooks
         $price *= -1;
         //@finishSkipCommitHooks
     }
     $line->setNo(count($this->_lines));
     $line->setItemCode($this->_getCalculationHelper()->getItemCode($this->_getProductForItemCode($item), $storeId, $item));
     $line->setDescription($item->getName());
     $line->setQty($item->getQty());
     $line->setAmount($price);
     $line->setDiscounted((double) $item->getBaseDiscountAmount() && $this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId));
     $productData = $this->_getLineProductData($item, $storeId);
     $line->setTaxCode($productData->getTaxCode());
     $line->setRef1($productData->getRef1());
     $line->setRef2($productData->getRef2());
     $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
     $this->_lines[] = $line;
 }
Example #4
0
 /**
  * Makes a Line object from a product item object
  *
  * @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
  * @param bool $credit
  * @return null
  */
 protected function _newLine($item, $credit = false)
 {
     if ($this->isProductCalculated($item->getOrderItem())) {
         return false;
     }
     if ($item->getQty() == 0) {
         return false;
     }
     $storeId = $this->_retrieveStoreIdFromItem($item);
     $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
     if ($credit) {
         //@startSkipCommitHooks
         $price *= -1;
         //@finishSkipCommitHooks
     }
     $line = new Line();
     $line->setNo(count($this->_lines));
     $line->setItemCode($this->_getItemCode($item, $storeId));
     $line->setDescription($item->getName());
     $line->setQty($item->getQty());
     $line->setAmount($price);
     $line->setDiscounted($item->getBaseDiscountAmount() ? true : false);
     $productData = $this->_getLineProductData($item, $storeId);
     $line->setTaxCode($productData->getTaxCode());
     $line->setRef1($productData->getRef1());
     $line->setRef2($productData->getRef2());
     $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
     $this->_lines[] = $line;
 }