Trouble understanding Gross sale calculation in line items

I just need a confirmation on this to make sure I’m using the correct method and it will not break in future.

So there can be 2 types of taxes in an Order, Inclusive and Additive.

If the TotalGrossAmount is same as TotalBaseAmount, then in such scenario to get the actual gross, reduce the Inclusive tax from gross_price.

This work for me and my reports matching with the SquareUp reports with this adjustment in code-base.

But still for few dates the gross-sales mis-match. Can you provide all the parameters which we need to consider while calculating the gross-sales?

Square formula to calculate the gross-sales?