//#region src/depreciation.d.ts /** * @classytic/tax-core/depreciation — the contract a country implements for INCOME-TAX depreciation * (capital allowances): its classes and rates, the facts it asks the accountant to confirm, and the * year-by-year schedule of one asset including what its sale gives rise to. * * Derived, never stored: a schedule is a pure function of register facts and the regime's dated rules, * so the same facts always give the same figures and nothing can drift from the register. A regime that * pools assets (a block of assets, a capital-allowance pool) declares `basis: 'pool'`; only `'asset'` is * served today, and a pool regime is refused rather than computed per asset. */ /** A class the law depreciates at one rate on one basis. */ interface TaxDepreciationClass { key: string; label: string; /** Where the law states it — `Third Schedule Part 1 para 4 item 12`. */ item?: string | undefined; ratePercent?: number | undefined; /** Regime-defined (`written-down-value`, `straight-line`, …). */ basis: string; } /** Register facts about one asset, in integer minor units. */ interface TaxAssetFacts { id: string; /** The register category; the regime derives the class from it unless `taxClass` is set. */ category?: string | undefined; taxClass?: string | undefined; firstUsedOn: Date; /** Purchase price, without the later additions listed below. */ cost: number; additions: ReadonlyArray<{ on: Date; amount: number; }>; /** Sold or otherwise disposed of: `proceeds` is the sale price net of any VAT on the sale. */ disposal?: { on: Date; proceeds: number; } | undefined; /** Taken out of use without a sale. */ retired?: boolean | undefined; /** The accountant's answers to the regime's {@link TaxTreatmentQuestion}s, keyed by question key. */ answers: Readonly>; } /** One allowance in a year — a regime may give several (initial, normal, annual investment…). */ interface TaxAllowance { kind: string; label: string; amount: number; } /** What a sale gives rise to for tax, beyond the year's allowance. */ interface TaxDisposalOutcome { kind: 'balancing-charge' | 'balancing-loss' | 'capital-gain' | (string & {}); label: string; amount: number; /** Where the law states it. */ sourceRef: string; } interface TaxDepreciationRow { /** The regime's own year label — `2026-27`, `2026`. */ year: string; openingWrittenDownValue: number; additions: number; allowances: readonly TaxAllowance[]; /** What the return claims for the year's allowances. */ deductible: number; closingWrittenDownValue: number; disposal?: { proceeds: number; outcomes: readonly TaxDisposalOutcome[]; } | undefined; /** Where the regime assumed, capped or refused something — for the accountant to read. */ notes: readonly string[]; } interface TaxDepreciationSchedule { taxClass: TaxDepreciationClass; /** The class was the regime's residual one for a category its law does not name. */ residualClass: boolean; rows: readonly TaxDepreciationRow[]; } /** A fact the regime asks the accountant to confirm — rendered by a UI that knows no country. */ interface TaxTreatmentQuestion { key: string; label: string; help?: string | undefined; /** `money` is integer minor units; `year` is a regime year label. */ kind: 'boolean' | 'percent' | 'money' | 'year' | 'group'; /** `group` only: its fields, all required together. */ fields?: readonly TaxTreatmentQuestion[] | undefined; /** Asked only for these classes. Absent: every class. */ classes?: readonly string[] | undefined; /** Asked only for an asset first used before this date (e.g. a value brought forward from an older law). */ firstUsedBefore?: Date | undefined; /** Asked only once the asset has been sold (e.g. its market value at the sale). */ onlyWhenDisposed?: boolean | undefined; /** The value assumed when the accountant has not answered — always the one that claims less. */ default?: unknown; } /** A refusal: the rules cannot compute this asset as stated. The message says what is missing. */ declare class TaxDepreciationUnsupportedError extends Error { constructor(message: string); } interface TaxDepreciationRegime { /** `BD-ITA-2023`. Stored with an accountant's answers, so answers given under one regime are never read by another. */ id: string; /** ISO 3166-1 alpha-2. */ jurisdiction: string; basis: 'asset' | 'pool'; /** The law, in a line — shown with every report. */ sourceRef: string; /** The tax year a date falls in, by its label. */ yearOf(date: Date): string; /** The last instant of a tax year — where its closing values are compared with the books. */ yearEnd(year: string): Date; /** Labels from `from` through `to` inclusive; throws `RangeError` on a label the regime does not write. */ yearsBetween(from: string, to: string): readonly string[]; listClasses(asOf: Date): readonly TaxDepreciationClass[]; classOfCategory(category: string | undefined): { key: string; residual: boolean; }; questions(asOf: Date): readonly TaxTreatmentQuestion[]; /** First use through `throughYear`, stopping at the year of disposal. Throws {@link TaxDepreciationUnsupportedError}. */ schedule(facts: TaxAssetFacts, throughYear: string): TaxDepreciationSchedule; } /** Answers that do not match the questions: unknown keys, wrong kinds, a percent out of (0, 100]. Empty when valid. */ declare function checkTaxTreatmentAnswers(questions: readonly TaxTreatmentQuestion[], answers: Readonly>, regime: Pick): string[]; /** Structural checks every regime must pass — run it in the pack's own tests. Empty when it conforms. */ declare function taxDepreciationRegimeConformance(regime: TaxDepreciationRegime, asOf: Date): string[]; //#endregion export { TaxAllowance, TaxAssetFacts, TaxDepreciationClass, TaxDepreciationRegime, TaxDepreciationRow, TaxDepreciationSchedule, TaxDepreciationUnsupportedError, TaxDisposalOutcome, TaxTreatmentQuestion, checkTaxTreatmentAnswers, taxDepreciationRegimeConformance };