diff --git a/src/components/AdvancePayment/AdvancePaymentList.jsx b/src/components/AdvancePayment/AdvancePaymentList.jsx index 0f975ab5..e14f9c06 100644 --- a/src/components/AdvancePayment/AdvancePaymentList.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList.jsx @@ -7,7 +7,7 @@ import Loader, { SpinnerLoader } from "../common/Loader"; const AdvancePaymentList = ({ employeeId }) => { const { data, isError, isLoading, error, isFetching } = useExpenseTransactions(employeeId, { enabled: !!employeeId }); - + console.log(data) // Handle no employee selected if (!employeeId) { return ( @@ -27,7 +27,7 @@ const AdvancePaymentList = ({ employeeId }) => { className="d-flex justify-content-center align-items-center" style={{ height: "200px" }} > - + ); } @@ -104,7 +104,7 @@ const AdvancePaymentList = ({ employeeId }) => { ); } - + console.log("Kartik", rowsWithBalance) return (
@@ -118,30 +118,49 @@ const AdvancePaymentList = ({ employeeId }) => { - {rowsWithBalance.map((row) => ( - - {columns.map((col) => ( - - ))} + {Array.isArray(data) && data.length > 0 ? ( + data.map((row) => ( + + {columns.map((col) => ( + + ))} + + )) + ) : ( + + - ))} + )} +
- {["balance", "credit", "debit"].includes(col.key) ? ( - - {row[col.key].toLocaleString("en-IN")} - - ) : ( -
- - {formatUTCToLocalTime(row.createdAt)} - - - {row.projectName} - - {row.description} -
- )} -
+ {col.key === "credit" ? ( + row.amount > 0 ? ( + {row.amount.toLocaleString("en-IN")} + ) : ( + "-" + ) + ) : col.key === "debit" ? ( + row.amount < 0 ? ( + {Math.abs(row.amount).toLocaleString("en-IN")} + ) : ( + "-" + ) + ) : col.key === "balance" ? ( + {row.currentBalance?.toLocaleString("en-IN")} + ) : ( +
+ + {formatUTCToLocalTime(row.paidAt)} + + + {row.project?.name || "-"} + + {row.title || "-"} +
+ )} +
+ No advance payment records found. +
Final Balance