Refactor_Expenses #321
@ -20,18 +20,7 @@ export const ExpenseSchema = (expenseTypes) => {
|
|||||||
transactionDate: z
|
transactionDate: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: "Date is required" })
|
.min(1, { message: "Date is required" })
|
||||||
.refine(
|
,
|
||||||
(val) => {
|
|
||||||
const selected = new Date(val);
|
|
||||||
const today = new Date();
|
|
||||||
|
|
||||||
selected.setHours(0, 0, 0, 0);
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
return selected <= today;
|
|
||||||
},
|
|
||||||
{ message: "Future dates are not allowed" }
|
|
||||||
),
|
|
||||||
transactionId: z.string().optional(),
|
transactionId: z.string().optional(),
|
||||||
description: z.string().min(1, { message: "Description is required" }),
|
description: z.string().min(1, { message: "Description is required" }),
|
||||||
location: z.string().min(1, { message: "Location is required" }),
|
location: z.string().min(1, { message: "Location is required" }),
|
||||||
@ -87,30 +76,6 @@ export const ExpenseSchema = (expenseTypes) => {
|
|||||||
path: ["noOfPersons"],
|
path: ["noOfPersons"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEndProcess) {
|
|
||||||
if (!data.reimburseTransactionId || data.reimburseTransactionId.trim() === "") {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: "Reimburse Transaction ID is required",
|
|
||||||
path: ["reimburseTransactionId"],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!data.reimburseDate) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: "Reimburse Date is required",
|
|
||||||
path: ["reimburseDate"],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!data.reimburseById) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: "Reimburse By is required",
|
|
||||||
path: ["reimburseById"],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
<div className="row my-2">
|
<div className="row my-2">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<label htmlFor="supplerName" className="form-label ">
|
<label htmlFor="supplerName" className="form-label ">
|
||||||
Supplier Name
|
Supplier Name/Transporter/Other
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -432,7 +432,7 @@ const ViewExpense = ({ ExpenseId }) => {
|
|||||||
|
|
||||||
{Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && (
|
{Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && (
|
||||||
<>
|
<>
|
||||||
{IsPaymentProcess && (
|
{(IsPaymentProcess && nextStatusWithPermission?.length > 0) && (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12 col-md-6 text-start">
|
<div className="col-12 col-md-6 text-start">
|
||||||
<label className="form-label">Transaction Id </label>
|
<label className="form-label">Transaction Id </label>
|
||||||
@ -461,7 +461,7 @@ const ViewExpense = ({ ExpenseId }) => {
|
|||||||
<EmployeeSearchInput
|
<EmployeeSearchInput
|
||||||
control={control}
|
control={control}
|
||||||
name="reimburseById"
|
name="reimburseById"
|
||||||
projectId={data?.project?.id}
|
projectId={null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user