feat: voucher crud and list
This commit is contained in:
1 parent
73295653ee
commit
660d6cff51
7 files changed
+358
No files matched your search
@@ -0,0 +1,12 @@
|
||||
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" });
|
||||
}
|
||||
Reference in new issue
Block a user