How to Get Gross sale & Net sales 100% accurate data as a Developer?

Hi everyone,

I’m working on a project where I need to fetch Gross Sales and Net Sales data with 100% accuracy as a developer.

Right now, I know I can use the Admin API (REST/GraphQL) to fetch order data and calculate sales, discounts, returns, and taxes on my side. But I’ve also read that sometimes this method may not always give real-time or fully accurate data (for example, when handling refunds, adjustments, or cancellations).

My question is:
:backhand_index_pointing_right: What’s the best practice or recommended approach to get fully accurate Gross Sales and Net Sales numbers directly from Shopify?
:backhand_index_pointing_right: Is there an API or report endpoint that guarantees 100% accurate data, or do developers usually need to build their own calculation logic from order data?

If anyone has experience or examples of how you’ve solved this, it would be really helpful.

Thanks in advance!

1 Like

Hey @Gridline_Dev,

The orders API is going to be the best source of truth here. An example of the following should give you the Gross and Net data you are after.

currentTotalPriceSet:

The total price of the order, after returns, in shop and presentment currencies. This includes taxes and discounts.

subtotalPriceSet:

The sum of the prices for all line items after discounts and before returns, in shop and presentment currencies. If taxesIncluded is true , then the subtotal also includes tax.

You can also use the agreements connection if you need to validate the corresponding sales records.

1 Like

Hey @Gridline_Dev, did the above work for you?

Hi @KyleG-Shopify, any tips for replicating the net/gross sales view over time, shown in Shopify Analytics?

I’ve been building out my analytics app, retailQ, and found its very hard to use the API for:

  • removing gift cards (not counted in analytics), but are included in the totalPriceSet/currentTotalPriceSet
  • splitting refunds into gift card, non-gift card, and shipping (I’m using the refund lines, but felt there should be better way!)
  • partial refunds also seem to completely remove tax and adjust the order instead leading to some strange edge cases (with gross sales of $100, tax of $10, and a refund of $1, net sales will appear as $109)

I’ve managed to find workarounds for these, but it felt more complicated than it should be, so wanted to check!

Hey @David-RetailQ, glad you tagged me here. There’s a new shopifyqlQuery field in Graphql which should help simplify some of your analytics queries.

Thanks @KyleG-Shopify , that looks great. Do you have any guidance on limits to the data we can put through shopifyQL?

I saw this thread which may be a more relevant place to move the discussion shopifyqlQuery with large datasets ? Thanks!

Thanks David. I’m looking in to this and will update that topic you’ve linked once I know more :slight_smile:

1 Like

Hey @David-RetailQ, I was able to get an answer for you. Posted it in this thread here:

Hey @KyleG-Shopify,

the problem with this approach is that you can’t allocate the refunds to the refund dates like you do in accounting.

Do you know how to get things to match, both revenue and refunds (including taxes) when using the refund object?

All the best,

Can you share a little more context on a specific order scenario where you’re unable to get things to match?

Specifically the steps I can take to replicate the inconsistency you see so I can then work back to find a way to get this to match (if possible) using the refund object.