mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 01:40:01 +00:00
Owner ledger: exclude archived entries from balance/breakdown views
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 <noreply@anthropic.com>
This commit is contained in:
@@ -19,12 +19,14 @@ export default function UnitLedgerAccountBreakdown({ unitId }: Props) {
|
|||||||
if (!unitId) return;
|
if (!unitId) return;
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
setLoading(true);
|
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
|
const { data } = await supabase
|
||||||
.from("owner_ledger_entries")
|
.from("owner_ledger_entries")
|
||||||
.select("id, transaction_type, description, debit, credit, date, created_at, owners!inner(status)")
|
.select("id, transaction_type, description, debit, credit, date, created_at, owners!inner(status)")
|
||||||
.eq("unit_id", unitId)
|
.eq("unit_id", unitId)
|
||||||
.eq("owners.status", "active")
|
.eq("owners.status", "active")
|
||||||
|
.not("is_archived", "is", true)
|
||||||
.order("date", { ascending: true })
|
.order("date", { ascending: true })
|
||||||
.order("created_at", { ascending: true })
|
.order("created_at", { ascending: true })
|
||||||
.order("id", { ascending: true });
|
.order("id", { ascending: true });
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ export default function CollectionsPage() {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("owner_ledger_entries")
|
.from("owner_ledger_entries")
|
||||||
.select("owner_id, transaction_type, debit, credit, date")
|
.select("owner_id, transaction_type, debit, credit, date")
|
||||||
|
.not("is_archived", "is", true)
|
||||||
.range(from, from + pageSize - 1);
|
.range(from, from + pageSize - 1);
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
if (!data || data.length === 0) break;
|
if (!data || data.length === 0) break;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export default function OutstandingBalancesPage() {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("owner_ledger_entries")
|
.from("owner_ledger_entries")
|
||||||
.select("owner_id, transaction_type, description, debit, credit, date")
|
.select("owner_id, transaction_type, description, debit, credit, date")
|
||||||
|
.not("is_archived", "is", true)
|
||||||
.range(from, from + pageSize - 1);
|
.range(from, from + pageSize - 1);
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
all.push(...(data || []));
|
all.push(...(data || []));
|
||||||
|
|||||||
Reference in New Issue
Block a user