Public Member Functions | |
_construct () | |
setInvoice (Mage_Sales_Model_Order_Invoice $invoice) | |
getInvoice () | |
setOrderItem (Mage_Sales_Model_Order_Item $item) | |
getOrderItem () | |
setQty ($qty) | |
register () | |
cancel () | |
calcRowTotal () | |
isLast () | |
Protected Attributes | |
$_eventPrefix = 'sales_invoice_item' | |
$_eventObject = 'invoice_item' | |
$_invoice = null | |
$_orderItem = null |
Definition at line 28 of file Item.php.
_construct | ( | ) |
Initialize resource model
Reimplemented from Varien_Object.
Definition at line 39 of file Item.php.
00040 { 00041 $this->_init('sales/order_invoice_item'); 00042 }
calcRowTotal | ( | ) |
Invoice item row total calculation
Definition at line 175 of file Item.php.
00176 { 00177 $rowTotal = $this->getOrderItem()->getRowTotal()/$this->getOrderItem()->getQtyOrdered()*$this->getQty(); 00178 $baseRowTotal = $this->getOrderItem()->getBaseRowTotal()/$this->getOrderItem()->getQtyOrdered()*$this->getQty(); 00179 00180 $this->setRowTotal($this->getInvoice()->getStore()->roundPrice($rowTotal)); 00181 $this->setBaseRowTotal($this->getInvoice()->getStore()->roundPrice($baseRowTotal)); 00182 return $this; 00183 }
cancel | ( | ) |
Cancelling invoice item
Definition at line 154 of file Item.php.
00155 { 00156 $orderItem = $this->getOrderItem(); 00157 $orderItem->setQtyInvoiced($orderItem->getQtyInvoiced()-$this->getQty()); 00158 00159 $orderItem->setTaxInvoiced($orderItem->getTaxInvoiced()-$this->getTaxAmount()); 00160 $orderItem->setBaseTaxInvoiced($orderItem->getBaseTaxInvoiced()-$this->getBaseTaxAmount()); 00161 00162 $orderItem->setDiscountInvoiced($orderItem->getDiscountInvoiced()-$this->getDiscountAmount()); 00163 $orderItem->setBaseDiscountInvoiced($orderItem->getBaseDiscountInvoiced()-$this->getBaseDiscountAmount()); 00164 00165 $orderItem->setRowInvoiced($orderItem->getRowInvoiced()-$this->getRowTotal()); 00166 $orderItem->setBaseRowInvoiced($orderItem->getBaseRowInvoiced()-$this->getBaseRowTotal()); 00167 return $this; 00168 }
getInvoice | ( | ) |
Retrieve invoice instance
Definition at line 61 of file Item.php.
getOrderItem | ( | ) |
Retrieve order item instance
Definition at line 84 of file Item.php.
00085 { 00086 if (is_null($this->_orderItem)) { 00087 if ($this->getInvoice()) { 00088 $this->_orderItem = $this->getInvoice()->getOrder()->getItemById($this->getOrderItemId()); 00089 } 00090 else { 00091 $this->_orderItem = Mage::getModel('sales/order_item') 00092 ->load($this->getOrderItemId()); 00093 } 00094 } 00095 return $this->_orderItem; 00096 }
isLast | ( | ) |
Checking if the item is last
Definition at line 190 of file Item.php.
00191 { 00192 if ($this->getQty() == $this->getOrderItem()->getQtyToInvoice()) { 00193 return true; 00194 } 00195 return false; 00196 }
register | ( | ) |
Applying qty to order item
Definition at line 133 of file Item.php.
00134 { 00135 $orderItem = $this->getOrderItem(); 00136 $orderItem->setQtyInvoiced($orderItem->getQtyInvoiced()+$this->getQty()); 00137 00138 $orderItem->setTaxInvoiced($orderItem->getTaxInvoiced()+$this->getTaxAmount()); 00139 $orderItem->setBaseTaxInvoiced($orderItem->getBaseTaxInvoiced()+$this->getBaseTaxAmount()); 00140 00141 $orderItem->setDiscountInvoiced($orderItem->getDiscountInvoiced()+$this->getDiscountAmount()); 00142 $orderItem->setBaseDiscountInvoiced($orderItem->getBaseDiscountInvoiced()+$this->getBaseDiscountAmount()); 00143 00144 $orderItem->setRowInvoiced($orderItem->getRowInvoiced()+$this->getRowTotal()); 00145 $orderItem->setBaseRowInvoiced($orderItem->getBaseRowInvoiced()+$this->getBaseRowTotal()); 00146 return $this; 00147 }
setInvoice | ( | Mage_Sales_Model_Order_Invoice $ | invoice | ) |
Declare invoice instance
Mage_Sales_Model_Order_Invoice | $invoice |
Definition at line 50 of file Item.php.
setOrderItem | ( | Mage_Sales_Model_Order_Item $ | item | ) |
Declare order item instance
Mage_Sales_Model_Order_Item | $item |
Definition at line 72 of file Item.php.
00073 { 00074 $this->_orderItem = $item; 00075 $this->setOrderItemId($item->getId()); 00076 return $this; 00077 }
setQty | ( | $ | qty | ) |
Declare qty
float | $qty |
Check qty availability
Definition at line 104 of file Item.php.
00105 { 00106 if ($this->getOrderItem()->getIsQtyDecimal()) { 00107 $qty = (float) $qty; 00108 } 00109 else { 00110 $qty = (int) $qty; 00111 } 00112 $qty = $qty > 0 ? $qty : 0; 00113 /** 00114 * Check qty availability 00115 */ 00116 00117 if ($qty <= $this->getOrderItem()->getQtyToInvoice() || $this->getOrderItem()->isDummy()) { 00118 $this->setData('qty', $qty); 00119 } 00120 else { 00121 Mage::throwException( 00122 Mage::helper('sales')->__('Invalid qty to invoice item "%s"', $this->getName()) 00123 ); 00124 } 00125 return $this; 00126 }
$_eventObject = 'invoice_item' [protected] |
$_eventPrefix = 'sales_invoice_item' [protected] |