I have issues with executing the credit memo functionality in Magento. Sometimes it works and sometimes it doesn't.
So far I have been able to narrow it down to a call to this function
$order->setBaseTotalRefunded($baseOrderRefund);
This can be found in app/code/core/Mage/Sales/Model/Order/Creditmemo.php inside a function called public function refund().
I am sure it is failing here because if I comment it out the credit memo will work. Also, in cases where the credit memo won't work, if I replace $baseOrderRefund with a hardcoded figure such as 20 for example it seems to work.
I am trying to find where this function is defined and find out exactly where the process is failing but I have been unable to find this function in the code. Can anyone point me the correct direction