Uecko_ERP/modules/customer-invoices/src/common/dto/request/create-customer-invoice.command.dto.ts

33 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-06-24 18:38:57 +00:00
import * as z from "zod/v4";
export const CreateCustomerInvoiceCommandSchema = z.object({
id: z.string().uuid(),
2025-06-26 11:32:55 +00:00
status: z.string(),
2025-06-24 18:38:57 +00:00
invoice_number: z.string().min(1, "Customer invoice number is required"),
invoice_series: z.string().min(1, "Customer invoice series is required"),
issue_date: z.string().datetime({ offset: true, message: "Invalid issue date format" }),
operation_date: z.string().datetime({ offset: true, message: "Invalid operation date format" }),
language_code: z.string().min(2, "Language code must be at least 2 characters long"),
currency: z.string().min(3, "Currency code must be at least 3 characters long"),
items: z.array(
z.object({
description: z.string().min(1, "Item description is required"),
quantity: z.object({
amount: z.number().positive("Quantity amount must be positive"),
scale: z.number().int().nonnegative("Quantity scale must be a non-negative integer"),
}),
unitPrice: z.object({
amount: z.number().positive("Unit price amount must be positive"),
scale: z.number().int().nonnegative("Unit price scale must be a non-negative integer"),
currency: z.string().min(3, "Unit price currency code must be at least 3 characters long"),
}),
discount: z.object({
amount: z.number().nonnegative("Discount amount cannot be negative"),
scale: z.number().int().nonnegative("Discount scale must be a non-negative integer"),
}),
})
),
});
export type CreateCustomerInvoiceCommandDTO = z.infer<typeof CreateCustomerInvoiceCommandSchema>;