Trouble understanding Gross sale calculation in line items

Please help me with how gross sale money is calculated in the line items of below order. It seems service charge is included in the line item total money. I need to calculate gross sale of this order by category of products excluding service charges.

{
  "id": "35YSTWrGiSf4bsm3aqgbTpoeV",
  "locationId": "CFDK8M711RK8S",
  "lineItems": [
   {
    "uid": "3996EC26-BC36-4411-B1F2-6CAD9CDA1522",
    "name": "Brunch Burrito",
    "quantity": "1",
    "note": "Bacon ",
    "catalogObjectId": "ZNGAZRDU2ZLWDAHNOV26C6B6",
    "catalogVersion": 1655060034893,
    "variationName": "Regular",
    "itemType": "ITEM",
    "appliedTaxes": [
     {
      "uid": "1E3F6FFB-240B-48C4-9DBB-2E078B1BE4C7",
      "taxUid": "6EA4845A-2E21-4C5F-BA26-6E4D83AF0EC7",
      "appliedMoney": {
       "amount": 60,
       "currency": "USD"
      }
     }
    ],
    "basePriceMoney": {
     "amount": 600,
     "currency": "USD"
    },
    "variationTotalPriceMoney": {
     "amount": 600,
     "currency": "USD"
    },
    "grossSalesMoney": {
     "amount": 715,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 60,
     "currency": "USD"
    },
    "totalDiscountMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 711,
     "currency": "USD"
    }
   },
   {
    "uid": "1F090EC9-3B9A-41CB-82DF-6EBAF0B2A2D2",
    "name": "Coffee",
    "quantity": "1",
    "catalogObjectId": "VX37HMUB5ZPAY33RHRLFXOE5",
    "catalogVersion": 1654272643355,
    "variationName": "Regular",
    "itemType": "ITEM",
    "modifiers": [
     {
      "uid": "D588D381-68DC-4D47-A1AC-210A9ED372EC",
      "catalogObjectId": "BFX75LGOBJVWOTUDFWFWJRHG",
      "catalogVersion": 1601392006087,
      "name": "Hot",
      "quantity": "1",
      "basePriceMoney": {
       "amount": 0,
       "currency": "USD"
      },
      "totalPriceMoney": {
       "amount": 0,
       "currency": "USD"
      }
     }
    ],
    "appliedTaxes": [
     {
      "uid": "FA871FB0-1992-469A-B784-7ADB6D89B7CE",
      "taxUid": "6EA4845A-2E21-4C5F-BA26-6E4D83AF0EC7",
      "appliedMoney": {
       "amount": 35,
       "currency": "USD"
      }
     }
    ],
    "basePriceMoney": {
     "amount": 350,
     "currency": "USD"
    },
    "variationTotalPriceMoney": {
     "amount": 350,
     "currency": "USD"
    },
    "grossSalesMoney": {
     "amount": 465,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 35,
     "currency": "USD"
    },
    "totalDiscountMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 415,
     "currency": "USD"
    }
   },
   {
    "uid": "D5805745-63D6-4D28-B76E-2F11419A7E68",
    "name": "Plain Waffle",
    "quantity": "1",
    "catalogObjectId": "OMAI567NVGTTGEGUA3UG7ZOU",
    "catalogVersion": 1654445276341,
    "variationName": "Regular",
    "itemType": "ITEM",
    "appliedTaxes": [
     {
      "uid": "7D14F087-5ACF-4507-B8AE-19142E1827B3",
      "taxUid": "6EA4845A-2E21-4C5F-BA26-6E4D83AF0EC7",
      "appliedMoney": {
       "amount": 39,
       "currency": "USD"
      }
     }
    ],
    "basePriceMoney": {
     "amount": 395,
     "currency": "USD"
    },
    "variationTotalPriceMoney": {
     "amount": 395,
     "currency": "USD"
    },
    "grossSalesMoney": {
     "amount": 510,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 39,
     "currency": "USD"
    },
    "totalDiscountMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 468,
     "currency": "USD"
    }
   }
  ],
  "taxes": [
   {
    "uid": "6EA4845A-2E21-4C5F-BA26-6E4D83AF0EC7",
    "catalogObjectId": "LN7JOYZXU45W4NVU7XY24QSE",
    "catalogVersion": 1602802401911,
    "name": "Sales Tax",
    "type": "ADDITIVE",
    "percentage": "10",
    "appliedMoney": {
     "amount": 134,
     "currency": "USD"
    },
    "scope": "LINE_ITEM"
   }
  ],
  "serviceCharges": [
   {
    "uid": "EC62E189-17C2-4B0C-816D-1365575858CD",
    "name": "Bagging fee",
    "catalogObjectId": "BVEDWWWXXSTGEWWHS5K2KI7A",
    "catalogVersion": 1655166702061,
    "amountMoney": {
     "amount": 75,
     "currency": "USD"
    },
    "appliedMoney": {
     "amount": 75,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 75,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "calculationPhase": "APPORTIONED_AMOUNT_PHASE",
    "taxable": false,
    "type": "CUSTOM"
   },
   {
    "uid": "4BE73DBE-7957-4B08-ACC1-459B8AE001EC",
    "name": "Credit card processing fee ",
    "catalogObjectId": "PHE675YBPPWB2YYUVFI7C2FG",
    "catalogVersion": 1655220964580,
    "percentage": "3",
    "appliedMoney": {
     "amount": 40,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 40,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "calculationPhase": "APPORTIONED_PERCENTAGE_PHASE",
    "taxable": false,
    "type": "CUSTOM"
   }
  ],
  "returnAmounts": {},
  "netAmounts": {
   "totalMoney": {
    "amount": 1881,
    "currency": "USD"
   },
   "taxMoney": {
    "amount": 134,
    "currency": "USD"
   },
   "discountMoney": {
    "amount": 0,
    "currency": "USD"
   },
   "tipMoney": {
    "amount": 287,
    "currency": "USD"
   },
   "serviceChargeMoney": {
    "amount": 115,
    "currency": "USD"
   }
  },
  "tenders": [
   {
    "id": "RAo22jiL3BBzEK9KH8iKK4QJvaB",
    "locationId": "CFDK8M711RK8S",
    "transactionId": "35YSTWrGiSf4bsm3aqgbTpoeV",
    "createdAt": "2022-06-19T18:55:59Z",
    "amountMoney": {
     "amount": 1881,
     "currency": "USD"
    },
    "tipMoney": {
     "amount": 287,
     "currency": "USD"
    },
    "processingFeeMoney": {
     "amount": 59,
     "currency": "USD"
    },
    "type": "CARD"
    }
  ],
  "createdAt": "2022-06-19T18:56:08Z",
  "updatedAt": "2022-06-19T18:56:08Z",
  "closedAt": "2022-06-19T18:56:08Z",
  "state": "COMPLETED",
  "totalMoney": {
   "amount": 1881,
   "currency": "USD"
  },
  "totalTaxMoney": {
   "amount": 134,
   "currency": "USD"
  },
  "totalDiscountMoney": {
   "amount": 0,
   "currency": "USD"
  },
  "totalTipMoney": {
   "amount": 287,
   "currency": "USD"
  },
  "totalServiceChargeMoney": {
   "amount": 115,
   "currency": "USD"
  },
  "square_product": [
   "SQUARE_POS"
  ]
 }

@josh-square @Bryan-Square Guys, I hope you won’t mind that I am tagging you directly here. I found similar issue for this customer again.

Gross sale sum for first line item is 1225 as per grossSalesMoney. But it should be 1195. I guess that Square is including service charge of 30 on this one. But then question is why it is not applied on second line item. Service charge type is APPORTIONED_PERCENTAGE_PHASE. It shows up as 3%. On what amount this 3% is applied, so it becomes 30?

Could you please help?

  "id": "P154QkM96VEoY8xldadqNdqeV",
  "locationId": "CFDK8M711RK8S",
  "lineItems": [
   {
    "uid": "997851BA-DF58-4B89-A5D1-AA531F31B8D7",
    "name": "Caesar Burrito",
    "quantity": "1",
    "catalogObjectId": "FG5B57VW4JXU3LJMYHKPNDYW",
    "catalogVersion": 1661894354819,
    "variationName": "Regular",
    "itemType": "ITEM",
    "appliedTaxes": [
     {
      "uid": "81039480-CCAD-4B24-A1EF-95634E0E3E56",
      "taxUid": "41973615-4316-45D9-88CE-35C30B183D78",
      "appliedMoney": {
       "amount": 102,
       "currency": "USD"
      }
     }
    ],
    "appliedDiscounts": [
     {
      "uid": "6932E599-5606-4F0D-8504-8761A08A4EE3",
      "discountUid": "107981D3-B782-4A3B-8B2C-DB5F0F2805E3",
      "appliedMoney": {
       "amount": 179,
       "currency": "USD"
      }
     }
    ],
    "basePriceMoney": {
     "amount": 1195,
     "currency": "USD"
    },
    "variationTotalPriceMoney": {
     "amount": 1195,
     "currency": "USD"
    },
    "grossSalesMoney": {
     "amount": 1225,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 102,
     "currency": "USD"
    },
    "totalDiscountMoney": {
     "amount": 179,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 1148,
     "currency": "USD"
    }
   },
   {
    "uid": "17D43021-9E24-4DC5-A626-C714153B55AE",
    "name": "Caesar Burrito",
    "quantity": "1",
    "catalogObjectId": "FG5B57VW4JXU3LJMYHKPNDYW",
    "catalogVersion": 1661894354819,
    "variationName": "Regular",
    "itemType": "ITEM",
    "appliedTaxes": [
     {
      "uid": "1FFE695D-9BB5-462F-9F87-E9273BE8C137",
      "taxUid": "41973615-4316-45D9-88CE-35C30B183D78",
      "appliedMoney": {
       "amount": 119,
       "currency": "USD"
      }
     }
    ],
    "basePriceMoney": {
     "amount": 1195,
     "currency": "USD"
    },
    "variationTotalPriceMoney": {
     "amount": 1195,
     "currency": "USD"
    },
    "grossSalesMoney": {
     "amount": 1195,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 119,
     "currency": "USD"
    },
    "totalDiscountMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 1314,
     "currency": "USD"
    }
   }
  ],
  "taxes": [
   {
    "uid": "41973615-4316-45D9-88CE-35C30B183D78",
    "catalogObjectId": "LN7JOYZXU45W4NVU7XY24QSE",
    "catalogVersion": 1602802401911,
    "name": "Sales Tax",
    "type": "ADDITIVE",
    "percentage": "10",
    "appliedMoney": {
     "amount": 221,
     "currency": "USD"
    },
    "scope": "LINE_ITEM"
   }
  ],
  "discounts": [
   {
    "uid": "107981D3-B782-4A3B-8B2C-DB5F0F2805E3",
    "name": "15% off any item in 6 qualifying categories (up to $20.00 of…",
    "type": "FIXED_PERCENTAGE",
    "percentage": "15",
    "appliedMoney": {
     "amount": 179,
     "currency": "USD"
    },
    "scope": "LINE_ITEM"
   }
  ],
  "serviceCharges": [
   {
    "uid": "0C04E6D0-41E0-4599-B8C5-B4D462E4CEF4",
    "name": "Credit card processing fee ",
    "catalogObjectId": "PHE675YBPPWB2YYUVFI7C2FG",
    "catalogVersion": 1655220964580,
    "percentage": "3",
    "appliedMoney": {
     "amount": 30,
     "currency": "USD"
    },
    "totalMoney": {
     "amount": 30,
     "currency": "USD"
    },
    "totalTaxMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "calculationPhase": "APPORTIONED_PERCENTAGE_PHASE",
    "taxable": false,
    "type": "CUSTOM"
   }
  ],
  "returnAmounts": {},
  "netAmounts": {
   "totalMoney": {
    "amount": 2462,
    "currency": "USD"
   },
   "taxMoney": {
    "amount": 221,
    "currency": "USD"
   },
   "discountMoney": {
    "amount": 179,
    "currency": "USD"
   },
   "tipMoney": {
    "amount": 0,
    "currency": "USD"
   },
   "serviceChargeMoney": {
    "amount": 30,
    "currency": "USD"
   }
  },
  "tenders": [
   {
    "id": "xswzKtU2WzBDPgRT6qxoRfrYvaB",
    "locationId": "CFDK8M711RK8S",
    "transactionId": "P154QkM96VEoY8xldadqNdqeV",
    "createdAt": "2022-10-05T17:06:22Z",
    "amountMoney": {
     "amount": 2462,
     "currency": "USD"
    },
    "tipMoney": {
     "amount": 0,
     "currency": "USD"
    },
    "processingFeeMoney": {
     "amount": 74,
     "currency": "USD"
    },
    "customerId": "P6F61MH1390YH7JKW0C41ERBAR",
    "type": "CARD",
    "cardDetails": {
     "status": "CAPTURED",
     "card": {
      "cardBrand": "VISA",
      "last4": "5542",
      "fingerprint": "sq-1-98dsR2zycsjO4DUzrBW4xGEYwGQNvgKhwC13xZkPrvbPVjlzHUc9lyq1qDQpYurX5A"
     },
     "entryMethod": "EMV"
    },
    "payment": {
     "id": "xswzKtU2WzBDPgRT6qxoRfrYvaB",
     "createdAt": "2022-10-05T17:06:24.247Z",
     "updatedAt": "2022-10-05T17:06:29.445Z",
     "amountMoney": {
      "amount": 2462,
      "currency": "USD"
     },
     "totalMoney": {
      "amount": 2462,
      "currency": "USD"
     },
     "approvedMoney": {
      "amount": 2462,
      "currency": "USD"
     },
     "processingFee": [
      {
       "effectiveAt": "2022-10-05T19:06:27.000Z",
       "type": "INITIAL",
       "amountMoney": {
        "amount": 74,
        "currency": "USD"
       }
      }
     ],
     "status": "COMPLETED",
     "sourceType": "CARD",
     "cardDetails": {
      "status": "CAPTURED",
      "card": {
       "cardBrand": "VISA",
       "last4": "5542",
       "expMonth": 1,
       "expYear": 2025,
       "cardholderName": "CROOK/VANCE ",
       "fingerprint": "sq-1-98dsR2zycsjO4DUzrBW4xGEYwGQNvgKhwC13xZkPrvbPVjlzHUc9lyq1qDQpYurX5A",
       "cardType": "CREDIT",
       "prepaidType": "NOT_PREPAID",
       "bin": "414709"
      },
      "entryMethod": "EMV",
      "cvvStatus": "CVV_NOT_CHECKED",
      "avsStatus": "AVS_NOT_CHECKED",
      "authResultCode": "08739C",
      "applicationIdentifier": "A0000000031010",
      "applicationName": "CAPITAL ONE VISA",
      "applicationCryptogram": "7ddaeb1e5fefae7b",
      "verificationMethod": "SIGNATURE",
      "verificationResults": "UNKNOWN",
      "statementDescription": "SQ *HEIRLOOM TACO",
      "deviceDetails": {
       "deviceId": "DEVICE_INSTALLATION_ID:844E6804-5B5D-491A-9F15-485540C11B2D",
       "deviceInstallationId": "844E6804-5B5D-491A-9F15-485540C11B2D",
       "deviceName": "iPad"
      },
      "cardPaymentTimeline": {
       "authorizedAt": "2022-10-05T17:06:24.725Z",
       "capturedAt": "2022-10-05T17:06:27.481Z"
      }
     },
     "locationId": "CFDK8M711RK8S",
     "orderId": "P154QkM96VEoY8xldadqNdqeV",
     "employeeId": "TMEpWJJSXFYUD9gj",
     "teamMemberId": "TMEpWJJSXFYUD9gj",
     "receiptNumber": "xswz",
     "receiptUrl": "https://squareup.com/receipt/preview/xswzKtU2WzBDPgRT6qxoRfrYvaB",
     "deviceDetails": {
      "deviceId": "DEVICE_INSTALLATION_ID:844E6804-5B5D-491A-9F15-485540C11B2D",
      "deviceInstallationId": "844E6804-5B5D-491A-9F15-485540C11B2D",
      "deviceName": "iPad"
     },
     "applicationDetails": {
      "squareProduct": "SQUARE_POS"
     },
     "versionToken": "hKk4Sp5KvAxl2G3L1dXfwMV7Ogap6NA5Ze1XSU95dWU6o"
    }
   }
  ],
  "createdAt": "2022-10-05T17:06:26Z",
  "updatedAt": "2022-10-05T17:06:26Z",
  "closedAt": "2022-10-05T17:06:26Z",
  "state": "COMPLETED",
  "totalMoney": {
   "amount": 2462,
   "currency": "USD"
  },
  "totalTaxMoney": {
   "amount": 221,
   "currency": "USD"
  },
  "totalDiscountMoney": {
   "amount": 179,
   "currency": "USD"
  },
  "totalTipMoney": {
   "amount": 0,
   "currency": "USD"
  },
  "totalServiceChargeMoney": {
   "amount": 30,
   "currency": "USD"
  },
  "square_product": [
   "SQUARE_POS"
  ]
 }

@Bryan-Square I’ve the same issue for which I can provide you the Order Id as well.

After exploring a lot, found that Tax can be of 2 types ADDITIVE or INCLUSIVE.
INCLUSIVE are the one already added within the gross-sales-amount, while ADDITIVE are additional tax, which will get added into the gross-sales.

But, I’ve few orders where Tax type is INCLUSIVE only and still it’s not deducted that tax amount from gross-amount into the order line item.

Could you please confirm us the exact way of calculating gross_amount from line-item or say from/for the order.

Whats the order_ids where the tax type is INCLUSIVE? :slightly_smiling_face:

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?

Whats the order_id that you can’t calculate the gross sales? :slightly_smiling_face:

Thanks for your reply @Bryan-Square

So here you can check the 2 attached screenshots.

1st one is a report for the date range 1st Feb to 17th Feb for a specific vendor, and the report for the same is matching the square report.

Hi @sumit-qahammer what are we looking at here? Am I supposed to look into something here? If so what are the Square generated IDs that need to be looked into and what discrepancy are you seeing? :slightly_smiling_face:

Hello @Bryan-Square

So this forum not allowing to add/post big content here, that’s why I sent the same on slack. You can check the details and order ids here.

Slack

Thanks, taking a look. :slightly_smiling_face: