feat(dimensions): PR10 advanced — custom dimensions, hierarchy, account rules, commit enforcement (#886)
* feat(dimensions): PR10 advanced — custom dimensions, hierarchy, account rules, commit enforcement The final rung of the dimensions ladder (dev_docs/dimensions_implementation_plan.md §7 row 10): - custom dimensions: POST /api/dimensions creates registry dims (next free SIE number >= 20 when omitted; explicit numbers allowed — SIE import already mints reserved ones); register gets a 'Ny dimension' dialog with a quiet Avancerat disclosure for the #UNDERDIM parent; GET now carries parent_sie_dim_no (the column + SIE round-trip existed since PR1/PR5 — this exposes it) - account_dimension_rules (migration 20260703120000): one rule per (account, dimension) — required / default / fixed, per-rule is_active, company-scoped RLS, composite FK to the registry, value-presence CHECK - enforcement, opt-in BY CONSTRUCTION (zero rules = engine byte-identical; deliberately NO settings toggle — a rule that exists but is ignored is worse than either extreme): default/fixed apply onto line bags at draft creation (fixed overwrites, default fills); required asserts at commitEntry with a Swedish MANDATORY_DIMENSION_MISSING naming every account + dimension; the bulk-book route runs the same policy before its RPC; storno/correction paths never pass through commitEntry so history always reverses regardless of policy; rule fetches fail open incl. thrown exceptions - chart of accounts: per-account Dimensionsregler section in EditAccountDialog (Krävs/Förval/Låst, value picker, pause switch), gated on the existing dimensions toggle, quiet when empty - pickers: LineDimensionFields is registry-driven (one combobox per active dimension, cached fetch, hardcoded 1/6 fallback) — every existing mount lights up custom dims with zero changes - agent briefing: per-dimension required_on_accounts/default_on_accounts so agents self-correct instead of bouncing off the policy error - rules CRUD API with existence/active/company validation and qualified DTO ids; firm_id FK deferred until the firms table lands (per plan) 39 new tests (pure-fn rules, engine enforcement, both new API surfaces, pg-real RLS/CHECK/cascade suite); full suite 6,791 green; migration replayed on a fresh container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: renumber migration to 20260703200000 — version collision with prod The concurrent session shipped pending_operations_add_link_document_to_voucher as 20260703120000 today; the Supabase preview branch (cloned from prod) rejected the duplicate version key. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: review round — auto-pick retry on collision, fail-open warnings, query schema - POST /api/dimensions retries once past a concurrent number claim when the number was auto-picked (explicit choices still 409) - every fail-open skip of the dimension-rules policy now logs a structured warning (engine draft/commit paths + bulk-book) — deliberate fail-open, but observable - GET /api/dimensions/rules validates its query through ListDimensionRulesQuerySchema instead of an inline regex Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
70e893b8d4
commit
764348e99c
+15
-1
@@ -3477,7 +3477,21 @@
|
||||
"settings_imported_toast": "{count, plural, one {1 existing code was imported} other {# existing codes were imported}}",
|
||||
"settings_import_failed_title": "Could not import existing codes",
|
||||
"settings_save_failed_title": "Could not save the setting",
|
||||
"settings_open_register": "Open cost centres & projects"
|
||||
"settings_open_register": "Open cost centres & projects",
|
||||
"new_dimension": "New dimension",
|
||||
"new_dimension_title": "New dimension",
|
||||
"dim_form_name_invalid": "Enter a name (1–60 characters).",
|
||||
"dim_form_number_label": "Number",
|
||||
"dim_form_number_help": "Leave empty for the next free number (20+). SIE reserves 1–19.",
|
||||
"dim_form_number_invalid": "Enter a whole number of 20 or higher.",
|
||||
"dim_form_resets_label": "Resets every fiscal year",
|
||||
"dim_form_resets_help": "Balances per value start over at a new fiscal year.",
|
||||
"dim_form_advanced": "Advanced",
|
||||
"dim_form_parent_label": "Parent dimension",
|
||||
"dim_form_parent_none": "None",
|
||||
"dim_form_parent_help": "Makes the new dimension a subdimension (SIE #UNDERDIM) of the selected one.",
|
||||
"dim_created_title": "Dimension created",
|
||||
"subdimension_of": "Subdimension of {parent}"
|
||||
},
|
||||
"tic_workspace": {
|
||||
"toast_settings_failed": "Could not fetch settings",
|
||||
|
||||
+15
-1
@@ -3477,7 +3477,21 @@
|
||||
"settings_imported_toast": "{count, plural, one {1 befintlig kod importerades} other {# befintliga koder importerades}}",
|
||||
"settings_import_failed_title": "Kunde inte importera befintliga koder",
|
||||
"settings_save_failed_title": "Kunde inte spara inställningen",
|
||||
"settings_open_register": "Öppna kostnadsställen & projekt"
|
||||
"settings_open_register": "Öppna kostnadsställen & projekt",
|
||||
"new_dimension": "Ny dimension",
|
||||
"new_dimension_title": "Ny dimension",
|
||||
"dim_form_name_invalid": "Ange ett namn (1–60 tecken).",
|
||||
"dim_form_number_label": "Nummer",
|
||||
"dim_form_number_help": "Lämna tomt för nästa lediga (20+). SIE reserverar 1–19.",
|
||||
"dim_form_number_invalid": "Ange ett heltal, 20 eller högre.",
|
||||
"dim_form_resets_label": "Nollställs varje räkenskapsår",
|
||||
"dim_form_resets_help": "Saldon per värde börjar om vid nytt räkenskapsår.",
|
||||
"dim_form_advanced": "Avancerat",
|
||||
"dim_form_parent_label": "Överordnad dimension",
|
||||
"dim_form_parent_none": "Ingen",
|
||||
"dim_form_parent_help": "Gör den nya dimensionen till en underdimension (SIE #UNDERDIM) av den valda.",
|
||||
"dim_created_title": "Dimension skapad",
|
||||
"subdimension_of": "Underdimension till {parent}"
|
||||
},
|
||||
"tic_workspace": {
|
||||
"toast_settings_failed": "Kunde inte hämta inställningar",
|
||||
|
||||
Reference in New Issue
Block a user