Magento 1.9 Sales – How to Show Discount Amount Excluding Tax in Invoice

magento-1.9sales

I have used "Magento ver. 1.9.2.1", I have added fixed discount to order items.

Using discount Order placed successfully and sales -> order shows correct order total but when create invoice then invoice total shows discount amount with tax.But I want to shows discount amount without tax.

For example order total with discount Rs 10 shown in figure:
enter image description here

And when I create invoice for this order then discount amount(Rs 10) shows after adding tax 11.45 ( where tax 14.5% ) as shown in figure :

enter image description here

How to shows discount amount in create invoice template without adding tax?

Best Answer

I have changed discount calculation for quote items in sales_quote_collect_totals_after observer event as below :

Before :

...
foreach($quote->getAllItems() as $item)
{
    $discountpercent = $discountAmount * ( $item->getPrice() /  $quote->getSubtotal() );
    $basediscountpercent = $baseDiscount * ( $item->getBasePrice() / $quote->getBaseSubtotal() );

    $item->setDiscountAmount((($item->getDiscountAmount() + $discountpercent) * $item->getQty()));
    $item->setBaseDiscountAmount((($item->getBaseDiscountAmount() + $basediscountpercent) * $item->getQty()))->save();
}
...

After :

...
$grandTotal = $quote->getGrandTotal();
$baseGrandTotal = $quote->getBaseGrandTotal();
$shippingAmount = $quote->getShippingAddress()->getShippingAmount();

foreach($quote->getAllItems() as $item)
{
    $discountpercent = $discountAmount * ( $item->getPriceInclTax() /  ($grandTotal-$shippingAmount) );
    $basediscountpercent = $baseDiscount * ( $item->getBasePriceInclTax() / ($baseGrandTotal-$shippingAmount) );

    $item->setDiscountAmount((($item->getDiscountAmount() + $discountpercent) * $item->getQty()));
    $item->setBaseDiscountAmount((($item->getBaseDiscountAmount() + $basediscountpercent) * $item->getQty()))->save();
}
...
Related Topic