feat(parties): fill customer and supplier forms from the register on a valid org number (#2355)

The registry lookup was built for rows that already exist (the detail
page's "Hämta uppgifter" records facts on the row's party), so on the
create form people typed what SCB already knew. Org number now comes
first in both forms; a complete, check-digit valid number of a Swedish
legal person is looked up once and fills name, address, postal code,
city (and the VAT number where the form shows one) wherever nothing has
been typed. A typed value is never replaced; a corrected number replaces
only its own earlier fill. A personnummer never reaches the register
(client key and server gate), and an environment without SCB credentials
answers 503 once and the form stays quiet.

- GET /api/parties/registry?org_number=: read-only route over the same
  SCB client, credential gate and registrySummary reader as the enrich
  route; writes nothing.
- lib/parties/registry-form-fill.ts: registryLookupKey (one rule for
  what may be looked up) and registryFormFill (contactFill's untouched
  rule plus name and VAT number), pure and tested.
- components/parties/use-registry-autofill.ts + RegistryAutofillNote:
  debounced, once per distinct number, skips the number an edit dialog
  opened with, one muted line under the field.
- Adressrad 2 is now an input on both forms: the register's c/o goes on
  line 1 with the street on line 2, as on the row, and both edit dialogs
  already passed the column in.


Claude-Session: https://claude.ai/code/session_01LvMaHcTnwAfxzgYD1fGYX1

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 21:03:06 +02:00
committed by GitHub
co-authored by Jakob Wennberg Claude Fable 5.1
parent 3b9daf2606
commit fcda4a75dd
11 changed files with 837 additions and 105 deletions
+16 -4
View File
@@ -1299,7 +1299,9 @@
"submit_save": "Save customer",
"submit_saving": "Saving...",
"viewer_disabled_tooltip": "You only have viewer access in this company",
"personal_number_unreadable": "The stored personal number cannot be read. Enter it again to replace it."
"personal_number_unreadable": "The stored personal number cannot be read. Enter it again to replace it.",
"address_line2_label": "Address line 2",
"address_line2_placeholder": "c/o"
},
"form_supplier": {
"name_label": "Name *",
@@ -1345,7 +1347,9 @@
"notes_placeholder": "Internal notes about the supplier...",
"submit_save": "Save supplier",
"submit_saving": "Saving...",
"viewer_disabled_tooltip": "You only have viewer access in this company"
"viewer_disabled_tooltip": "You only have viewer access in this company",
"address_line2_label": "Address line 2",
"address_line2_placeholder": "c/o"
},
"initial_setup": {
"completed_verdict": "Your bookkeeping is up and running.",
@@ -8823,8 +8827,16 @@
"open_dossier": "Open {name}",
"attn_create": "Create suggestions",
"auto_created_title": "{count} suggestions created from the books",
"auto_created_description": "Counterparts your vouchers name that are not in the register. Add them, or hide the ones that do not belong here."
},
"auto_created_description": "Counterparts your vouchers name that are not in the register. Add them, or hide the ones that do not belong here.",
"autofill_looking": "Searching the SCB business register…",
"autofill_filled": "{name} · {fields} from SCB. Edit freely.",
"autofill_found": "{name} according to the SCB register. Nothing changed, the fields were already filled in.",
"autofill_not_found": "No company with org. no. {org} in the SCB register.",
"autofill_field_name": "name",
"autofill_field_email": "email",
"autofill_field_phone": "phone",
"autofill_field_vat": "VAT number"
},
"tx_expense_payout_match": {
"title": "Book expense reimbursement",
"description": "The transfer is booked against the person's liability account, the claims are marked as paid and the transaction is linked to the voucher.",
+16 -4
View File
@@ -1299,7 +1299,9 @@
"submit_save": "Spara kund",
"submit_saving": "Sparar...",
"viewer_disabled_tooltip": "Du har endast läsbehörighet i detta företag",
"personal_number_unreadable": "Det sparade personnumret kan inte läsas. Skriv in det igen för att ersätta det."
"personal_number_unreadable": "Det sparade personnumret kan inte läsas. Skriv in det igen för att ersätta det.",
"address_line2_label": "Adressrad 2",
"address_line2_placeholder": "c/o"
},
"form_supplier": {
"name_label": "Namn *",
@@ -1345,7 +1347,9 @@
"notes_placeholder": "Interna anteckningar om leverantören...",
"submit_save": "Spara leverantör",
"submit_saving": "Sparar...",
"viewer_disabled_tooltip": "Du har endast läsbehörighet i detta företag"
"viewer_disabled_tooltip": "Du har endast läsbehörighet i detta företag",
"address_line2_label": "Adressrad 2",
"address_line2_placeholder": "c/o"
},
"initial_setup": {
"completed_verdict": "Bokföringen är igång.",
@@ -8823,8 +8827,16 @@
"open_dossier": "Öppna {name}",
"attn_create": "Skapa förslag",
"auto_created_title": "{count} förslag skapade från bokföringen",
"auto_created_description": "Motparter som dina verifikat namnger men som inte finns i registret. Lägg upp dem, eller dölj de som inte hör hemma här."
},
"auto_created_description": "Motparter som dina verifikat namnger men som inte finns i registret. Lägg upp dem, eller dölj de som inte hör hemma här.",
"autofill_looking": "Söker i SCB:s företagsregister…",
"autofill_filled": "{name} · {fields} från SCB. Ändra fritt.",
"autofill_found": "{name} enligt SCB:s register. Inget ändrat, fälten var redan ifyllda.",
"autofill_not_found": "Inget företag med org.nr {org} i SCB:s register.",
"autofill_field_name": "namn",
"autofill_field_email": "e-post",
"autofill_field_phone": "telefon",
"autofill_field_vat": "momsnummer"
},
"tx_expense_payout_match": {
"title": "Bokför återbetalning av utlägg",
"description": "Överföringen bokförs mot personens skuldkonto, utläggen markeras som utbetalda och transaktionen kopplas till verifikatet.",