added validation for Tax , base amount, and added signal for PR and Recurring
This commit is contained in:
parent
78faab1b1e
commit
ec9bcd1ea5
@ -254,68 +254,67 @@ const ActionPaymentRequest = ({ requestId }) => {
|
|||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<Label className="form-label" required>
|
<Label className="form-label" required>
|
||||||
Upload Bill{" "}
|
Upload Bill{" "}
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
document.getElementById("billAttachments").click()
|
document.getElementById("billAttachments").click()
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<i className="bx bx-cloud-upload d-block bx-lg"> </i>
|
<i className="bx bx-cloud-upload d-block bx-lg"> </i>
|
||||||
<span className="text-muted d-block">
|
<span className="text-muted d-block">
|
||||||
Click to select or click here to browse
|
Click to select or click here to browse
|
||||||
</span>
|
</span>
|
||||||
<small className="text-muted">
|
<small className="text-muted">
|
||||||
(PDF, JPG, PNG, max 5MB)
|
(PDF, JPG, PNG, max 5MB)
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
id="billAttachments"
|
id="billAttachments"
|
||||||
accept=".pdf,.jpg,.jpeg,.png"
|
accept=".pdf,.jpg,.jpeg,.png"
|
||||||
multiple
|
multiple
|
||||||
style={{ display: "none" }}
|
style={{ display: "none" }}
|
||||||
{...register("billAttachments")}
|
{...register("billAttachments")}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
onFileChange(e);
|
onFileChange(e);
|
||||||
e.target.value = "";
|
e.target.value = "";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
{errors.billAttachments && (
|
|
||||||
<small className="danger-text">
|
|
||||||
{errors.billAttachments.message}
|
|
||||||
</small>
|
|
||||||
)}
|
|
||||||
{files?.length > 0 && (
|
|
||||||
<Filelist
|
|
||||||
files={files}
|
|
||||||
removeFile={removeFile}
|
|
||||||
expenseToEdit={false}
|
|
||||||
sm={12}
|
|
||||||
md={12}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{Array.isArray(errors.billAttachments) &&
|
|
||||||
errors.billAttachments.map((fileError, index) => (
|
|
||||||
<div key={index} className="danger-text small mt-1">
|
|
||||||
{
|
|
||||||
(fileError?.fileSize?.message ||
|
|
||||||
fileError?.contentType?.message ||
|
|
||||||
fileError?.base64Data?.message,
|
|
||||||
fileError?.documentId?.message)
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
{errors.billAttachments && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.billAttachments.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
{files?.length > 0 && (
|
||||||
|
<Filelist
|
||||||
|
files={files}
|
||||||
|
removeFile={removeFile}
|
||||||
|
expenseToEdit={false}
|
||||||
|
sm={12}
|
||||||
|
md={12}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{Array.isArray(errors.billAttachments) &&
|
||||||
|
errors.billAttachments.map((fileError, index) => (
|
||||||
|
<div key={index} className="danger-text small mt-1">
|
||||||
|
{
|
||||||
|
(fileError?.fileSize?.message ||
|
||||||
|
fileError?.contentType?.message ||
|
||||||
|
fileError?.base64Data?.message,
|
||||||
|
fileError?.documentId?.message)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@ -358,9 +357,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
|||||||
<div className="col-12 col-md-6 text-start mb-1">
|
<div className="col-12 col-md-6 text-start mb-1">
|
||||||
<Label className="form-label">TDS Percentage</Label>
|
<Label className="form-label">TDS Percentage</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("tdsPercentage")}
|
{...register("tdsPercentage", { valueAsNumber: true })}
|
||||||
|
min="0"
|
||||||
|
step="any"
|
||||||
/>
|
/>
|
||||||
{errors.tdsPercentage && (
|
{errors.tdsPercentage && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -373,9 +374,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
|||||||
Base Amount
|
Base Amount
|
||||||
</Label>
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("baseAmount")}
|
{...register("baseAmount", { valueAsNumber: true })}
|
||||||
|
min="0"
|
||||||
|
step="any"
|
||||||
/>
|
/>
|
||||||
{errors.baseAmount && (
|
{errors.baseAmount && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -388,9 +391,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
|||||||
Tax Amount
|
Tax Amount
|
||||||
</Label>
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("taxAmount")}
|
{...register("taxAmount", { valueAsNumber: true })}
|
||||||
|
min="0"
|
||||||
|
step="any"
|
||||||
/>
|
/>
|
||||||
{errors.taxAmount && (
|
{errors.taxAmount && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -406,7 +411,6 @@ const ActionPaymentRequest = ({ requestId }) => {
|
|||||||
{((nextStatusWithPermission?.length > 0 && !isRejectedRequest) ||
|
{((nextStatusWithPermission?.length > 0 && !isRejectedRequest) ||
|
||||||
(isRejectedRequest && isCreatedBy)) && (
|
(isRejectedRequest && isCreatedBy)) && (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<Label className="form-label me-2 mb-0" required>
|
<Label className="form-label me-2 mb-0" required>
|
||||||
Comment
|
Comment
|
||||||
</Label>
|
</Label>
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
import { boolean, z } from "zod";
|
import { boolean, z } from "zod";
|
||||||
import { CREATE_EXEPENSE, EXPENSE_DRAFT, EXPENSE_STATUS, INR_CURRENCY_CODE } from "../../utils/constants";
|
import {
|
||||||
|
CREATE_EXEPENSE,
|
||||||
|
EXPENSE_DRAFT,
|
||||||
|
EXPENSE_STATUS,
|
||||||
|
INR_CURRENCY_CODE,
|
||||||
|
} from "../../utils/constants";
|
||||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||||
const ALLOWED_TYPES = [
|
const ALLOWED_TYPES = [
|
||||||
"application/pdf",
|
"application/pdf",
|
||||||
@ -93,9 +97,24 @@ export const PaymentRequestActionScheam = (
|
|||||||
paidTransactionId: z.string().nullable().optional(),
|
paidTransactionId: z.string().nullable().optional(),
|
||||||
paidAt: z.string().nullable().optional(),
|
paidAt: z.string().nullable().optional(),
|
||||||
paidById: z.string().nullable().optional(),
|
paidById: z.string().nullable().optional(),
|
||||||
tdsPercentage: z.string().nullable().optional(),
|
tdsPercentage: z
|
||||||
baseAmount: z.string().nullable().optional(),
|
.number({ invalid_type_error: "TDS must be a number" })
|
||||||
taxAmount: z.string().nullable().optional(),
|
.min(0, { message: "TDS must be zero or greater" })
|
||||||
|
.or(z.nan())
|
||||||
|
.or(z.null())
|
||||||
|
.optional(),
|
||||||
|
baseAmount: z
|
||||||
|
.number({ invalid_type_error: "TDS must be a number" })
|
||||||
|
.min(0, { message: "TDS must be zero or greater" })
|
||||||
|
.or(z.nan())
|
||||||
|
.or(z.null())
|
||||||
|
.optional(),
|
||||||
|
taxAmount: z
|
||||||
|
.number({ invalid_type_error: "Tax amount must be a number" })
|
||||||
|
.min(0, { message: "Tax amount must be zero or greater" })
|
||||||
|
.or(z.nan())
|
||||||
|
.or(z.null())
|
||||||
|
.optional(),
|
||||||
// after Payment Processed
|
// after Payment Processed
|
||||||
paymentModeId: z.string().nullable().optional(),
|
paymentModeId: z.string().nullable().optional(),
|
||||||
location: z.string().nullable().optional(),
|
location: z.string().nullable().optional(),
|
||||||
@ -139,18 +158,31 @@ export const PaymentRequestActionScheam = (
|
|||||||
message: "Paid By is required",
|
message: "Paid By is required",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!data.baseAmount) {
|
if (!data.baseAmount || data.baseAmount < 0) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
path: ["baseAmount"],
|
path: ["baseAmount"],
|
||||||
message: "Base Amount i required",
|
message: "Base Amount is required",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!data.taxAmount) {
|
if (
|
||||||
|
data.taxAmount === null ||
|
||||||
|
data.taxAmount === undefined ||
|
||||||
|
isNaN(Number(data.taxAmount)) ||
|
||||||
|
Number(data.taxAmount) < 0
|
||||||
|
) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
path: ["taxAmount"],
|
path: ["taxAmount"],
|
||||||
message: "Tax is required",
|
message: "Tax amount must be zero or greater",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.tdsPercentage < 0) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["tdsPercentage"],
|
||||||
|
message: "TDS must valid",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,9 +218,9 @@ export const defaultPRActionValues = {
|
|||||||
paidTransactionId: null,
|
paidTransactionId: null,
|
||||||
paidAt: null,
|
paidAt: null,
|
||||||
paidById: null,
|
paidById: null,
|
||||||
tdsPercentage: "0",
|
tdsPercentage: null,
|
||||||
baseAmount: null,
|
baseAmount: null,
|
||||||
taxAmount: "0",
|
taxAmount: 0,
|
||||||
// after Payment Processed
|
// after Payment Processed
|
||||||
paymentModeId: null,
|
paymentModeId: null,
|
||||||
location: null,
|
location: null,
|
||||||
@ -227,7 +259,6 @@ export const DefaultRequestedExpense = {
|
|||||||
billAttachments: [],
|
billAttachments: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const STATUS_HEADING = {
|
export const STATUS_HEADING = {
|
||||||
[EXPENSE_STATUS.draft]: "Initiation",
|
[EXPENSE_STATUS.draft]: "Initiation",
|
||||||
[EXPENSE_STATUS.review_pending]: "Review & Validation",
|
[EXPENSE_STATUS.review_pending]: "Review & Validation",
|
||||||
|
|||||||
@ -38,9 +38,9 @@ const PaymentStatusLogs = ({ data }) => {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<div className="d-flex mb-2 py-1">
|
<div className="d-flex mb-1 pt-10">
|
||||||
<i className="bx bx-time-five me-2 "></i>{" "}
|
<i className="bx bx-time-five me-2 "></i>{" "}
|
||||||
<p className="fw-medium">TimeLine</p>
|
<p className="fw-semibold">TimeLine</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="row h-74 overflow-auto px-3">
|
<div className="row h-74 overflow-auto px-3">
|
||||||
<Timeline items={timelineData} />
|
<Timeline items={timelineData} />
|
||||||
|
|||||||
@ -146,7 +146,7 @@ const ViewPaymentRequest = ({ requestId }) => {
|
|||||||
<div className="col-12 col-sm-6 ">
|
<div className="col-12 col-sm-6 ">
|
||||||
<div className="row ">
|
<div className="row ">
|
||||||
<div className="col-12 d-flex justify-content-between mb-6">
|
<div className="col-12 d-flex justify-content-between mb-6">
|
||||||
<span> {data?.paymentRequestUID}</span>
|
<div className="d-flex align-items-center"><span className="fw-semibold">PR No : </span><span className="fw-semibold ms-2"> {data?.paymentRequestUID}</span></div>
|
||||||
<span
|
<span
|
||||||
className={`badge bg-label-${getColorNameFromHex(data?.expenseStatus?.color) || "secondary"
|
className={`badge bg-label-${getColorNameFromHex(data?.expenseStatus?.color) || "secondary"
|
||||||
}`}
|
}`}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ const Timeline = ({ items = [], transparent = true }) => {
|
|||||||
<small className="text-body-secondary"><Tooltip text={formatUTCToLocalTime(item.timeAgo,true)}>{moment.utc(item.timeAgo).local().fromNow()}</Tooltip></small>
|
<small className="text-body-secondary"><Tooltip text={formatUTCToLocalTime(item.timeAgo,true)}>{moment.utc(item.timeAgo).local().fromNow()}</Tooltip></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{item.description && <p className="mb-1">{item.description}</p>}
|
{item.description && <p className="mb-1 small">{item.description}</p>}
|
||||||
|
|
||||||
{item.attachments && item.attachments.length > 0 && (
|
{item.attachments && item.attachments.length > 0 && (
|
||||||
<div className="d-flex align-items-center mb-2">
|
<div className="d-flex align-items-center mb-2">
|
||||||
@ -93,7 +93,7 @@ const Timeline = ({ items = [], transparent = true }) => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="d-flex flex-wrap ms-10">{item.userComment && <p className="mb-2 ">{item.userComment}</p>}</div>
|
<div className="d-flex flex-wrap small ms-10">{item.userComment && <p className="mb-2 ">{item.userComment}</p>}</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -132,7 +132,7 @@ const PaymentRequestPage = () => {
|
|||||||
{ViewRequest.view && (
|
{ViewRequest.view && (
|
||||||
<GlobalModel
|
<GlobalModel
|
||||||
isOpen
|
isOpen
|
||||||
size="lg"
|
size="xl"
|
||||||
modalType="top"
|
modalType="top"
|
||||||
closeModal={() => setVieRequest({ requestId: null, view: false })}
|
closeModal={() => setVieRequest({ requestId: null, view: false })}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -40,6 +40,14 @@ export function startSignalR(loggedUser) {
|
|||||||
|
|
||||||
// ---- Handlers for invalidate or remove ----
|
// ---- Handlers for invalidate or remove ----
|
||||||
const queryInvalidators = {
|
const queryInvalidators = {
|
||||||
|
Payment_Request: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["recurringExpenseList"] }),
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["recurringExpenseList"] });
|
||||||
|
},
|
||||||
|
Recurring_Payment: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["paymentRequestList"] }),
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["paymentRequest"] });
|
||||||
|
},
|
||||||
Expanse: () => {
|
Expanse: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["Expenses"] }),
|
queryClient.invalidateQueries({ queryKey: ["Expenses"] }),
|
||||||
queryClient.invalidateQueries({ queryKey: ["Expense"] });
|
queryClient.invalidateQueries({ queryKey: ["Expense"] });
|
||||||
@ -79,7 +87,8 @@ export function startSignalR(loggedUser) {
|
|||||||
if (today === checkIn) eventBus.emit("attendance", data);
|
if (today === checkIn) eventBus.emit("attendance", data);
|
||||||
|
|
||||||
const onlyDate = Number(checkIn.substring(8, 10));
|
const onlyDate = Number(checkIn.substring(8, 10));
|
||||||
const afterTwoDay = checkIn.substring(0,8) + (onlyDate + 2).toString().padStart(2, "0");
|
const afterTwoDay =
|
||||||
|
checkIn.substring(0, 8) + (onlyDate + 2).toString().padStart(2, "0");
|
||||||
if (
|
if (
|
||||||
afterTwoDay <= today &&
|
afterTwoDay <= today &&
|
||||||
(response.activity === 4 || response.activity === 5)
|
(response.activity === 4 || response.activity === 5)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user