Merge branch 'upgrade_Expense' of https://git.marcoaiot.com/admin/marco.pms.web into upgrade_Expense
This commit is contained in:
commit
616b986deb
@ -9,10 +9,11 @@ import { useCreatePaymentRequest, usePaymentRequestDetail, useUpdatePaymentReque
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { formatFileSize, localToUtc } from '../../utils/appUtils';
|
import { formatFileSize, localToUtc } from '../../utils/appUtils';
|
||||||
import { defaultPaymentRequest, PaymentRequestSchema } from './PaymentRequestSchema';
|
import { defaultPaymentRequest, PaymentRequestSchema } from './PaymentRequestSchema';
|
||||||
|
import { INR_CURRENCY_CODE } from '../../utils/constants';
|
||||||
|
|
||||||
function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
||||||
const {data,isLoading,isError,error:requestError}= usePaymentRequestDetail(requestToEdit)
|
const { data, isLoading, isError, error: requestError } = usePaymentRequestDetail(requestToEdit)
|
||||||
// const data = {}
|
// const data = {}
|
||||||
|
|
||||||
const { projectNames, loading: projectLoading, error, isError: isProjectError,
|
const { projectNames, loading: projectLoading, error, isError: isProjectError,
|
||||||
} = useProjectName();
|
} = useProjectName();
|
||||||
@ -138,6 +139,17 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
}
|
}
|
||||||
}, [data, reset]);
|
}, [data, reset]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!requestToEdit && currencyData && currencyData.length > 0) {
|
||||||
|
const inrCurrency = currencyData.find(
|
||||||
|
(c) => c.id === INR_CURRENCY_CODE
|
||||||
|
);
|
||||||
|
if (inrCurrency) {
|
||||||
|
setValue("currencyId", INR_CURRENCY_CODE, { shouldValidate: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [currencyData, requestToEdit, setValue]);
|
||||||
|
|
||||||
const onSubmit = (fromdata) => {
|
const onSubmit = (fromdata) => {
|
||||||
let payload = {
|
let payload = {
|
||||||
...fromdata,
|
...fromdata,
|
||||||
@ -158,6 +170,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
{requestToEdit ? "Update Payment Request " : "Create Payment Request"}
|
{requestToEdit ? "Update Payment Request " : "Create Payment Request"}
|
||||||
</h5>
|
</h5>
|
||||||
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{/* Project and Category */}
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<Label className="form-label" required>
|
<Label className="form-label" required>
|
||||||
@ -214,6 +227,50 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Title and Advance Payment */}
|
||||||
|
<div className="row my-2 text-start">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<Label htmlFor="title" className="form-label" required>
|
||||||
|
Title
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="title"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("title")}
|
||||||
|
/>
|
||||||
|
{errors.title && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.title.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-md-6">
|
||||||
|
<Label htmlFor="isAdvancePayment" className="form-label" required>
|
||||||
|
Advance Payment
|
||||||
|
</Label>
|
||||||
|
<select
|
||||||
|
id="isAdvancePayment"
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
{...register("isAdvancePayment", {
|
||||||
|
setValueAs: (v) => v === "true" ? true : v === "false" ? false : undefined,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<option value="">Select Option</option>
|
||||||
|
<option value="true">True</option>
|
||||||
|
<option value="false">False</option>
|
||||||
|
</select>
|
||||||
|
{errors.isAdvancePayment && (
|
||||||
|
<small className="danger-text">{errors.isAdvancePayment.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{/* Date and Amount */}
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<Label htmlFor="dueDate" className="form-label" required>
|
<Label htmlFor="dueDate" className="form-label" required>
|
||||||
@ -252,10 +309,11 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Payee and Currency */}
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<Label htmlFor="payee" className="form-label" required>
|
<Label htmlFor="payee" className="form-label" required>
|
||||||
Supplier Name/Transporter Name/Other
|
Payee(Supplier Name/Transporter Name/Other)
|
||||||
</Label>
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -298,47 +356,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row my-2 text-start">
|
{/* Description */}
|
||||||
<div className="col-md-6">
|
|
||||||
<Label htmlFor="title" className="form-label" required>
|
|
||||||
Title
|
|
||||||
</Label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="title"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("title")}
|
|
||||||
/>
|
|
||||||
{errors.title && (
|
|
||||||
<small className="danger-text">
|
|
||||||
{errors.title.message}
|
|
||||||
</small>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-md-6">
|
|
||||||
<Label htmlFor="isAdvancePayment" className="form-label" required>
|
|
||||||
Advance Payment
|
|
||||||
</Label>
|
|
||||||
<select
|
|
||||||
id="isAdvancePayment"
|
|
||||||
className="form-select form-select-sm"
|
|
||||||
{...register("isAdvancePayment", {
|
|
||||||
setValueAs: (v) => v === "true" ? true : v === "false" ? false : undefined,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<option value="">Select Option</option>
|
|
||||||
<option value="true">True</option>
|
|
||||||
<option value="false">False</option>
|
|
||||||
</select>
|
|
||||||
{errors.isAdvancePayment && (
|
|
||||||
<small className="danger-text">{errors.isAdvancePayment.message}</small>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<Label htmlFor="description" className="form-label" required>
|
<Label htmlFor="description" className="form-label" required>
|
||||||
@ -358,6 +376,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Upload Document */}
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<Label className="form-label">
|
<Label className="form-label">
|
||||||
|
|||||||
@ -14,14 +14,14 @@ import ConfirmModal from "../common/ConfirmModal";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
const PaymentRequestList = ({filters, groupBy = "submittedBy", search }) => {
|
const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||||
const { setManageRequest,setVieRequest } = usePaymentRequestContext();
|
const { setManageRequest, setVieRequest } = usePaymentRequestContext();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [deletingId, setDeletingId] = useState(null);
|
const [deletingId, setDeletingId] = useState(null);
|
||||||
const SelfId = useSelector(
|
const SelfId = useSelector(
|
||||||
(store) => store?.globalVariables?.loginUser?.employeeInfo?.id
|
(store) => store?.globalVariables?.loginUser?.employeeInfo?.id
|
||||||
);
|
);
|
||||||
const groupByField = (items, field) => {
|
const groupByField = (items, field) => {
|
||||||
return items.reduce((acc, item) => {
|
return items.reduce((acc, item) => {
|
||||||
let key;
|
let key;
|
||||||
@ -122,8 +122,11 @@ const PaymentRequestList = ({filters, groupBy = "submittedBy", search }) => {
|
|||||||
label: " Amount",
|
label: " Amount",
|
||||||
align: "text-start",
|
align: "text-start",
|
||||||
getValue: (e) => (
|
getValue: (e) => (
|
||||||
<>{formatCurrency(e?.amount, e.currency.currencyCode)}</>
|
<>
|
||||||
|
{formatCurrency(e?.amount)} {e.currency.currencyCode}
|
||||||
|
</>
|
||||||
),
|
),
|
||||||
|
|
||||||
align: "text-end px-3",
|
align: "text-end px-3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -279,52 +282,52 @@ const PaymentRequestList = ({filters, groupBy = "submittedBy", search }) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
></i>
|
></i>
|
||||||
{canDetetExpense(paymentRequest) &&
|
{canDetetExpense(paymentRequest) &&
|
||||||
canEditExpense(paymentRequest) && (
|
canEditExpense(paymentRequest) && (
|
||||||
<div className="dropdown z-2">
|
<div className="dropdown z-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-xs btn-icon btn-text-secondary rounded-pill dropdown-toggle hide-arrow p-0 m-0"
|
className="btn btn-xs btn-icon btn-text-secondary rounded-pill dropdown-toggle hide-arrow p-0 m-0"
|
||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className="bx bx-dots-vertical-rounded text-muted p-0"
|
className="bx bx-dots-vertical-rounded text-muted p-0"
|
||||||
data-bs-toggle="tooltip"
|
data-bs-toggle="tooltip"
|
||||||
data-bs-offset="0,8"
|
data-bs-offset="0,8"
|
||||||
data-bs-placement="top"
|
data-bs-placement="top"
|
||||||
data-bs-custom-class="tooltip-dark"
|
data-bs-custom-class="tooltip-dark"
|
||||||
title="More Action"
|
title="More Action"
|
||||||
></i>
|
></i>
|
||||||
</button>
|
</button>
|
||||||
<ul className="dropdown-menu dropdown-menu-end w-auto">
|
<ul className="dropdown-menu dropdown-menu-end w-auto">
|
||||||
<li
|
<li
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setManageRequest({
|
setManageRequest({
|
||||||
IsOpen: true,
|
IsOpen: true,
|
||||||
RequestId: paymentRequest.id,
|
RequestId: paymentRequest.id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<a className="dropdown-item px-2 cursor-pointer py-1">
|
<a className="dropdown-item px-2 cursor-pointer py-1">
|
||||||
<i className="bx bx-edit text-primary bx-xs me-2"></i>
|
<i className="bx bx-edit text-primary bx-xs me-2"></i>
|
||||||
<span className="align-left ">Modify</span>
|
<span className="align-left ">Modify</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsDeleteModalOpen(true);
|
setIsDeleteModalOpen(true);
|
||||||
setDeletingId(paymentRequest.id);
|
setDeletingId(paymentRequest.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a className="dropdown-item px-2 cursor-pointer py-1">
|
<a className="dropdown-item px-2 cursor-pointer py-1">
|
||||||
<i className="bx bx-trash text-danger bx-xs me-2"></i>
|
<i className="bx bx-trash text-danger bx-xs me-2"></i>
|
||||||
<span className="align-left">Delete</span>
|
<span className="align-left">Delete</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>)}
|
</div>)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { boolean, z } from "zod";
|
import { boolean, z } from "zod";
|
||||||
|
import { 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",
|
||||||
|
|||||||
@ -100,6 +100,7 @@ export const VERIFY_DOCUMENT = "13a1f30f-38d1-41bf-8e7a-b75189aab8e0";
|
|||||||
|
|
||||||
// 1 - Expense Manage
|
// 1 - Expense Manage
|
||||||
export const EXPENSE_MANAGEMENT = "a4e25142-449b-4334-a6e5-22f70e4732d7";
|
export const EXPENSE_MANAGEMENT = "a4e25142-449b-4334-a6e5-22f70e4732d7";
|
||||||
|
export const INR_CURRENCY_CODE = "78e96e4a-7ce0-4164-ae3a-c833ad45ec2c";
|
||||||
|
|
||||||
export const TENANT_STATUS = [
|
export const TENANT_STATUS = [
|
||||||
{ id: "62b05792-5115-4f99-8ff5-e8374859b191", name: "Active" },
|
{ id: "62b05792-5115-4f99-8ff5-e8374859b191", name: "Active" },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user