workspace_pk), making this effectively a 1-to-1 extension of the Workspace entity. The row is created by the onboarding/setup flow (seed or WorkspaceService) and subsequently updated either by the user via PUT /v1/workspaces/:id/accounting-settings or automatically by WorkspaceSelfIdentityService when invoice-extraction consensus is reached. It anchors the workspace’s fiscal identity (base currency, country, accounting framework, business registration details) and configures two LedgerAccount defaults used by the journal-entry posting engine.
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_accounting_settings_id: generated via gen_random_uuid() at insert; client must not supply this value.
- created_at: set by MikroORM onCreate hook at insert time; never overwritten.
- updated_at: set by MikroORM onCreate hook at insert and by onUpdate hook on every subsequent flush.
- deleted_at: written only by soft-delete logic; never set via the upsert API path.
- Row creation: WorkspaceService.setupWorkspace() creates the initial row via WorkspaceAccountingSettingsRepository.persist() during workspace onboarding. WorkspaceAccountingSettingsService.upsertByWorkspace() handles all subsequent writes (find-or-create semantics — it creates the row if absent).
- Identity field auto-population: WorkspaceSelfIdentityService applies an N=2 consensus rule over WorkspaceIdentityExtraction rows before committing values (registered_name, tax_id_value, tax_id_type, registered_value, domain, trade_name, base_currency, country, accounting_framework) to this table automatically.
- accounting_framework PostgreSQL enum retains the deprecated ‘MAR’ value (removed from application code; cannot be dropped via ALTER TYPE). Any pre-existing ‘MAR’ rows were migrated to ‘IFRS’ by Migration20260409200000.
- Tolerance defaults: invoice_status_tolerance_pct defaults to 0.0100 (1%); invoice_status_tolerance_abs defaults to 0.50. Both are application-layer defaults that align with InvoiceStatusRecomputeService plan §4.3 caps.
Example
apps/api/src/database/entities/WorkspaceAccountingSettings.ts · domain: financial-graph · tier: Infrastructure