feat(settings): rename or re-date an existing räkenskapsår from the fiscal-year list (#2287) (#2337)

* feat(settings): rename or re-date an existing räkenskapsår from the fiscal-year list (#2287)

Inställningar > Bokföring > Räkenskapsår offered Lås, Nollställ and Skapa
nytt räkenskapsår but no way to change the name or dates of a year that
already exists, although PATCH /api/bookkeeping/fiscal-periods/[id] has
supported both (name always on an open year, dates only while the year has
no posted vouchers). The only surface over that route was the first-year
date editor under Företag, so a later or backfilled year saved with the
wrong name or dates (Aisen & Adison AB, #2286) could only be repaired in
the database.

Every open year row now gets a quiet Ändra action opening one dialog
(Namn, Startdatum, Slutdatum) that posts only the changed fields to the
existing route. Dates are read-only with the route's own reason when the
year has posted vouchers (count from the entry-count endpoint); the name
is always editable. Locked and closed years get no Ändra, matching the
route's refusal and the row's chip. Route refusals are shown inline so the
user can correct and retry.

The name follows the dates while it still has the shape fiscalYearName()
produces (new isDerivedFiscalYearName, the inverse predicate next to the
one naming helper): the customer's "Räkenskapsår 2027" corrects itself to
"Räkenskapsår 2022/2023" as the dates are fixed, and a hand-written name is
never overwritten. Saving invalidates ref:fiscal-periods so every picker
updates; the reset dialog's typed confirmation reads the name live from
the reset snapshot, so a rename does not break it.

No route change. New strings in both messages/sv.json and messages/en.json.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019SaJfqNi4VmsG8FMKq99G6

* fix(settings): fiscal-year edit dialog is not dirty on open when the stored name has stray whitespace

"Changed" now compares the raw input with the stored name and sends the
trimmed value only once the user has edited it; before, a stored name with
leading or trailing whitespace enabled Spara on open with a trimmed name
in the payload (CodeRabbit on #2337).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-09-06 18:48:27 +02:00
committed by GitHub
co-authored by Claude Fable 5.1 Jakob Wennberg
parent 162de2128a
commit b2d3a3e273
6 changed files with 352 additions and 1 deletions
+14
View File
@@ -1862,6 +1862,20 @@
"fy_reset_success_description": "{count} vouchers were deleted.",
"fy_reset_failed_title": "The fiscal year could not be reset",
"fy_reset_failed_default": "Something went wrong. No changes were saved.",
"fy_action_edit": "Edit",
"fy_edit_dialog_title": "Edit fiscal year",
"fy_edit_dialog_description": "The name of an open fiscal year can always be changed. The dates can only be changed while no vouchers are posted in the year.",
"fy_edit_name_label": "Name",
"fy_edit_start_label": "Start date",
"fy_edit_end_label": "End date",
"fy_edit_dates_checking": "Checking whether the dates can be changed...",
"fy_edit_dates_blocked_posted": "{count, plural, =1 {# voucher is} other {# vouchers are}} posted in the fiscal year, so the dates cannot be changed. The name can still be changed.",
"fy_edit_dates_check_failed": "Could not check whether the dates can be changed. The name can still be changed.",
"fy_edit_end_before_start": "The end date must be after the start date.",
"fy_edit_save": "Save",
"fy_edit_saving": "Saving...",
"fy_edit_success": "Fiscal year updated",
"fy_edit_failed_default": "Something went wrong. No changes were saved.",
"related_heading": "Related",
"related_chart_of_accounts": "Chart of accounts (BAS)",
"periodisering_label": "Accruals",
+14
View File
@@ -1862,6 +1862,20 @@
"fy_reset_success_description": "{count} verifikat raderades.",
"fy_reset_failed_title": "Räkenskapsåret kunde inte nollställas",
"fy_reset_failed_default": "Något gick fel. Inga ändringar har sparats.",
"fy_action_edit": "Ändra",
"fy_edit_dialog_title": "Ändra räkenskapsår",
"fy_edit_dialog_description": "Namnet på ett öppet räkenskapsår kan alltid ändras. Datumen kan bara ändras så länge inga verifikationer är bokförda i året.",
"fy_edit_name_label": "Namn",
"fy_edit_start_label": "Startdatum",
"fy_edit_end_label": "Slutdatum",
"fy_edit_dates_checking": "Kontrollerar om datumen kan ändras...",
"fy_edit_dates_blocked_posted": "{count, plural, =1 {# bokförd verifikation finns} other {# bokförda verifikationer finns}} i räkenskapsåret, så datumen kan inte ändras. Namnet går fortfarande att ändra.",
"fy_edit_dates_check_failed": "Kunde inte kontrollera om datumen kan ändras. Namnet går fortfarande att ändra.",
"fy_edit_end_before_start": "Slutdatum måste vara efter startdatum.",
"fy_edit_save": "Spara",
"fy_edit_saving": "Sparar...",
"fy_edit_success": "Räkenskapsåret är uppdaterat",
"fy_edit_failed_default": "Något gick fel. Inga ändringar har sparats.",
"related_heading": "Relaterat",
"related_chart_of_accounts": "Kontoplan (BAS)",
"periodisering_label": "Periodisering",