Unable to replicate analytics report through Graphiql - specifically Gross Sales for lineitem

One of the standard reports within Shopify is “Total Sales by Order” which gives amongst other things for each line item:

Gross Sales - The price of the item excluding VAT and any Discounts

Net Sales - The price of the item excluding VAT but with discounts applied

Taxes - The VAT on the lineitem

Specifically where a discount of 10% has been applied to an order through a voucher code I can get the following through Graphiql:

Original Price including VAT (OriginalTotalSet)

The discount including VAT (AllocatedDiscount)

The VAT paid (Taxlines → PriceSet)

So I can get Net Sales (The price of the item excluding VAT but with discounts applied) by:

OriginalTotalSet - AllocatedDiscount - Taxlines-PriceSet

But I can’t work out how to get Gross Sales for that line item, ie the original price ex vat.

I did try simply dividing by unit price by the VAT rate of 20% but this is giving me rounding errors when compared with shopify as sometimes Shopify will round up and sometimes down depending on how it’s treating the VAT on that line. I really need Shopify’s view of the ex-tax rate for the lineitem.

It’s for accounting purposes so needs to be accurate to the nearest penny.

Any help appreciated.

You might consider asking this on Shopify’s developer community forum, since it’s an API question:

https://community.shopify.dev/

If you make a post there, please link it here. I’m also interested in hopefully hearing Shopify potentially explain how they decide whether to round prices up or down.