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
LineTotalvalues already include taxSalesAmountWithTax= sum ofLineTotalfor all lines with this tax typeTaxAmount=SalesAmountWithTax- round(SalesAmountWithTax/ (1 + TaxPercent/100), 2)TotalAmountmust equal the sum of allLineTotalvalues
When ReceiptLinesTaxInclusive is false
LineTotalvalues are pre-tax amountsTaxAmount= round(sum ofLineTotalfor this tax type × TaxPercent/100, 2)SalesAmountWithTax= sum ofLineTotalfor this tax type +TaxAmountTotalAmountmust equal the sum of allLineTotalvalues plus the sum of allTaxAmountvalues
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.