/**
 * Expenses Validators
 *
 * Zod schemas for expense API input validation.
 */

import { z } from 'zod';

export const expenseFiltersSchema = z.object({
  categoryId: z.string().optional(),
  startDate: z.string().optional(),
  endDate: z.string().optional(),
  minAmount: z.coerce.number().optional(),
  maxAmount: z.coerce.number().optional(),
});

export const createExpenseSchema = z.object({
  categoryId: z.string().min(1, 'Category is required'),
  amount: z.number().positive('Amount must be positive'),
  currency: z.string().optional().default('QAR'),
  vendor: z.string().optional(),
  description: z.string().optional(),
  date: z.string().or(z.date()),
  receiptUrl: z.string().url().optional(),
  isRecurring: z.boolean().optional().default(false),
  recurringFrequency: z.string().optional(),
  tags: z.array(z.string()).optional(),
  notes: z.string().optional(),
});

export type ExpenseFilters = z.infer<typeof expenseFiltersSchema>;
export type CreateExpenseInput = z.infer<typeof createExpenseSchema>;
