Uecko_ERP/modules/customer-invoices/src/common/dto/request/create-customer-invoice.command.dto.ts
2025-07-07 20:25:13 +02:00

35 lines
1.6 KiB
TypeScript

import * as z from "zod/v4";
export const CreateCustomerInvoiceCommandSchema = z.object({
id: z.uuid(),
invoice_status: z.string(),
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_code: 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"),
}),
unit_price: 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_code: 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>;