import { NumericStringSchema, PercentageSchema } from "@erp/core";
import { z } from "zod/v4";

export const CreateCustomerInvoiceItemRequestSchema = z.object({
  id: z.uuid(),
  position: z.string(),
  description: z.string().default(""),
  quantity: NumericStringSchema.default(""),
  unit_amount: NumericStringSchema.default(""),
  discount_percentage: NumericStringSchema.default(""),
  taxes: z.string().default(""),
});

export const CreateCustomerInvoiceRequestSchema = z.object({
  id: z.uuid(),

  invoice_number: z.string(),
  series: z.string().default(""),

  invoice_date: z.string(),
  operation_date: z.string().default(""),

  customer_id: z.uuid(),

  notes: z.string().default(""),

  language_code: z.string().toLowerCase().default("es"),
  currency_code: z.string().toUpperCase().default("EUR"),

  discount_percentage: PercentageSchema.default({
    value: "0",
    scale: "2",
  }),

  items: z.array(CreateCustomerInvoiceItemRequestSchema).default([]),
});

export type CreateCustomerInvoiceItemRequestDTO = z.infer<
  typeof CreateCustomerInvoiceItemRequestSchema
>;
export type CreateCustomerInvoiceRequestDTO = z.infer<typeof CreateCustomerInvoiceRequestSchema>;
