I'm trying to understand how Magento handles the order totals and trying to replicate the same behaviour for a Magento 2 Module.
This is one of the most weird cases or as we call it, the "100 Coffees Problem".
The price of each coffee (without VAT) is 0,49€.
Each coffee has a VAT of 23% applied.
If we have 10 rows of 10 coffees each, we get this totals:
Subtotal: 49,00 €
Tax: 11,30 €
Grand Total: 60,30 €
But if we have for example 1 row of 100 coffees, we have the following totals:
Subtotal: 49,00 €
Tax: 11,27 €
Grand Total: 60,27 €
I know this is a corner case and that the Grand Totals will be wrong, but how does it get to 11,30€ in taxes?
Also, another case that we found during our module development, is for example:
Three products of 10,65€ (No VAT) + 23% VAT
One product of 10,20€ (No VAT) + 23% VAT
And the end totals are:
Subtotal: 42,16 €
Tax: 9,70 €
Grand Total: 51,85 €
How do can I do my cals right so that I get the same totals?