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

export const ListCustomerInvoicesResponseSchema = createPaginatedListSchema(
  z.object({
    id: z.uuid(),
    company_id: z.uuid(),
    is_proforma: z.boolean(),

    customer_id: z.string(),

    invoice_number: z.string(),
    status: z.string(),
    series: z.string(),

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

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

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

    recipient: z.object({
      tin: z.string(),
      name: z.string(),
      street: z.string(),
      street2: z.string(),
      city: z.string(),
      postal_code: z.string(),
      province: z.string(),
      country: z.string(),
    }),

    taxes: z.string(),

    subtotal_amount: MoneySchema,
    discount_percentage: PercentageSchema,
    discount_amount: MoneySchema,
    taxable_amount: MoneySchema,
    taxes_amount: MoneySchema,
    total_amount: MoneySchema,

    metadata: MetadataSchema.optional(),
  })
);

export type ListCustomerInvoicesResponseDTO = z.infer<typeof ListCustomerInvoicesResponseSchema>;
