export type VoucherInput = { name: string; anbieter: string; wertCents: number; restCents: number; ablaufdatum: string | null; codeText?: string | null; kategorie?: string | null; notiz?: string | null; }; export function validateVoucher(v: VoucherInput): string[] { const errs: string[] = []; if (!v.name?.trim()) errs.push("name"); if (!v.anbieter?.trim()) errs.push("anbieter"); if (!Number.isInteger(v.wertCents) || v.wertCents <= 0) errs.push("wertCents"); if (!Number.isInteger(v.restCents) || v.restCents < 0 || v.restCents > v.wertCents) errs.push("restCents"); return errs; } export function formatEuro(cents: number): string { return (cents / 100).toLocaleString("de-DE", { style: "currency", currency: "EUR" }); }