From 9b091840d6590bfefafb8104ce7d7f5896b77076 Mon Sep 17 00:00:00 2001 From: "pramod.mahajan" Date: Wed, 5 Nov 2025 18:10:24 +0530 Subject: [PATCH] added payee default --- src/components/Expenses/ExpenseSchema.js | 10 +-- src/components/Expenses/ViewExpense.jsx | 10 +-- .../PaymentRequest/ManagePaymentRequest.jsx | 90 +++++++++++++------ .../PaymentRequest/PaymentRequestSchema.js | 4 +- src/components/common/Avatar.jsx | 2 +- 5 files changed, 75 insertions(+), 41 deletions(-) diff --git a/src/components/Expenses/ExpenseSchema.js b/src/components/Expenses/ExpenseSchema.js index 65c05133..04110339 100644 --- a/src/components/Expenses/ExpenseSchema.js +++ b/src/components/Expenses/ExpenseSchema.js @@ -114,7 +114,7 @@ export const ExpenseActionScheam = ( reimburseTransactionId: z.string().nullable().optional(), reimburseDate: z.string().nullable().optional(), reimburseById: z.string().nullable().optional(), - tdsPercentage: z.number().optional(), + tdsPercentage: z.number().nullable().optional(), baseAmount: z.string().nullable().optional(), taxAmount: z.string().nullable().optional(), }) @@ -166,10 +166,10 @@ export const defaultActionValues = { reimburseTransactionId: null, reimburseDate: null, - reimburseById: "", - tdsPercentage: 0, - baseAmount: "", - taxAmount: "", + reimburseById: null, + tdsPercentage: null, + baseAmount:null, + taxAmount: null, }; export const SearchSchema = z.object({ diff --git a/src/components/Expenses/ViewExpense.jsx b/src/components/Expenses/ViewExpense.jsx index 1d408cad..36997786 100644 --- a/src/components/Expenses/ViewExpense.jsx +++ b/src/components/Expenses/ViewExpense.jsx @@ -393,7 +393,7 @@ const ViewExpense = ({ ExpenseId }) => { {IsPaymentProcess && nextStatusWithPermission?.length > 0 && (
- + { )}
-
- +
+ { )}
-
+
@@ -476,7 +476,7 @@ const ViewExpense = ({ ExpenseId }) => {
)} -
+
{((nextStatusWithPermission.length > 0 && !IsRejectedExpense) || (IsRejectedExpense && isCreatedBy)) && ( diff --git a/src/components/PaymentRequest/ManagePaymentRequest.jsx b/src/components/PaymentRequest/ManagePaymentRequest.jsx index 77bead76..52459a56 100644 --- a/src/components/PaymentRequest/ManagePaymentRequest.jsx +++ b/src/components/PaymentRequest/ManagePaymentRequest.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { useCurrencies, useProjectName } from "../../hooks/useProjects"; import Label from "../common/Label"; -import { useForm } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; import { useExpenseCategory } from "../../hooks/masterHook/useMaster"; import DatePicker from "../common/DatePicker"; import { @@ -50,7 +50,12 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { } = useExpenseCategory(); const { profile } = useProfile(); - const {data:Payees,isLoading:isPayeeLoaing,isError:isPayeeError,error:payeeError} = usePayee() + const { + data: Payees, + isLoading: isPayeeLoaing, + isError: isPayeeError, + error: payeeError, + } = usePayee(); const schema = PaymentRequestSchema(ExpenseCategories); const { register, @@ -113,7 +118,6 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { reader.onerror = (error) => reject(error); }); const removeFile = (index) => { - debugger if (requestToEdit) { const newFiles = files.map((file, i) => { if (file.documentId !== index) return file; @@ -183,7 +187,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { let payload = { ...fromdata, dueDate: localToUtc(fromdata.dueDate), - payee: isItself ? profile?.employeeInfo?.id : fromdata.payee, + payee: isItself ? `${profile?.employeeInfo?.firstName} ${profile?.employeeInfo?.lastName}` : fromdata.payee, }; if (requestToEdit) { const editPayload = { @@ -198,7 +202,12 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { }; const handleSetItSelf = (e) => { setisItself(e.target.value); - setValue("payee", `${profile?.employeeInfo.firstName} ${profile?.employeeInfo.lastName}`); + let name = `${profile?.employeeInfo.firstName} ${profile?.employeeInfo.lastName}` + + setValue( + "payee", + name + ); }; return ( @@ -280,26 +289,53 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { )}
-
-
@@ -355,7 +391,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { } error={errors.payee?.message} /> - + {errors.payee && ( {errors.payee.message} )} @@ -425,9 +461,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { {/* Upload Document */}
- +
{ dueDate: z.string().min(1, { message: "Date is required" }), description: z.string().min(1, { message: "Description is required" }), payee: z.string().min(1, { message: "Supplier name is required" }), - isAdvancePayment: z.boolean().optional(), + isAdvancePayment: z.boolean().optional().default(false), amount: z.coerce .number({ invalid_type_error: "Amount is required and must be a number", @@ -56,7 +56,7 @@ export const defaultPaymentRequest = { dueDate: "", projectId: "", expenseCategoryId: "", - isAdvancePayment: boolean, + isAdvancePayment: false, billAttachments: [], }; diff --git a/src/components/common/Avatar.jsx b/src/components/common/Avatar.jsx index 5c3f25e6..34c14e50 100644 --- a/src/components/common/Avatar.jsx +++ b/src/components/common/Avatar.jsx @@ -52,7 +52,7 @@ const Avatar = ({ firstName, lastName, size = "sm", classAvatar }) => { return (
- + {generateAvatarText(firstName, lastName)}