Skip to content

ADR-0002. DiscriminationType as authoritative tax classification (dual-write taxTypeId)

FieldValue
StatusAccepted
Date2026-04-15
Deciderstaxation-team
Supersedes

Context

  • The system has a generic DiscriminationType classifier (scopes for inventory, finance, license, and tax_classification).
  • The legacy TaxType entity in the pricing schema also classified taxes (000_VAT, 400_PIT, ...), duplicating that concept.
  • TaxGroupItem and Tax need one classification source; existing pricing/calculation code still reads Tax.taxTypeId.
  • We want a single, scope-partitioned catalogue without breaking pricing immediately.

Decision

TaxGroupItem.discriminationTypeId and Tax.discriminationTypeId (both notNull) are the authoritative tax classification. During provisioning we dual-write: each Tax keeps the new discriminationTypeId and the legacy taxTypeId (nullable) so existing pricing reads continue to work. Discrimination types under scope tax_classification are seeded by taxation-0001-seed-discrimination-types.ts.

Consequences

ProsCons
Single classifier catalogue across domainsTwo columns to keep aligned during the transition
Tax.taxTypeId stays nullable — no hard break for pricingReconciliation logic needed to map DiscriminationType → TaxType
New tax classes added via discrimination seeds, not schemaTaxType table lingers until pricing migrates fully

Alternatives Considered

OptionProsConsWhy rejected
Keep TaxType onlyNo migrationDuplicate classifier concept; no cross-domain reuseDiverges from DiscriminationType strategy
Drop taxTypeId immediatelyClean schemaBreaks pricing reads in-flightToo risky without coordinated pricing change
Separate tax-only classifier tableFocusedYet another classifier; same duplication problemReuse beats new table

References

  • packages/core/src/models/schemas/tax/tax-group-item/schema.ts (discriminationTypeId)
  • packages/core/src/models/schemas/pricing/tax/schema.ts (taxTypeId nullable + discriminationTypeId)
  • packages/core/src/models/schemas/public/discrimination-type/constants.ts:DiscriminationTypeScopes.TAX_CLASSIFICATION
  • packages/taxation/src/services/tax-provisioning.service.ts (dual-write loop)
  • packages/taxation/src/migrations/processes/taxation-0001-seed-discrimination-types.ts

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.