Merge branch 'upgrade_Expense' of https://git.marcoaiot.com/admin/marco.pms.web into upgrade_Expense
This commit is contained in:
commit
616b986deb
@ -9,6 +9,7 @@ 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)
|
||||
@ -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">
|
||||
|
||||
@ -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",
|
||||
},
|
||||
{
|
||||
|
||||
@ -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