Based on lat9 new PR, I did more testing and tried new code. I got a good 'penny loss' fix that works great on standard orders, no more differences between tax display or not, cart or final invoice. But this is not a final solution, lots need to be testing. Just for those who are interested in testing:
https://github.com/piloujp/zencart/tree/The-Lost-Penny
I am now working on discount coupon but have hard time understanding all options.
My image of coupon is that they are a discounts (fix or percentage) that apply to what customers pay at the end as a deduction. Although there are some that apply only to some items. Validation can be pretty complicated, but Zen cart seems to do it very well.
Where I start to get lost is when looking at 'Admin->Modules->Discount coupons', there are few options that I can't understand very well:
'Include Shipping' in calculation.
Probably used when checking if discount is higher than total, but I am not sure.
'Include Tax' in calculation.
Same as shipping?
'Re-Calculate Tax'
There are three options here:
'None' is easy to understand, nothing is change, tax is as it was before discount.
'Standard', I suppose tax is adjusted to new taxable total. It is pretty straight forward if there is only one tax class that apply to all item including shipping, then new tax should be tax rate x new total without tax. But it is not the case in ZC now, something is wrong in calculation. I did some test with 10% tax and a fix discount coupon, but tax displayed is never 10% of the new total without tax.
'Credit Note', I am not sure what it is, but it is the one that gives results identical to 'none'.
With 'standard' option set, tax calculation if off and final total too. Coupons seems to be treated as an item with price without tax and tax included, but when creating coupons there is only one price. It does not make sense to me to apply tax on coupons. How a shop owner can control what discount he does if tax is applied or not on a discount set in %? Plus a discount is money not paid, how can it be taxed?
There might be some rounding error too, but before trying to fix it, I need to understand what is expected here.
Please, if someone as some light to through on this I would really appreciate.
ZC v2.2.2 PHP 8.4+ MySQL 8.4+