fix(invoices): keep the stored ROT/RUT personnummer when editing a draft (#1186)

Fixes #1175. The stored personnummer exists only as AES-256-GCM
ciphertext (+ last4), so the editor cannot rehydrate it and sent an
empty string; buildInvoiceWriteData then failed ROT/RUT validation and
every edit of a draft deduction invoice was blocked with "Personnummer
krävs för ROT/RUT-avdrag" unless the user re-entered the customer's
personnummer.

buildInvoiceWriteData accepts the stored ciphertext from the update
path: an empty field on an invoice that still has deduction lines
means keep, a typed value replaces, and removing every deduction line
clears as before. The editor hint shows the kept last4 in edit mode
(new i18n key, sv+en).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-25 12:59:50 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 731a57dd6e
commit 5afd031306
6 changed files with 107 additions and 5 deletions
+1
View File
@@ -2914,6 +2914,7 @@
"deduction_personnummer_label": "Personal identity number (personnummer)",
"deduction_personnummer_placeholder": "YYYYMMDD-NNNN",
"deduction_personnummer_hint": "Encrypted before storage. Only the last four digits are shown on the invoice.",
"deduction_personnummer_kept_hint": "The saved personal number (****{last4}) is kept if the field is left empty. Enter one only to replace it.",
"deduction_housing_label": "Property designation (fastighetsbeteckning)",
"deduction_housing_placeholder": "e.g. Stockholm Vasastan 1:23",
"deduction_housing_hint": "Required for ROT deductions (not needed for RUT).",
+1
View File
@@ -2914,6 +2914,7 @@
"deduction_personnummer_label": "Personnummer",
"deduction_personnummer_placeholder": "ÅÅÅÅMMDD-NNNN",
"deduction_personnummer_hint": "Krypteras innan lagring. Endast de fyra sista siffrorna visas på fakturan.",
"deduction_personnummer_kept_hint": "Sparat personnummer (****{last4}) behålls om fältet lämnas tomt. Fyll i endast för att byta.",
"deduction_housing_label": "Fastighetsbeteckning",
"deduction_housing_placeholder": "t.ex. Stockholm Vasastan 1:23",
"deduction_housing_hint": "Krävs för ROT-avdrag (RUT behöver inte detta fält).",