Sales Tax Presets and Line Calculation¶
Preset behavior¶
SalesTaxPreset stores jurisdiction defaults by country and region.
Seeded defaults include all Canadian provinces and territories:
AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT
Preset resolution order¶
If Tax Mode =
Manual, manual rates are used.If Tax Mode =
Autoand preset is selected on the invoice, preset rates are used.If Tax Mode =
Autoand no preset is selected, the system searches active presets byship_to_country_code+ship_to_region_code.If no preset matches, fallback defaults are used (for Canada/US only).
Line-level (Xero-style) calculation¶
Tax is computed per line and rounded per line item to two decimals, then summed. This matches common accounting behavior where line-level rounding may differ from single-document rounding.
Algorithm summary:
Build invoice lines from
ItemTransactionModelplus optional Shipping line.Allocate invoice-level discount proportionally across taxable lines.
For each line: *
taxable_line_amount = line_amount - allocated_discount*line_tax = round(taxable_line_amount * tax_rate, 2)Sum all line tax components for totals.
Tax-exempt items¶
Any item with item_model.additional_info["sales_tax_exempt"] = true is
treated as non-taxable in this flow.