Files
accounted/lib/bookkeeping/booking-template-schemas.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

25 lines
971 B
TypeScript

import { z } from 'zod'
import { PACK_CATEGORIES, PACK_ENTITY_TYPES } from '@/lib/packs/schema'
/**
* Request-body schemas shared by the booking-template routes
* (/api/settings/booking-templates, its [id] and import siblings).
*
* The category / entity_type enums mirror `booking_template_library`'s CHECK
* constraints via the pack contract. The line schema is deliberately looser
* than `PackLineSchema`: user templates may carry both `ratio` and `vat_rate`
* on a line, which the pack validator rejects.
*/
export const BookingTemplateLineSchema = z.object({
account: z.string().regex(/^\d{4}$/),
label: z.string().min(1),
side: z.enum(['debit', 'credit']),
type: z.enum(['business', 'vat', 'settlement']),
ratio: z.number().min(0).max(10).optional(),
vat_rate: z.number().min(0).max(1).optional(),
})
export const BookingTemplateCategorySchema = z.enum(PACK_CATEGORIES)
export const BookingTemplateEntityTypeSchema = z.enum(PACK_ENTITY_TYPES)