Mage_Sales_Model_Order_Creditmemo_Item Class Reference

Inheritance diagram for Mage_Sales_Model_Order_Creditmemo_Item:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 _construct ()
 setCreditmemo (Mage_Sales_Model_Order_Creditmemo $creditmemo)
 getCreditmemo ()
 setOrderItem (Mage_Sales_Model_Order_Item $item)
 getOrderItem ()
 setQty ($qty)
 register ()
 cancel ()
 calcRowTotal ()

Protected Attributes

 $_eventPrefix = 'sales_creditmemo_item'
 $_eventObject = 'creditmemo_item'
 $_creditmemo = null
 $_orderItem = null


Detailed Description

Definition at line 27 of file Item.php.


Member Function Documentation

_construct (  ) 

Initialize resource model

Reimplemented from Varien_Object.

Definition at line 37 of file Item.php.

00038     {
00039         $this->_init('sales/order_creditmemo_item');
00040     }

calcRowTotal (  ) 

Invoice item row total calculation

Returns:
Mage_Sales_Model_Order_Invoice_Item

Definition at line 151 of file Item.php.

00152     {
00153         $rowTotal       = $this->getOrderItem()->getRowTotal()/$this->getOrderItem()->getQtyOrdered()*$this->getQty();
00154         $baseRowTotal   = $this->getOrderItem()->getBaseRowTotal()/$this->getOrderItem()->getQtyOrdered()*$this->getQty();
00155         
00156         $this->setRowTotal($this->getCreditmemo()->getStore()->roundPrice($rowTotal));
00157         $this->setBaseRowTotal($this->getCreditmemo()->getStore()->roundPrice($baseRowTotal));
00158         return $this;
00159     }

cancel (  ) 

Definition at line 138 of file Item.php.

00139     {
00140         $this->getOrderItem()->setQtyRefunded(
00141             $this->getOrderItem()->getQtyRefunded()-$this->getQty()
00142         );
00143         return $this;
00144     }

getCreditmemo (  ) 

Retrieve creditmemo instance

Returns:
Mage_Sales_Model_Order_Creditmemo

Definition at line 59 of file Item.php.

00060     {
00061         return $this->_creditmemo;
00062     }

getOrderItem (  ) 

Retrieve order item instance

Returns:
Mage_Sales_Model_Order_Item

Definition at line 82 of file Item.php.

00083     {
00084         if (is_null($this->_orderItem)) {
00085             if ($this->getCreditmemo()) {
00086                 $this->_orderItem = $this->getCreditmemo()->getOrder()->getItemById($this->getOrderItemId());
00087             }
00088             else {
00089                 $this->_orderItem = Mage::getModel('sales/order_item')
00090                     ->load($this->getOrderItemId());
00091             }
00092         }
00093         return $this->_orderItem;
00094     }

register (  ) 

Applying qty to order item

Returns:
Mage_Sales_Model_Order_Shipment_Item

Definition at line 130 of file Item.php.

00131     {
00132         $this->getOrderItem()->setQtyRefunded(
00133             $this->getOrderItem()->getQtyRefunded()+$this->getQty()
00134         );
00135         return $this;
00136     }

setCreditmemo ( Mage_Sales_Model_Order_Creditmemo creditmemo  ) 

Declare creditmemo instance

Parameters:
Mage_Sales_Model_Order_Creditmemo $creditmemo
Returns:
Mage_Sales_Model_Order_Creditmemo_Item

Definition at line 48 of file Item.php.

00049     {
00050         $this->_creditmemo = $creditmemo;
00051         return $this;
00052     }

setOrderItem ( Mage_Sales_Model_Order_Item item  ) 

Declare order item instance

Parameters:
Mage_Sales_Model_Order_Item $item
Returns:
Mage_Sales_Model_Order_Creditmemo_Item

Definition at line 70 of file Item.php.

00071     {
00072         $this->_orderItem = $item;
00073         $this->setOrderItemId($item->getId());
00074         return $this;
00075     }

setQty ( qty  ) 

Declare qty

Parameters:
float $qty
Returns:
Mage_Sales_Model_Order_Creditmemo_Item

Check qty availability

Definition at line 102 of file Item.php.

00103     {
00104         if ($this->getOrderItem()->getIsQtyDecimal()) {
00105             $qty = (float) $qty;
00106         }
00107         else {
00108             $qty = (int) $qty;
00109         }
00110         $qty = $qty > 0 ? $qty : 0;
00111         /**
00112          * Check qty availability
00113          */
00114         if ($qty <= $this->getOrderItem()->getQtyToRefund() || $this->getOrderItem()->isDummy()) {
00115             $this->setData('qty', $qty);
00116         }
00117         else {
00118             Mage::throwException(
00119                 Mage::helper('sales')->__('Invalid qty to refund item "%s"', $this->getName())
00120             );
00121         }
00122         return $this;
00123     }


Member Data Documentation

$_creditmemo = null [protected]

Definition at line 31 of file Item.php.

$_eventObject = 'creditmemo_item' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 30 of file Item.php.

$_eventPrefix = 'sales_creditmemo_item' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 29 of file Item.php.

$_orderItem = null [protected]

Definition at line 32 of file Item.php.


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

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