Skip to main content

Tax Calculation

warning

Tax amounts must be calculated by applying the tax percentage to the sum of all receipt line totals for that tax type, not by summing per-line tax calculations. Summing per-line taxes introduces rounding differences that will cause validation errors.

When ReceiptLinesTaxInclusive is true

  • LineTotal values already include tax
  • SalesAmountWithTax = sum of LineTotal for all lines with this tax type
  • TaxAmount = SalesAmountWithTax - round(SalesAmountWithTax / (1 + TaxPercent/100), 2)
  • TotalAmount must equal the sum of all LineTotal values

When ReceiptLinesTaxInclusive is false

  • LineTotal values are pre-tax amounts
  • TaxAmount = round(sum of LineTotal for this tax type × TaxPercent/100, 2)
  • SalesAmountWithTax = sum of LineTotal for this tax type + TaxAmount
  • TotalAmount must equal the sum of all LineTotal values plus the sum of all TaxAmount values

Rounding

Rounding uses MidpointRounding.ToEven (banker's rounding) to 2 decimal places.

Totals Cross-Check

TotalAmount must also equal the sum of all SalesAmountWithTax values across all tax entries.