Files
accounted/lib/bookkeeping/create-account-prefill.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

23 lines
863 B
TypeScript

/**
* Split the search string an account picker was showing when the user reached
* for "Skapa konto" into AddAccountDialog's two prefill props.
*
* The combobox hands over whatever was typed, which is either a partial/full
* account number ("8022") or a name fragment ("andelar i dotterföretag").
* Feeding a name into initialAccountNumber would be silently dropped by the
* dialog's digits-only filter, and feeding a number into initialAccountName
* would put "8022" in the name field.
*/
export interface CreateAccountPrefill {
initialAccountNumber?: string
initialAccountName?: string
}
export function splitCreateAccountPrefill(prefill: string): CreateAccountPrefill {
const trimmed = prefill.trim()
if (!trimmed) return {}
return /^\d{1,4}$/.test(trimmed)
? { initialAccountNumber: trimmed }
: { initialAccountName: trimmed }
}