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 { boolean, z } from "zod";
|
||||||
import { INR_CURRENCY_CODE } from "../../utils/constants";
|
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) => {
|
export const PaymentRecurringExpense = (expenseTypes) => {
|
||||||
return z.object({
|
return z.object({
|
||||||
title: z.string().min(1, { message: "Project 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()),
|
||||||
description: z.string().min(1, { message: "Description is required" }),
|
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()),
|
||||||
payee: z.string().min(1, { message: "Supplier name is required" }),
|
|
||||||
|
|
||||||
notifyTo: z.string().min(1, { message: "Notification is required" }),
|
|
||||||
|
|
||||||
currencyId: z
|
currencyId: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Currency is required" }),
|
.min(1, { message: "Currency is required" })
|
||||||
|
.transform((val) => val.trim()),
|
||||||
|
|
||||||
amount: z
|
amount: z
|
||||||
.number({
|
.number({
|
||||||
@ -76,11 +27,13 @@ export const PaymentRecurringExpense = (expenseTypes) => {
|
|||||||
.min(1, { message: "Date is required" })
|
.min(1, { message: "Date is required" })
|
||||||
.refine((val) => !isNaN(Date.parse(val)), {
|
.refine((val) => !isNaN(Date.parse(val)), {
|
||||||
message: "Invalid date format",
|
message: "Invalid date format",
|
||||||
}),
|
})
|
||||||
|
.transform((val) => val.trim()),
|
||||||
|
|
||||||
projectId: z
|
projectId: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Project is required" }),
|
.min(1, { message: "Project is required" })
|
||||||
|
.transform((val) => val.trim()),
|
||||||
|
|
||||||
paymentBufferDays: z
|
paymentBufferDays: z
|
||||||
.number({
|
.number({
|
||||||
@ -98,23 +51,28 @@ export const PaymentRecurringExpense = (expenseTypes) => {
|
|||||||
|
|
||||||
expenseCategoryId: z
|
expenseCategoryId: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Expense Category is required" }),
|
.min(1, { message: "Expense Category is required" })
|
||||||
|
.transform((val) => val.trim()),
|
||||||
|
|
||||||
statusId: z
|
statusId: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Please select a status" }),
|
.min(1, { message: "Please select a status" })
|
||||||
|
.transform((val) => val.trim()),
|
||||||
|
|
||||||
frequency: z
|
frequency: z
|
||||||
.number({
|
.number({
|
||||||
required_error: "Frequency is required",
|
required_error: "Frequency is required",
|
||||||
invalid_type_error: "Frequency must be a number",
|
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(),
|
isVariable: z.boolean().optional(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const defaultRecurringExpense = {
|
export const defaultRecurringExpense = {
|
||||||
title: "",
|
title: "",
|
||||||
description: "",
|
description: "",
|
||||||
@ -129,30 +87,26 @@ export const defaultRecurringExpense = {
|
|||||||
expenseCategoryId: "",
|
expenseCategoryId: "",
|
||||||
statusId: "",
|
statusId: "",
|
||||||
frequency: 1,
|
frequency: 1,
|
||||||
isVariable: false,
|
isVariable: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// export const SearchPaymentRequestSchema = z.object({
|
export const SearchRecurringExpenseSchema = z.object({
|
||||||
// projectIds: z.array(z.string()).optional(),
|
title: z.array(z.string()).optional(),
|
||||||
// statusIds: z.array(z.string()).optional(),
|
description: z.array(z.string()).optional(),
|
||||||
// createdByIds: z.array(z.string()).optional(),
|
payee: z.array(z.string()).optional(),
|
||||||
// currencyIds: z.array(z.string()).optional(),
|
notifyTo: z.array(z.string()).optional(),
|
||||||
// expenseCategoryIds: z.array(z.string()).optional(),
|
currencyId: z.array(z.string()).optional(),
|
||||||
// payees: z.array(z.string()).optional(),
|
amount: z.array(z.string()).optional(),
|
||||||
// startDate: z.string().optional(),
|
strikeDate: z.string().optional(),
|
||||||
// endDate: z.string().optional(),
|
projectId: z.string().optional(),
|
||||||
// });
|
paymentBufferDays: z.string().optional(),
|
||||||
|
numberOfIteration: z.string().optional(),
|
||||||
// export const defaultPaymentRequestFilter = {
|
expenseCategoryId: z.string().optional(),
|
||||||
// projectIds: [],
|
statusId: z.string().optional(),
|
||||||
// statusIds: [],
|
frequency: z.string().optional(),
|
||||||
// createdByIds: [],
|
isVariable: z.string().optional(),
|
||||||
// currencyIds: [],
|
});
|
||||||
// expenseCategoryIds: [],
|
|
||||||
// payees: [],
|
|
||||||
// startDate: null,
|
|
||||||
// endDate: null,
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user