Mage_Sales_Model_Order_Invoice_Item Class Reference

Inheritance diagram for Mage_Sales_Model_Order_Invoice_Item:

Mage_Core_Model_Abstract Varien_Object

List of all members.

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


Detailed Description

Definition at line 28 of file Item.php.


Member Function Documentation

_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

Returns:
Mage_Sales_Model_Order_Invoice_Item

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

Returns:
Mage_Sales_Model_Order_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

Returns:
Mage_Sales_Model_Order_Invoice

Definition at line 61 of file Item.php.

00062     {
00063         return $this->_invoice;
00064     }

getOrderItem (  ) 

Retrieve order item instance

Returns:
Mage_Sales_Model_Order_Item

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

Returns:
bool

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

Returns:
Mage_Sales_Model_Order_Invoice_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

Parameters:
Mage_Sales_Model_Order_Invoice $invoice
Returns:
Mage_Sales_Model_Order_Invoice_Item

Definition at line 50 of file Item.php.

00051     {
00052         $this->_invoice = $invoice;
00053         return $this;
00054     }

setOrderItem ( Mage_Sales_Model_Order_Item item  ) 

Declare order item instance

Parameters:
Mage_Sales_Model_Order_Item $item
Returns:
Mage_Sales_Model_Order_Invoice_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

Parameters:
float $qty
Returns:
Mage_Sales_Model_Order_Invoice_Item

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     }


Member Data Documentation

$_eventObject = 'invoice_item' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 31 of file Item.php.

$_eventPrefix = 'sales_invoice_item' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 30 of file Item.php.

$_invoice = null [protected]

Definition at line 33 of file Item.php.

$_orderItem = null [protected]

Definition at line 34 of file Item.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:47 2009 for Magento by  doxygen 1.5.8