How to calculate net sales

I calculated “Net sales” until now according to the following formula
“Net sales” = “Number(originalUnitPriceSet.shopMoney.amount) - discounts - taxLines”,
And I was getting the wrong results

I searched and found that I was wrong about the formula
I saw the correct formula here

https://www.shopify.com/retail/net-sales
that to calculate, I need the following fields
Net sales = Gross sales - Discounts - Sales returns - Allowances
I need help. How do I bring them into the API

Hi @hmjeh1

If you’re working on a Plus store with an app that has access to the ShopifyQL orders dataset you can look up net sales totals there.

Otherwise, the GraphQL Order object holds multiple fields relating to it’s corresponding transactions, discounts, etc.

Hope that helps.