Which discount amount is correct for product sale TotalAmount Calculation

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?

1 Like

Hey @SRCB,

Can you check the shops tax settings? What you are seeing looks like what would be expected depending on if taxes are included in the product prices or not. https://shopify.dev/docs/api/admin-graphql/latest/queries/shop#returns-Shop.fields.taxesIncluded

I’ll take a look soon, but if I remember correctly this happens even within the same shop.

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.