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:
co-authored by
Jakob Wennberg
Claude Fable 5.1
parent
3b9daf2606
commit
fcda4a75dd
@@ -4248,6 +4248,16 @@ export const PartySearchRegistryQuerySchema = z.object({
|
||||
q: z.string().max(120).optional(),
|
||||
})
|
||||
|
||||
/**
|
||||
* GET /api/parties/registry: the org number a customer or supplier form is
|
||||
* being filled for. Shape, check digit and the legal-person rule are one
|
||||
* function (registryLookupKey in lib/parties/registry-form-fill), so the
|
||||
* form and the route cannot disagree about what may be looked up.
|
||||
*/
|
||||
export const PartyRegistryLookupQuerySchema = z.object({
|
||||
org_number: z.string().trim().min(1).max(20),
|
||||
})
|
||||
|
||||
export const PartyUndoMergeSchema = z.object({
|
||||
decisionId: uuid,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user