feat(bookkeeping): edit & customize booking templates in GUI (#704)

* feat(bookkeeping): edit & customize booking templates in GUI

Make bokföringsmallar editable from /settings/templates and surface the
ratio (Andel) field, addressing two user requests.

- Refactor CreateTemplateForm into a shared TemplateForm (create / edit /
  duplicate) reusing the existing POST and PUT routes.
- Add an Edit (pencil) action on company/team templates, and an Anpassa
  (customize) action on read-only "Standard" templates that forks a
  company-scoped copy — letting a company override the standard 1930
  settlement account with e.g. 1920 without mutating the shared template.
- Show the ratio field progressively (only when a template splits across
  more than one cost line), with an InfoTooltip, a non-blocking
  "shares must sum to 1.0" warning, and a live "1 000 kr" split preview.
- Add settings_booking_templates i18n keys in both sv and en.

Frontend-only: no API, schema, type, or migration changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(bookkeeping): show ratio input on cost lines only

Addresses PR review: the Andel input also appeared on settlement lines
when a template had multiple cost lines, but settlement ratios don't feed
the "shares sum to 1.0" check or balance validation. Restrict the editable
ratio to cost/revenue lines; the settlement leg (full counter-amount) is
shown in the live preview instead. No behavior change to applyTemplate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-06-10 13:20:26 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent c0b006fcc1
commit 21cfcbe180
3 changed files with 269 additions and 26 deletions
+13 -1
View File
@@ -1305,7 +1305,19 @@
"vat_rate_6": "6%",
"vat_rate_0": "0% (export/reverse-charge/exempt)",
"unconvertible_hint": "This template can't be picked directly when booking a transaction — it's used from a journal entry. To appear in the transaction list, it needs exactly one cost/revenue line and one settlement line on opposite sides.",
"unconvertible_badge": "Journal entries only"
"unconvertible_badge": "Journal entries only",
"ratio_label": "Share",
"ratio_help": "Share of the total amount booked on this line. The shares should sum to 1.0.",
"ratio_sum_warning": "The shares for cost lines do not sum to 1.0.",
"preview_label": "Preview for 1,000 kr",
"edit": "Edit",
"edit_dialog_title": "Edit template",
"customize": "Customize",
"customize_dialog_title": "Customize standard template",
"copy_name_suffix": "{name} (customized)",
"save_button": "Save",
"toast_updated": "Template saved",
"duplicate_name_warning": "A template with this name already exists."
},
"settings_counterparty_templates": {
"title": "Bookkeeping templates",
+13 -1
View File
@@ -1305,7 +1305,19 @@
"vat_rate_6": "6 %",
"vat_rate_0": "0 % (export/omvänd/momsfri)",
"unconvertible_hint": "Den här mallen kan inte väljas direkt vid bokföring av en transaktion — den används från ett verifikat. För att visas i transaktionslistan krävs exakt en kostnads-/intäktsrad och en betalningsrad på motsatt sida.",
"unconvertible_badge": "Endast i verifikat"
"unconvertible_badge": "Endast i verifikat",
"ratio_label": "Andel",
"ratio_help": "Andel av totalbeloppet som bokförs på raden. Summan av andelarna ska bli 1,0.",
"ratio_sum_warning": "Andelarna för kostnadsrader summerar inte till 1,0.",
"preview_label": "Förhandsvisning för 1 000 kr",
"edit": "Redigera",
"edit_dialog_title": "Redigera mall",
"customize": "Anpassa",
"customize_dialog_title": "Anpassa standardmall",
"copy_name_suffix": "{name} (anpassad)",
"save_button": "Spara",
"toast_updated": "Mallen sparades",
"duplicate_name_warning": "Det finns redan en mall med det här namnet."
},
"settings_counterparty_templates": {
"title": "Bokföringsmallar",