I have added a new custom subtotal to my totals in Magento CE 18.104.22.168. 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.
I've done all this as described in this blog with a few modifcations: https://astrio.net/blog/magento-development-add-total-row-checkout/
<sales> <quote> <totals> <***_***surcharge> <class>***_***surcharge_Model_Total_***surcharge_Quote</class> <after>nominal</after> <before>subtotal</before> </***_***surcharge> </totals> </quote> [...] </sales>
As you can see, I want to add this custom total (surcharge) before the subtotal, right after the start.
<default> <sales> <totals_sort> <***_***surcharge>5</***_***surcharge> </totals_sort> </sales> </default>
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.