Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-19 18:59:22 +00:00
co-authored by renee-png
parent 26a9f8cbb5
commit 23ca4e1a4e
+5 -14
View File
@@ -114,24 +114,15 @@ function InvoicesIndex() {
useEffect(() => { loadUnbilled(); }, []);
const filtered = useMemo(() => {
return invoices.filter((i) => {
if (status !== "all" && i.status !== status) return false;
if (!q) return true;
const s = q.toLowerCase();
return (
i.invoice_number?.toLowerCase().includes(s) ||
i.client?.name?.toLowerCase().includes(s) ||
i.case?.case_number?.toLowerCase().includes(s)
);
});
}, [invoices, q, status]);
const filtered = invoices;
const totals = useMemo(() => {
const outstanding = filtered.reduce((s, i) => s + (Number(i.total) - Number(i.amount_paid)), 0);
const paid = filtered.reduce((s, i) => s + Number(i.amount_paid), 0);
return { outstanding, paid, count: filtered.length };
}, [filtered]);
return { outstanding, paid, count: totalCount };
}, [filtered, totalCount]);
const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE));
// Classify each row: unbilled (no invoice_id), marked (linked to placeholder), real (linked to real invoice — not shown)
const isPlaceholder = (invId: string | null) => !!invId && placeholderIds.has(invId);