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

export const UpdateCustomerInvoiceByIdParamsRequestSchema = z.object({
  invoice_id: z.string(),
});

export const UpdateCustomerInvoiceByIdRequestSchema = z.object({
  series: z.string().optional(),

  invoice_date: z.string().optional(),
  operation_date: z.string().optional(),

  customer_id: z.uuid().optional(),

  reference: z.string().optional(),
  description: z.string().optional(),
  notes: z.string().optional(),

  language_code: z.string().optional(),
  currency_code: z.string().optional(),

  items: z
    .array(
      z.object({
        is_non_valued: z.string().optional(),

        description: z.string().optional(),
        quantity: QuantitySchema.optional(),
        unit_amount: MoneySchema.optional(),

        discount_percentage: PercentageSchema.optional(),

        tax_codes: z.array(z.string()).default([]),
      })
    )
    .optional()
    .default([]),
});

export type UpdateCustomerInvoiceByIdRequestDTO = Partial<
  z.infer<typeof UpdateCustomerInvoiceByIdRequestSchema>
>;
