From 8dcf7647820ae1fb3f44081682b8eb2ddabe8cd9 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:15:01 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/collections.index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/routes/collections.index.tsx b/src/routes/collections.index.tsx index bceedce..e66873c 100644 --- a/src/routes/collections.index.tsx +++ b/src/routes/collections.index.tsx @@ -73,7 +73,7 @@ function CollectionsIndexPage() { const [{ data: ents }, { data: tasks }] = await Promise.all([ supabase .from("collection_ledger_entries") - .select("collection_id, debit, credit") + .select("collection_id, assess, late, admin, legal, viol, interest, bank, payment, debit, credit") .in("collection_id", ids), supabase .from("collection_tasks") @@ -85,9 +85,13 @@ function CollectionsIndexPage() { list.forEach((c: any) => { balMap[c.id] = Number(c.homeowner?.opening_balance ?? 0); }); + const num = (v: any) => Number(v) || 0; (ents ?? []).forEach((e: any) => { - balMap[e.collection_id] = - (balMap[e.collection_id] ?? 0) + Number(e.debit) - Number(e.credit); + const charges = + num(e.assess) + num(e.late) + num(e.admin) + num(e.legal) + + num(e.viol) + num(e.interest) + num(e.bank) + num(e.debit); + const credits = num(e.payment) + num(e.credit); + balMap[e.collection_id] = (balMap[e.collection_id] ?? 0) + charges - credits; }); setBalances(balMap);