From 46b085584091a9121c638dc16c45a340698f3758 Mon Sep 17 00:00:00 2001 From: renee-png Date: Tue, 16 Jun 2026 21:00:07 -0400 Subject: [PATCH] Owner ledger: exclude archived entries from balance/breakdown views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Archived (voided/duplicate) owner_ledger_entries were still counted in the per-unit account breakdown, Collections, and Outstanding Balances — inflating totals (e.g. 2455-VL showed $4K in violations vs the real $3K after a duplicate was archived). Filter out archived entries in all three, matching the canonical Unit Ledger view. Co-Authored-By: Claude Opus 4.8 --- src/components/unit-profile/UnitLedgerAccountBreakdown.tsx | 4 +++- src/pages/CollectionsPage.tsx | 1 + src/pages/OutstandingBalancesPage.tsx | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/unit-profile/UnitLedgerAccountBreakdown.tsx b/src/components/unit-profile/UnitLedgerAccountBreakdown.tsx index d44b495..c9e9581 100644 --- a/src/components/unit-profile/UnitLedgerAccountBreakdown.tsx +++ b/src/components/unit-profile/UnitLedgerAccountBreakdown.tsx @@ -19,12 +19,14 @@ export default function UnitLedgerAccountBreakdown({ unitId }: Props) { if (!unitId) return; const fetchData = async () => { setLoading(true); - // Account breakdown reflects the active ledger only — exclude entries from archived owners. + // Account breakdown reflects the active ledger only — exclude entries from + // archived owners and archived (voided/duplicate) ledger entries. const { data } = await supabase .from("owner_ledger_entries") .select("id, transaction_type, description, debit, credit, date, created_at, owners!inner(status)") .eq("unit_id", unitId) .eq("owners.status", "active") + .not("is_archived", "is", true) .order("date", { ascending: true }) .order("created_at", { ascending: true }) .order("id", { ascending: true }); diff --git a/src/pages/CollectionsPage.tsx b/src/pages/CollectionsPage.tsx index 27aff0b..5c474b4 100644 --- a/src/pages/CollectionsPage.tsx +++ b/src/pages/CollectionsPage.tsx @@ -250,6 +250,7 @@ export default function CollectionsPage() { const { data, error } = await supabase .from("owner_ledger_entries") .select("owner_id, transaction_type, debit, credit, date") + .not("is_archived", "is", true) .range(from, from + pageSize - 1); if (error) throw error; if (!data || data.length === 0) break; diff --git a/src/pages/OutstandingBalancesPage.tsx b/src/pages/OutstandingBalancesPage.tsx index 886ab0c..24f1250 100644 --- a/src/pages/OutstandingBalancesPage.tsx +++ b/src/pages/OutstandingBalancesPage.tsx @@ -130,6 +130,7 @@ export default function OutstandingBalancesPage() { const { data, error } = await supabase .from("owner_ledger_entries") .select("owner_id, transaction_type, description, debit, credit, date") + .not("is_archived", "is", true) .range(from, from + pageSize - 1); if (error) throw error; all.push(...(data || []));