import { z } from "zod";

export const ICreateInvoiceRequestSchema = z.object({
  id: z.string().uuid(),
  invoice_number: z.string().min(1),
  invoice_series: z.string().min(1),
  issue_date: z.string().refine((date) => {
    const dateStr = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Invalid YYYY-MM-DD format");
    return dateStr.safeParse(date).success;
  }),
  operation_date: z.string().refine((date) => {
    const dateStr = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Invalid YYYY-MM-DD format");
    return dateStr.safeParse(date).success;
  }),
  //customerId: z.string().uuid(),
  lang_code: z.string().min(1),
  currency_code: z.string().min(1),

  items: z
    .array(
      z.object({
        //id: z.string().uuid(),
        description: z.string().optional(),
        unit_price: z
          .object({
            amount: z.number().positive(),
            scale: z.number().positive(),
          })
          .optional(),
        quantity: z
          .object({
            amount: z.number().positive(),
            scale: z.number().positive(),
          })
          .optional(),
      })
    )
    .optional(),
});

export const IUpdateInvoiceRequestSchema = z.object({});

export const IDeleteInvoiceRequestSchema = z.object({});
