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