Merge branch 'upgrade_Expense' of https://git.marcoaiot.com/admin/marco.pms.web into upgrade_Expense

This commit is contained in:
pramod.mahajan 2025-11-06 10:07:46 +05:30
commit c3e030754f

View File

@ -7,7 +7,7 @@ import Loader, { SpinnerLoader } from "../common/Loader";
const AdvancePaymentList = ({ employeeId }) => { const AdvancePaymentList = ({ employeeId }) => {
const { data, isError, isLoading, error, isFetching } = const { data, isError, isLoading, error, isFetching } =
useExpenseTransactions(employeeId, { enabled: !!employeeId }); useExpenseTransactions(employeeId, { enabled: !!employeeId });
console.log(data)
// Handle no employee selected // Handle no employee selected
if (!employeeId) { if (!employeeId) {
return ( return (
@ -27,7 +27,7 @@ const AdvancePaymentList = ({ employeeId }) => {
className="d-flex justify-content-center align-items-center" className="d-flex justify-content-center align-items-center"
style={{ height: "200px" }} style={{ height: "200px" }}
> >
<SpinnerLoader/> <SpinnerLoader />
</div> </div>
); );
} }
@ -104,7 +104,7 @@ const AdvancePaymentList = ({ employeeId }) => {
</div> </div>
); );
} }
console.log("Kartik", rowsWithBalance)
return ( return (
<div className="table-responsive"> <div className="table-responsive">
<table className="table align-middle"> <table className="table align-middle">
@ -118,30 +118,49 @@ const AdvancePaymentList = ({ employeeId }) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{rowsWithBalance.map((row) => ( {Array.isArray(data) && data.length > 0 ? (
<tr key={row.id}> data.map((row) => (
{columns.map((col) => ( <tr key={row.id}>
<td key={col.key} className={`${col.align} p-2`}> {columns.map((col) => (
{["balance", "credit", "debit"].includes(col.key) ? ( <td key={col.key} className={`${col.align} p-2`}>
<span> {col.key === "credit" ? (
{row[col.key].toLocaleString("en-IN")} row.amount > 0 ? (
</span> <span>{row.amount.toLocaleString("en-IN")}</span>
) : ( ) : (
<div className="d-flex flex-column text-start"> "-"
<small className="text-muted"> )
{formatUTCToLocalTime(row.createdAt)} ) : col.key === "debit" ? (
</small> row.amount < 0 ? (
<small className="fw-semibold text-dark"> <span>{Math.abs(row.amount).toLocaleString("en-IN")}</span>
{row.projectName} ) : (
</small> "-"
<small>{row.description}</small> )
</div> ) : col.key === "balance" ? (
)} <span>{row.currentBalance?.toLocaleString("en-IN")}</span>
</td> ) : (
))} <div className="d-flex flex-column text-start">
<small className="text-muted">
{formatUTCToLocalTime(row.paidAt)}
</small>
<small className="fw-semibold text-dark">
{row.project?.name || "-"}
</small>
<small>{row.title || "-"}</small>
</div>
)}
</td>
))}
</tr>
))
) : (
<tr>
<td colSpan={columns.length} className="text-center text-muted py-3">
No advance payment records found.
</td>
</tr> </tr>
))} )}
</tbody> </tbody>
<tfoot className="table-secondary fw-bold"> <tfoot className="table-secondary fw-bold">
<tr> <tr>
<td className="text-start p-3">Final Balance</td> <td className="text-start p-3">Final Balance</td>