/** * 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; } $product = $this->_getProductByProductId($item->getProductId()); $taxClass = $this->_getTaxClassByProduct($product); $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount(); if ($credit) { //@startSkipCommitHooks $price *= -1; //@finishSkipCommitHooks } $line = new Line(); $line->setNo(count($this->_lines)); $line->setItemCode(substr($item->getSku(), 0, 50)); $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); if ($ref1Value) { $line->setRef1($ref1Value); } $ref2Value = $this->_getRefValueByProductAndNumber($product, 2); if ($ref2Value) { $line->setRef2($ref2Value); } $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId(); $this->_lines[] = $line; }