Changes in Advance PaymentList.
This commit is contained in:
parent
a253eea33c
commit
dfaf90ccac
@ -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 (
|
||||||
@ -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 ? (
|
||||||
|
data.map((row) => (
|
||||||
<tr key={row.id}>
|
<tr key={row.id}>
|
||||||
{columns.map((col) => (
|
{columns.map((col) => (
|
||||||
<td key={col.key} className={`${col.align} p-2`}>
|
<td key={col.key} className={`${col.align} p-2`}>
|
||||||
{["balance", "credit", "debit"].includes(col.key) ? (
|
{col.key === "credit" ? (
|
||||||
<span>
|
row.amount > 0 ? (
|
||||||
{row[col.key].toLocaleString("en-IN")}
|
<span>{row.amount.toLocaleString("en-IN")}</span>
|
||||||
</span>
|
) : (
|
||||||
|
"-"
|
||||||
|
)
|
||||||
|
) : col.key === "debit" ? (
|
||||||
|
row.amount < 0 ? (
|
||||||
|
<span>{Math.abs(row.amount).toLocaleString("en-IN")}</span>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
)
|
||||||
|
) : col.key === "balance" ? (
|
||||||
|
<span>{row.currentBalance?.toLocaleString("en-IN")}</span>
|
||||||
) : (
|
) : (
|
||||||
<div className="d-flex flex-column text-start">
|
<div className="d-flex flex-column text-start">
|
||||||
<small className="text-muted">
|
<small className="text-muted">
|
||||||
{formatUTCToLocalTime(row.createdAt)}
|
{formatUTCToLocalTime(row.paidAt)}
|
||||||
</small>
|
</small>
|
||||||
<small className="fw-semibold text-dark">
|
<small className="fw-semibold text-dark">
|
||||||
{row.projectName}
|
{row.project?.name || "-"}
|
||||||
</small>
|
</small>
|
||||||
<small>{row.description}</small>
|
<small>{row.title || "-"}</small>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
))}
|
))}
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td colSpan={columns.length} className="text-center text-muted py-3">
|
||||||
|
No advance payment records found.
|
||||||
|
</td>
|
||||||
|
</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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user