Skip to main content
WorkspacePostingMapping encodes a single posting rule that maps a semantic document context (CoA version, semantic role, posting kind, document polarity) to accounting targets (LedgerAccount, TaxRate, Journal) for a workspace. The posting engine writes these rows deterministically or via LLM review; the rule-resolver reads them at journal-entry draft time to auto-classify postings. Each row is scoped to a Workspace and optionally to a specific WorkspaceConnector, with precision modifiers for tax behaviour, counterparty kind, currency, country code, and effective date range. A partial unique index (WHERE deleted_at IS NULL AND mapping_status = ‘active’) prevents duplicate active mappings for the same context tuple.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • workspace_posting_mapping_id — generated via gen_random_uuid() on insert, exposed as the public API id
  • created_at — set automatically by the MikroORM onCreate hook; never writable after creation
  • updated_at — set automatically by the MikroORM onUpdate hook on every write
  • deleted_at — soft-delete field written by the posting engine on rule retirement; not writable by users
  • mapping_status — managed exclusively by the posting engine (transitions: active → needs_review → inactive or active → deleted_at); default ‘active’ on creation
  • mapping_version — incremented by the posting engine on each rule revision; default 1
  • created_by — set at creation time by the engine to record provenance (‘deterministic’, ‘reviewed_llm’) or set to ‘manual’ for human-authored rules; not subsequently editable
  • confidence — computed and stamped by the LLM jury or deterministic scoring logic; null for fully-deterministic rules
  • evidence — populated by the engine with the reasoning payload from the mapping generation run
  • sourceWorkspaceConnector provenance — when set, records which connector sync triggered the mapping creation; ON DELETE SET NULL ensures orphan safety on connector removal
  • Partial unique index workspace_posting_mappings_active_context_unique (WHERE deleted_at IS NULL AND mapping_status = ‘active’) — enforced at the DB layer only; cannot be expressed via MikroORM decorators (COALESCE expressions + partial predicate). The entity comment documents this divergence from schema:fresh.

Example

Source: apps/api/src/database/entities/WorkspacePostingMapping.ts · domain: financial-graph · tier: Infrastructure