//#region src/ledger.d.ts /** * @classytic/tax-core/ledger — the ledger-facing tax data shapes. * * What actually composes across jurisdictions is not tax COMPUTATION * (BD VAT, CA GST/HST, US sales tax share no math) — it's the * POSTING-SHAPED OUTPUT: a tax code with rate/direction/repartition, and * a report template whose grid lines the codes reference. This is the * Odoo `account.tax` insight, kept as pure data. * * History: these types were defined twice — in `@classytic/ledger-bd` and * `@classytic/ledger-ca`, each carrying a "will eventually move to the * tax package" note after `@classytic/ledger@0.7.0` deliberately dropped * tax from the accounting core. This is that move: country packs now * re-export from here. */ /** * One leg of a tax amount's split across accounts/report grids. A simple * VAT collects 100% into one payable account; reverse-charge and * multi-agency taxes (CA GST+QST, IN CGST+SGST) split across several. */ interface TaxRepartitionLine { /** Fraction of the tax amount on this leg (1 = 100%). */ readonly factor: number; /** Logical account role the leg posts to — 'collected', 'recoverable', 'transition', … */ readonly accountRole: string; /** Report-template grid line this leg reports on. */ readonly gridCode?: string | number | undefined; /** Display label for the leg. */ readonly label?: string | undefined; /** Restrict the leg to specific document types (default: all). */ readonly documentTypes?: readonly ('invoice' | 'refund' | 'payment')[] | undefined; } /** When the tax becomes payable: on invoice (accrual) or on payment (cash basis). */ type TaxExigibility = 'accrual' | 'cash'; /** A selectable tax treatment — the row a UI shows and a document line references. */ interface TaxCode { /** Stable identifier — 'BD-VAT-15', 'CA-GST', 'CA-HST-ON'. */ readonly code: string; readonly name: string; /** Country vocabulary — 'VAT', 'GST', 'HST', 'PST', 'TDS', 'TOT', 'SD', 'VDS', … */ readonly taxType: string; /** Decimal fraction (0.15 = 15%). 0 for fixed-amount or zero-rate codes. */ readonly rate: number; /** Which way the money flows relative to the taxpayer. */ readonly direction: 'collected' | 'recoverable' | 'paid'; /** Region/province scope — 'National', 'ON', 'QC'. */ readonly province?: string | undefined; /** Report-template lines this code aggregates into. */ readonly reportLines?: readonly number[] | undefined; readonly description: string; readonly active: boolean; /** Multi-leg split; omitted = single leg at factor 1 to the natural role. */ readonly repartition?: readonly TaxRepartitionLine[] | undefined; readonly exigibility?: TaxExigibility | undefined; } /** Region → applicable tax-code ids (single-rate countries map every region to the same list). */ interface TaxCodesByRegion { readonly [region: string]: readonly string[]; } /** One line of a periodic-return template (Mushak 9.1, GST34, VAT100). */ interface TaxReportLine { readonly line: number | string; readonly name: string; readonly description: string; /** 'input' = aggregated from postings, 'calculated' = derived, 'manual' = filed-by-hand. */ readonly type: 'input' | 'calculated' | 'manual'; /** Derivation for 'calculated' lines, over the full line-value map. */ readonly calculate?: ((data: Record) => number) | undefined; readonly section: string; } /** A periodic-return template: lines + the calculation/summary passes over them. */ interface TaxReportTemplate { readonly name: string; readonly lines: Readonly>; calculate(inputData: Record, manualData?: Record): Record; summarize(calculated: Record): Record; } //#endregion export { TaxCode, TaxCodesByRegion, TaxExigibility, TaxRepartitionLine, TaxReportLine, TaxReportTemplate };