The documentation on ProductSale for the totalAmount field says as follows
The total sale amount after taxes and discounts.
From what I understand, this means that totalAmount = Sale amount - Discounts + taxes.
However, there are 2 fields for discounts on Product sale, there is totalDiscountAmountAfterTaxes, and there is totalDiscountAmountBeforeTaxes. After some testing, I have found that most of the time Discounts in the totalAmount calculation, uses totalDiscountAmountBeforeTaxes, however the calculation sometimes uses totalDiscountAmountAfterTaxes. Is there a way to see which one is the correct one to use for the calculation?
Interesting. I’m curious to see what you find. Double check the product and customer tax settings as well to see if there are other specific exemptions.
I have been using the order’s taxesIncluded in order to calculate the sale amount for a while without any issues. I guess I’ll need to use to calculate the discount amount as well.