0

I have added extra fee in the checkout page and save it to the database but when I go to credit memos the extra fee is shown in Credit memo totals but the grand total is not updated

enter image description here

This is my config.xml file

 <blocks>
      <adminhtml>
         <rewrite>
            <sales_order_creditmemo_totals>My_Module_Block_Adminhtml_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
         </rewrite>
      </adminhtml>
    </blocks>
1

1 Answer 1

1

Check this module on github by Adam Moss. I have used the creditmemoSaveBefore() method in observer for the same solution. (Use your extra charge fee variable at the place of $depositAmount)

https://github.com/adampmoss/magento-deposit-total/blob/master/app/code/local/Creare/Deposit/Model/Observer.php

Code:

class Creare_Deposit_Model_Observer {

    /* ... */

    public function creditmemoSaveBefore(Varien_Event_Observer $observer)
    {
        $post_data = Mage::app()->getRequest()->getPost();
        $creditmemo = $observer->getEvent()->getCreditmemo();
        $deposit_amount = $post_data['creditmemo']['deposit_amount'];
        if ($deposit_amount > 0)
        {
            $depositAmount = $creditmemo->getDepositAmount();
            $baseDepositAmount = $creditmemo->getDepositAmount();
            // Adjust Grand Total to reflect Deposit refund
            $creditmemo->setGrandTotal($creditmemo->getGrandTotal()-($depositAmount-$deposit_amount));
            $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal()-($baseDepositAmount-$deposit_amount));
            // Set Deposit Total to actual refund amount
            $creditmemo->setDepositAmount($deposit_amount);
            $creditmemo->setBaseDepositAmount($deposit_amount);
        }
        return $this;
    }

    /* ... */
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.