Public Member Functions | |
collect (Mage_Sales_Model_Order_Creditmemo $creditmemo) |
Definition at line 28 of file Weee.php.
collect | ( | Mage_Sales_Model_Order_Creditmemo $ | creditmemo | ) |
Reimplemented from Mage_Sales_Model_Order_Creditmemo_Total_Abstract.
Definition at line 30 of file Weee.php.
00031 { 00032 $store = $creditmemo->getStore(); 00033 00034 $totalTax = 0; 00035 $baseTotalTax = 0; 00036 00037 foreach ($creditmemo->getAllItems() as $item) { 00038 if ($item->getOrderItem()->isDummy()) { 00039 continue; 00040 } 00041 $orderItemQty = $item->getOrderItem()->getQtyOrdered(); 00042 00043 $totalTax += $item->getWeeeTaxAppliedAmount()*$item->getQty(); 00044 $baseTotalTax += $item->getBaseWeeeTaxAppliedAmount()*$item->getQty(); 00045 00046 $newApplied = array(); 00047 $applied = Mage::helper('weee')->getApplied($item); 00048 foreach ($applied as $one) { 00049 $one['base_row_amount'] = $one['base_amount']*$item->getQty(); 00050 $one['row_amount'] = $one['amount']*$item->getQty(); 00051 $one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax']*$item->getQty(); 00052 $one['row_amount_incl_tax'] = $one['amount_incl_tax']*$item->getQty(); 00053 00054 $newApplied[] = $one; 00055 } 00056 Mage::helper('weee')->setApplied($item, $newApplied); 00057 00058 $item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition()*$item->getQty()); 00059 $item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition()*$item->getQty()); 00060 } 00061 00062 if (Mage::helper('weee')->includeInSubtotal($store)) { 00063 $creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax); 00064 $creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax); 00065 } else { 00066 $creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax); 00067 $creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax); 00068 } 00069 00070 $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax); 00071 $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax); 00072 00073 return $this; 00074 }