import { objectId } from '@jig-software/zod-bson';
import { z } from 'zod';
import { LeaveType } from './LeaveType';

export const LeaveTransaction = z.object({
  _id: objectId(),
  _prevId: objectId().optional(), // For unique index to prevent conflicts.
  leaveType: LeaveType,
  amount: z.number(),
  balance: z.number(),
  remarks: z.string().nullish(),
  grantedTo: objectId(),
  grantedBy: objectId().nullish(),
  createdAt: z.date(),
});

export type LeaveTransaction = z.infer<typeof LeaveTransaction>;
