I don't know how you add COD Charges in the order so I will write a code how to add COD Charges only in PDF Invoice in Magento core files. I highly recommend to transfer this code in the custom module that you are using.
in app/code/core/Mage/Sales/etc/config.xml
-> in pdf/totals node add this:
<codcharges translate="title">
<title>COD Charges</title>
<model>sales/order_pdf_total_codcharges</model>
<font_size>7</font_size>
<display_zero>0</display_zero>
<sort_order>300</sort_order>
</codcharges>
then create new file app/code/core/Mage/Sales/Model/Order/Pdf/Total/Codcharges.php
with this content:
<?php
class Mage_Sales_Model_Order_Pdf_Total_Codcharges extends Mage_Sales_Model_Order_Pdf_Total_Default
{
public function getTotalsForDisplay()
{
$price = 15; //or write a code to get it from where you store it for each order
$amount = $this->getOrder()->formatPriceTxt($price);
$label = Mage::helper('sales')->__($this->getTitle());
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
$total = array(
'amount' => $amount,
'label' => $label,
'font_size' => $fontSize
);
return array($total);
}
}
For hints you can see app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php
.
To add it to the Grand Total of the Invoice please try with this:
in config.xml
in sales/order_invoice/totals node add:
<codcharges>
<class>sales/order_invoice_total_codcharges</class>
<after>subtotal,discount</after>
<before>grand_total,tax</before>
</codcharges>
Create new file app/code/core/Mage/Sales/Model/Order/Invoice/Total/Codcharges.php
:
<?php
class Mage_Sales_Model_Order_Invoice_Total_Codcharges extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$amount = 15; //or write a code to get it from where you store it for each order
$invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
return $this;
}
}