import { z } from 'zod';

export const LedgerEntryTypeSchema = z.enum(['debit', 'credit']);

export const LedgerEntrySchema = z.object({
  id: z.string().uuid(),
  accountId: z.string().uuid(),
  type: LedgerEntryTypeSchema,
  amount: z.number().positive(),
  currency: z.string().length(3),
  description: z.string().optional(),
  reference: z.string().optional(),
  createdAt: z.date().or(z.string().datetime()),
});

export type LedgerEntry = z.infer<typeof LedgerEntrySchema>;

export const CreateLedgerEntrySchema = LedgerEntrySchema.omit({
  id: true,
  createdAt: true,
});

export type CreateLedgerEntry = z.infer<typeof CreateLedgerEntrySchema>;

