Files
accounted/lib/invoices/posting-account.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

18 lines
831 B
TypeScript

/**
* Canonical shape for a per-line invoice posting-account override: a 4-digit
* BAS class 1-3 account. Single source of truth shared by the server-side Zod
* schemas (lib/api/schemas.ts) and the client-side form schemas
* (ArticleForm, InvoiceEditor) so the two layers cannot drift apart.
*
* Classes 4-8 stay excluded: an invoice line never books to cost, payroll,
* or financial accounts. Class 1-2 (balance-sheet) overrides exist for
* deposits, customer advances, and genuine outlays; they are only bookable
* on zero-VAT lines (enforced server-side in build-invoice-write.ts).
*/
export const INVOICE_POSTING_ACCOUNT_REGEX = /^[123]\d{3}$/
/** True when the account is a balance-sheet account (BAS class 1-2). */
export function isBalanceSheetAccount(account: string): boolean {
return /^[12]/.test(account)
}