00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Mage_Weee_Model_Total_Creditmemo_Weee extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
00029 {
00030 public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
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 }
00075 }