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>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<Label className="form-label" required>
|
||||
Upload Bill{" "}
|
||||
</Label>
|
||||
<div className="col-12">
|
||||
<Label className="form-label" required>
|
||||
Upload Bill{" "}
|
||||
</Label>
|
||||
|
||||
<div
|
||||
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() =>
|
||||
document.getElementById("billAttachments").click()
|
||||
}
|
||||
>
|
||||
<i className="bx bx-cloud-upload d-block bx-lg"> </i>
|
||||
<span className="text-muted d-block">
|
||||
Click to select or click here to browse
|
||||
</span>
|
||||
<small className="text-muted">
|
||||
(PDF, JPG, PNG, max 5MB)
|
||||
</small>
|
||||
<div
|
||||
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() =>
|
||||
document.getElementById("billAttachments").click()
|
||||
}
|
||||
>
|
||||
<i className="bx bx-cloud-upload d-block bx-lg"> </i>
|
||||
<span className="text-muted d-block">
|
||||
Click to select or click here to browse
|
||||
</span>
|
||||
<small className="text-muted">
|
||||
(PDF, JPG, PNG, max 5MB)
|
||||
</small>
|
||||
|
||||
<input
|
||||
type="file"
|
||||
id="billAttachments"
|
||||
accept=".pdf,.jpg,.jpeg,.png"
|
||||
multiple
|
||||
style={{ display: "none" }}
|
||||
{...register("billAttachments")}
|
||||
onChange={(e) => {
|
||||
onFileChange(e);
|
||||
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>
|
||||
))}
|
||||
<input
|
||||
type="file"
|
||||
id="billAttachments"
|
||||
accept=".pdf,.jpg,.jpeg,.png"
|
||||
multiple
|
||||
style={{ display: "none" }}
|
||||
{...register("billAttachments")}
|
||||
onChange={(e) => {
|
||||
onFileChange(e);
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
@ -358,9 +357,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
||||
<div className="col-12 col-md-6 text-start mb-1">
|
||||
<Label className="form-label">TDS Percentage</Label>
|
||||
<input
|
||||
type="text"
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
{...register("tdsPercentage")}
|
||||
{...register("tdsPercentage", { valueAsNumber: true })}
|
||||
min="0"
|
||||
step="any"
|
||||
/>
|
||||
{errors.tdsPercentage && (
|
||||
<small className="danger-text">
|
||||
@ -373,9 +374,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
||||
Base Amount
|
||||
</Label>
|
||||
<input
|
||||
type="text"
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
{...register("baseAmount")}
|
||||
{...register("baseAmount", { valueAsNumber: true })}
|
||||
min="0"
|
||||
step="any"
|
||||
/>
|
||||
{errors.baseAmount && (
|
||||
<small className="danger-text">
|
||||
@ -388,9 +391,11 @@ const ActionPaymentRequest = ({ requestId }) => {
|
||||
Tax Amount
|
||||
</Label>
|
||||
<input
|
||||
type="text"
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
{...register("taxAmount")}
|
||||
{...register("taxAmount", { valueAsNumber: true })}
|
||||
min="0"
|
||||
step="any"
|
||||
/>
|
||||
{errors.taxAmount && (
|
||||
<small className="danger-text">
|
||||
@ -406,7 +411,6 @@ const ActionPaymentRequest = ({ requestId }) => {
|
||||
{((nextStatusWithPermission?.length > 0 && !isRejectedRequest) ||
|
||||
(isRejectedRequest && isCreatedBy)) && (
|
||||
<>
|
||||
|
||||
<Label className="form-label me-2 mb-0" required>
|
||||
Comment
|
||||
</Label>
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
|
||||
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 ALLOWED_TYPES = [
|
||||
"application/pdf",
|
||||
@ -93,9 +97,24 @@ export const PaymentRequestActionScheam = (
|
||||
paidTransactionId: z.string().nullable().optional(),
|
||||
paidAt: z.string().nullable().optional(),
|
||||
paidById: z.string().nullable().optional(),
|
||||
tdsPercentage: z.string().nullable().optional(),
|
||||
baseAmount: z.string().nullable().optional(),
|
||||
taxAmount: z.string().nullable().optional(),
|
||||
tdsPercentage: 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(),
|
||||
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
|
||||
paymentModeId: z.string().nullable().optional(),
|
||||
location: z.string().nullable().optional(),
|
||||
@ -139,18 +158,31 @@ export const PaymentRequestActionScheam = (
|
||||
message: "Paid By is required",
|
||||
});
|
||||
}
|
||||
if (!data.baseAmount) {
|
||||
if (!data.baseAmount || data.baseAmount < 0) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
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({
|
||||
code: z.ZodIssueCode.custom,
|
||||
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,
|
||||
paidAt: null,
|
||||
paidById: null,
|
||||
tdsPercentage: "0",
|
||||
tdsPercentage: null,
|
||||
baseAmount: null,
|
||||
taxAmount: "0",
|
||||
taxAmount: 0,
|
||||
// after Payment Processed
|
||||
paymentModeId: null,
|
||||
location: null,
|
||||
@ -227,7 +259,6 @@ export const DefaultRequestedExpense = {
|
||||
billAttachments: [],
|
||||
};
|
||||
|
||||
|
||||
export const STATUS_HEADING = {
|
||||
[EXPENSE_STATUS.draft]: "Initiation",
|
||||
[EXPENSE_STATUS.review_pending]: "Review & Validation",
|
||||
|
||||
@ -38,9 +38,9 @@ const PaymentStatusLogs = ({ data }) => {
|
||||
};
|
||||
return (
|
||||
<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>{" "}
|
||||
<p className="fw-medium">TimeLine</p>
|
||||
<p className="fw-semibold">TimeLine</p>
|
||||
</div>
|
||||
<div className="row h-74 overflow-auto px-3">
|
||||
<Timeline items={timelineData} />
|
||||
|
||||
@ -146,7 +146,7 @@ const ViewPaymentRequest = ({ requestId }) => {
|
||||
<div className="col-12 col-sm-6 ">
|
||||
<div className="row ">
|
||||
<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
|
||||
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>
|
||||
</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 && (
|
||||
<div className="d-flex align-items-center mb-2">
|
||||
@ -93,7 +93,7 @@ const Timeline = ({ items = [], transparent = true }) => {
|
||||
|
||||
</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>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -132,7 +132,7 @@ const PaymentRequestPage = () => {
|
||||
{ViewRequest.view && (
|
||||
<GlobalModel
|
||||
isOpen
|
||||
size="lg"
|
||||
size="xl"
|
||||
modalType="top"
|
||||
closeModal={() => setVieRequest({ requestId: null, view: false })}
|
||||
>
|
||||
|
||||
@ -40,6 +40,14 @@ export function startSignalR(loggedUser) {
|
||||
|
||||
// ---- Handlers for invalidate or remove ----
|
||||
const queryInvalidators = {
|
||||
Payment_Request: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["recurringExpenseList"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["recurringExpenseList"] });
|
||||
},
|
||||
Recurring_Payment: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["paymentRequestList"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["paymentRequest"] });
|
||||
},
|
||||
Expanse: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["Expenses"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["Expense"] });
|
||||
@ -79,7 +87,8 @@ export function startSignalR(loggedUser) {
|
||||
if (today === checkIn) eventBus.emit("attendance", data);
|
||||
|
||||
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 (
|
||||
afterTwoDay <= today &&
|
||||
(response.activity === 4 || response.activity === 5)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user