Make creditmemo display negative prices
-
16-10-2019 - |
Question
In the creditmemo all prices are shows as positive amounts, to make the difference between an invoice and a creditmemo more clear I would like to display the prices as negative values. Is there a way to show negative prices for creditmemos?
Solution
The good way:
rewrite the core class Mage_Directory_Model_Currency
method formatTxt
with this code:
public function formatTxt($price, $options=array())
{
$price = parent::formatTxt($price,$options);
if ( Mage::app()->getRequest()->getControllerName() == "sales_order_creditmemo" ) {
return "-".$price;
}
return $price;
}
A dirtier way :
If you just want this to be a visual (display) change, you can simply edit the .phtml files and place a - in front of the price output.
You'd need to edit many places in the file, and multiple files (creditmemo, bundles, downloadables, configurables - off the top of my head) - see for example adminhtml/default/default/template/sales/order/creditmemo/view/items/renderer/default.phtml
EDIT: I have updated the routine, to actually call the core parent method first, this way you retain core functionality (if and when the core code changes with any upgrades)