Custom total (surcharge) added before subtotal but tax is to low in Magento 1.9

by Osiriz   Last Updated September 18, 2018 09:09 AM

I have added a new custom subtotal to my totals in Magento CE Each item in my shopping cart may have a different surcharge to avoid losses due to fluctuations in value. This is common in the industry that these surcharges are calculated and presented separately. A helper class calculates this value for each item and only show it under the final price without taxes in the template. Later, the surcharges will be added together and shown as a subtotal below. It looks good so far and everything works as it should, except the calculation of taxes. The tax calculation uses the subtotal as a basis and not the subtotal plus the surcharges, as you can see in the snapshot of the shopping cart below. The yellow arrow shows what i want, the red one is the wrong calculation basis. I expect the VAT amount to be 3.86€ (19% of 19,86€ + 0,47€) and not 3.77€ (19% of 19,86€). So the taxes are too low.

wrong tax calculation in cart

I've done all this as described in this blog with a few modifcations:

My config.xml:


As you can see, I want to add this custom total (surcharge) before the subtotal, right after the start.


And I want to show it as the first total in the list (subtotal has the value 10, so 5 is lower). In the admin backend the tax calculation method based on pos. subtotal.

How can I force the "VAT total" to take the surcharge into account?

If you need more information, let me know and thank you in advance.

Related Questions

Wrong calculation credit memo

Updated June 11, 2017 13:09 PM

Magento 2: Sub total is not updating on custom discount

Updated September 23, 2017 15:09 PM