Adding some changes in Recurring Schema.
This commit is contained in:
parent
0372991ac1
commit
cb0ed03525
@ -1,65 +1,16 @@
|
||||
import { boolean, z } from "zod";
|
||||
import { INR_CURRENCY_CODE } from "../../utils/constants";
|
||||
|
||||
// export const PaymentRecurringExpense = (expenseTypes) => {
|
||||
// return z
|
||||
// .object({
|
||||
// title: z.string().min(1, { message: "Project is required" }),
|
||||
|
||||
// description: z.string().min(1, { message: "Description is required" }),
|
||||
|
||||
// payee: z.string().min(1, { message: "Supplier name is required" }),
|
||||
|
||||
// notifyTo: z.string().min(1, { message: "Notification is required" }),
|
||||
|
||||
// currencyId: z
|
||||
// .string()
|
||||
// .min(1, { message: "Currency is required" }),
|
||||
|
||||
// amount: z.coerce
|
||||
// .number({
|
||||
// invalid_type_error: "Amount is required and must be a number",
|
||||
// })
|
||||
// .min(1, "Amount must be Enter")
|
||||
// .refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
|
||||
// message: "Amount must have at most 2 decimal places",
|
||||
// }),
|
||||
|
||||
// strikeDate: z.string().min(1, { message: "Date is required" }),
|
||||
|
||||
// projectId: z.string().min(1, { message: "Project is required" }),
|
||||
|
||||
// paymentBufferDays: z.string().min(1, { message: "Buffer days is required" }),
|
||||
|
||||
// numberOfIteration: z.string().min(1, { message: "Iteration is required" }),
|
||||
|
||||
// expenseCategoryId: z
|
||||
// .string()
|
||||
// .min(1, { message: "Expense Category is required" }),
|
||||
|
||||
// statusId: z.string().min(1, { message: "Please select a status" }),
|
||||
|
||||
// frequency: z.string().min(1, { message: "Frequency is required" }),
|
||||
|
||||
// isVariable: z.boolean().optional(),
|
||||
|
||||
// })
|
||||
// };
|
||||
|
||||
|
||||
export const PaymentRecurringExpense = (expenseTypes) => {
|
||||
return z.object({
|
||||
title: z.string().min(1, { message: "Project is required" }),
|
||||
|
||||
description: z.string().min(1, { message: "Description is required" }),
|
||||
|
||||
payee: z.string().min(1, { message: "Supplier name is required" }),
|
||||
|
||||
notifyTo: z.string().min(1, { message: "Notification is required" }),
|
||||
|
||||
title: z.string().min(1, { message: "Title is required" }).transform((val) => val.trim()),
|
||||
description: z.string().min(1, { message: "Description is required" }).transform((val) => val.trim()),
|
||||
payee: z.string().min(1, { message: "Payee name is required" }).transform((val) => val.trim()),
|
||||
notifyTo: z.string().min(1, { message: "Notification e-mail is required" }).transform((val) => val.trim()),
|
||||
currencyId: z
|
||||
.string()
|
||||
.min(1, { message: "Currency is required" }),
|
||||
.min(1, { message: "Currency is required" })
|
||||
.transform((val) => val.trim()),
|
||||
|
||||
amount: z
|
||||
.number({
|
||||
@ -76,11 +27,13 @@ export const PaymentRecurringExpense = (expenseTypes) => {
|
||||
.min(1, { message: "Date is required" })
|
||||
.refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Invalid date format",
|
||||
}),
|
||||
})
|
||||
.transform((val) => val.trim()),
|
||||
|
||||
projectId: z
|
||||
.string()
|
||||
.min(1, { message: "Project is required" }),
|
||||
.min(1, { message: "Project is required" })
|
||||
.transform((val) => val.trim()),
|
||||
|
||||
paymentBufferDays: z
|
||||
.number({
|
||||
@ -98,23 +51,28 @@ export const PaymentRecurringExpense = (expenseTypes) => {
|
||||
|
||||
expenseCategoryId: z
|
||||
.string()
|
||||
.min(1, { message: "Expense Category is required" }),
|
||||
.min(1, { message: "Expense Category is required" })
|
||||
.transform((val) => val.trim()),
|
||||
|
||||
statusId: z
|
||||
.string()
|
||||
.min(1, { message: "Please select a status" }),
|
||||
.min(1, { message: "Please select a status" })
|
||||
.transform((val) => val.trim()),
|
||||
|
||||
frequency: z
|
||||
.number({
|
||||
required_error: "Frequency is required",
|
||||
invalid_type_error: "Frequency must be a number",
|
||||
})
|
||||
.min(1, { message: "Frequency must be greater than 0" }),
|
||||
.refine((val) => [0, 1, 2, 3, 4, 5].includes(val), {
|
||||
message: "Invalid frequency selected",
|
||||
}),
|
||||
|
||||
isVariable: z.boolean().optional(),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const defaultRecurringExpense = {
|
||||
title: "",
|
||||
description: "",
|
||||
@ -129,30 +87,26 @@ export const defaultRecurringExpense = {
|
||||
expenseCategoryId: "",
|
||||
statusId: "",
|
||||
frequency: 1,
|
||||
isVariable: false,
|
||||
isVariable: true,
|
||||
};
|
||||
|
||||
|
||||
// export const SearchPaymentRequestSchema = z.object({
|
||||
// projectIds: z.array(z.string()).optional(),
|
||||
// statusIds: z.array(z.string()).optional(),
|
||||
// createdByIds: z.array(z.string()).optional(),
|
||||
// currencyIds: z.array(z.string()).optional(),
|
||||
// expenseCategoryIds: z.array(z.string()).optional(),
|
||||
// payees: z.array(z.string()).optional(),
|
||||
// startDate: z.string().optional(),
|
||||
// endDate: z.string().optional(),
|
||||
// });
|
||||
|
||||
// export const defaultPaymentRequestFilter = {
|
||||
// projectIds: [],
|
||||
// statusIds: [],
|
||||
// createdByIds: [],
|
||||
// currencyIds: [],
|
||||
// expenseCategoryIds: [],
|
||||
// payees: [],
|
||||
// startDate: null,
|
||||
// endDate: null,
|
||||
// };
|
||||
export const SearchRecurringExpenseSchema = z.object({
|
||||
title: z.array(z.string()).optional(),
|
||||
description: z.array(z.string()).optional(),
|
||||
payee: z.array(z.string()).optional(),
|
||||
notifyTo: z.array(z.string()).optional(),
|
||||
currencyId: z.array(z.string()).optional(),
|
||||
amount: z.array(z.string()).optional(),
|
||||
strikeDate: z.string().optional(),
|
||||
projectId: z.string().optional(),
|
||||
paymentBufferDays: z.string().optional(),
|
||||
numberOfIteration: z.string().optional(),
|
||||
expenseCategoryId: z.string().optional(),
|
||||
statusId: z.string().optional(),
|
||||
frequency: z.string().optional(),
|
||||
isVariable: z.string().optional(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user