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

37 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-06-24 18:38:57 +00:00
import * as z from "zod/v4";
2025-08-12 11:23:50 +00:00
export const CreateCustomerInvoiceRequestSchema = z.object({
2025-07-07 18:25:13 +00:00
id: z.uuid(),
invoice_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" }),
2025-07-16 15:47:45 +00:00
description: z.string(),
2025-06-24 18:38:57 +00:00
language_code: z.string().min(2, "Language code must be at least 2 characters long"),
2025-07-07 18:25:13 +00:00
currency_code: z.string().min(3, "Currency code must be at least 3 characters long"),
2025-07-16 15:47:45 +00:00
notes: z.string().optional(),
2025-06-24 18:38:57 +00:00
items: z.array(
z.object({
description: z.string().min(1, "Item description is required"),
quantity: z.object({
2025-09-04 10:02:24 +00:00
value: z.number().positive("Quantity amount must be positive"),
2025-06-24 18:38:57 +00:00
scale: z.number().int().nonnegative("Quantity scale must be a non-negative integer"),
}),
2025-09-04 10:02:24 +00:00
unit_amount: z.object({
value: z.number().positive("Unit price amount must be positive"),
2025-06-24 18:38:57 +00:00
scale: z.number().int().nonnegative("Unit price scale must be a non-negative integer"),
2025-07-07 18:25:13 +00:00
currency_code: z
.string()
.min(3, "Unit price currency code must be at least 3 characters long"),
2025-06-24 18:38:57 +00:00
}),
2025-09-04 10:02:24 +00:00
discount_percentage: z.object({
value: z.number().nonnegative("Discount amount cannot be negative"),
2025-06-24 18:38:57 +00:00
scale: z.number().int().nonnegative("Discount scale must be a non-negative integer"),
}),
})
),
});
2025-08-12 11:23:50 +00:00
export type CreateCustomerInvoiceRequestDTO = z.infer<typeof CreateCustomerInvoiceRequestSchema>;