I have add an observer to sales_quote_collect_totals_after
to changing tax amount, the tax is changed but order totals and tax totals are wrong.
I tried with :
<checkout_submit_all_after>
<observers>
<Module_Sales>
<type>singleton</type>
<class>Module_Sales_Model_Observer</class>
<method>setTaxAmountOrder</method>
</Module_Sales>
</observers>
</checkout_submit_all_after>
Without success finally i try to change the totals by :
$order = Mage::getModel('sales/order')->load(356);
$order->setSubtotal(500) ;
$order->setBaseSubtotal(500) ;
$order->setGrandTotal(500) ;
$order->setBaseGrandTotal(500) ;
$order->setBaseSubtotalInclTax(500) ;
Without success because only setSubtotal has changed. Can you help me.
this is when i save order
$_items = $order->getAllVisibleItems();
foreach ($_items as $item) {
$price = $item->getPrice();
$basePrice = $item->getBasePrice();
$_taxHelper = Mage::helper('tax');
$_store = $item->getProduct()->getStore();
$_convertedPrice_ = $_store->roundPrice($_store->convertPrice($item->getPrice()));
$_convertedBasePrice_ = $_store->roundPrice($_store->convertPrice($item->getPrice()));
$taxamount = $_taxHelper->getPrice($item, ($price * 0.2), null, null, null, null, null, null, false);
$baseNewTaxAmount = $_taxHelper->getPrice($item, ($basePrice * 0.2), null, null, null, null, null, null, false);
$finalprodprice = $_convertedPrice_ + ($_convertedPrice_ * 0.2) + ($taxamount - ($item->getProduct()->getPrice() * 0.2));
$finalprodBaseprice = $_convertedBasePrice_ + ($_convertedBasePrice_ * 0.2) + ($baseNewTaxAmount - ($basePrice * 0.2));
$item->setTaxAmount($taxamount - ($item->getPrice() * 0.2));
$item->setBaseTaxAmount($baseNewTaxAmount - ($item->getPrice() * 0.2));
$item->setPrice($finalprodprice);
$item->setPriceInclTax($finalprodprice);
$item->setBasePriceInclTax($finalprodBaseprice);
$item->save();
}
$order->setSubtotal($finalprodprice)->setBaseSubtotal($finalprodprice);
$order->setGrandTotal($finalprodprice)->setBaseGrandTotal($finalprodprice);
$order->setBaseSubtotalInclTax($finalprodprice);
$order->save();