2025-09-22 17:43:55 +00:00
|
|
|
import * as z from "zod/v4";
|
|
|
|
|
|
2025-09-23 17:21:16 +00:00
|
|
|
export const CustomerFormSchema = z.object({
|
2025-09-22 17:43:55 +00:00
|
|
|
reference: z.string().optional(),
|
|
|
|
|
|
2025-09-24 10:34:04 +00:00
|
|
|
is_company: z.string().default("true"),
|
2025-09-23 11:48:19 +00:00
|
|
|
name: z
|
|
|
|
|
.string({
|
|
|
|
|
error: "El nombre es obligatorio",
|
|
|
|
|
})
|
|
|
|
|
.min(1, "El nombre no puede estar vacío"),
|
2025-09-22 17:43:55 +00:00
|
|
|
trade_name: z.string().optional(),
|
|
|
|
|
tin: z.string().optional(),
|
2025-09-23 11:48:19 +00:00
|
|
|
default_taxes: z.array(z.string()).default([]),
|
2025-09-22 17:43:55 +00:00
|
|
|
|
|
|
|
|
street: z.string().optional(),
|
|
|
|
|
street2: z.string().optional(),
|
|
|
|
|
city: z.string().optional(),
|
|
|
|
|
province: z.string().optional(),
|
|
|
|
|
postal_code: z.string().optional(),
|
2025-09-23 11:48:19 +00:00
|
|
|
country: z
|
|
|
|
|
.string({
|
|
|
|
|
error: "El país es obligatorio",
|
|
|
|
|
})
|
|
|
|
|
.min(1, "El país no puede estar vacío")
|
|
|
|
|
.toLowerCase() // asegura minúsculas
|
|
|
|
|
.default("es"),
|
2025-09-22 17:43:55 +00:00
|
|
|
|
|
|
|
|
email_primary: z.string().optional(),
|
|
|
|
|
email_secondary: z.string().optional(),
|
|
|
|
|
phone_primary: z.string().optional(),
|
|
|
|
|
phone_secondary: z.string().optional(),
|
|
|
|
|
mobile_primary: z.string().optional(),
|
|
|
|
|
mobile_secondary: z.string().optional(),
|
|
|
|
|
|
|
|
|
|
fax: z.string().optional(),
|
|
|
|
|
website: z.string().optional(),
|
|
|
|
|
|
|
|
|
|
legal_record: z.string().optional(),
|
|
|
|
|
|
2025-09-23 11:48:19 +00:00
|
|
|
language_code: z
|
|
|
|
|
.string({
|
|
|
|
|
error: "El idioma es obligatorio",
|
|
|
|
|
})
|
|
|
|
|
.min(1, "Debe indicar un idioma")
|
|
|
|
|
.toUpperCase() // asegura mayúsculas
|
|
|
|
|
.default("es"),
|
|
|
|
|
|
|
|
|
|
currency_code: z
|
|
|
|
|
.string({
|
|
|
|
|
error: "La moneda es obligatoria",
|
|
|
|
|
})
|
|
|
|
|
.min(1, "La moneda no puede estar vacía")
|
|
|
|
|
.toUpperCase() // asegura mayúsculas
|
|
|
|
|
.default("EUR"),
|
2025-09-22 17:43:55 +00:00
|
|
|
});
|
|
|
|
|
|
2025-09-23 17:21:16 +00:00
|
|
|
export type CustomerFormData = z.infer<typeof CustomerFormSchema>;
|
2025-09-22 17:43:55 +00:00
|
|
|
|
2025-09-23 17:21:16 +00:00
|
|
|
export const defaultCustomerFormData: CustomerFormData = {
|
2025-09-22 17:43:55 +00:00
|
|
|
reference: "",
|
|
|
|
|
|
2025-09-23 11:48:19 +00:00
|
|
|
is_company: "true",
|
2025-09-22 17:43:55 +00:00
|
|
|
name: "",
|
|
|
|
|
trade_name: "",
|
|
|
|
|
tin: "",
|
2025-09-23 11:48:19 +00:00
|
|
|
default_taxes: ["iva_21"],
|
2025-09-22 17:43:55 +00:00
|
|
|
|
|
|
|
|
street: "",
|
|
|
|
|
street2: "",
|
|
|
|
|
city: "",
|
|
|
|
|
province: "",
|
|
|
|
|
postal_code: "",
|
|
|
|
|
country: "es",
|
|
|
|
|
|
|
|
|
|
email_primary: "",
|
|
|
|
|
email_secondary: "",
|
|
|
|
|
phone_primary: "",
|
|
|
|
|
phone_secondary: "",
|
|
|
|
|
mobile_primary: "",
|
|
|
|
|
mobile_secondary: "",
|
|
|
|
|
|
|
|
|
|
fax: "",
|
|
|
|
|
website: "",
|
|
|
|
|
|
|
|
|
|
legal_record: "",
|
|
|
|
|
language_code: "es",
|
|
|
|
|
currency_code: "EUR",
|
|
|
|
|
};
|