From 920def8826a7036d98ac5c6bc44b52af67dcc8fb Mon Sep 17 00:00:00 2001 From: renee-png Date: Fri, 12 Jun 2026 20:27:18 -0400 Subject: [PATCH] Reports: archived accounts hidden everywhere except the General Ledger - fetchAllGLLines filters accounts.is_archived=false, covering P&L, Balance Sheet, Cash Flow, Movement of Equity and Income Statement in one place - Trial Balance, Reserve Fund Schedule and Budget vs Actuals account lists exclude archived; Banking page hides archived accounts from cards/pickers - General Ledger report intentionally keeps archived accounts (history) Co-Authored-By: Claude Opus 4.8 --- src/pages/accounting/AccountingBankingPage.tsx | 3 ++- src/pages/accounting/AccountingReportsPage.tsx | 7 +++++-- src/pages/accounting/components/ReserveFundReport.tsx | 1 + src/pages/accounting/components/TrialBalanceReport.tsx | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/accounting/AccountingBankingPage.tsx b/src/pages/accounting/AccountingBankingPage.tsx index 3b5b00a..0e8a812 100644 --- a/src/pages/accounting/AccountingBankingPage.tsx +++ b/src/pages/accounting/AccountingBankingPage.tsx @@ -139,7 +139,8 @@ export default function AccountingBankingPage() { queryKey: ["accounts", cid], enabled: !!cid, queryFn: async () => - (await accounting.from("accounts").select("*").eq("company_id", cid).order("code")).data ?? [], + // Archived accounts are hidden from Banking (cards + category pickers) + (await accounting.from("accounts").select("*").eq("company_id", cid).eq("is_archived", false).order("code")).data ?? [], }); const bankAccounts = useMemo(() => (accounts as any[]).filter((a) => a.is_bank), [accounts]); diff --git a/src/pages/accounting/AccountingReportsPage.tsx b/src/pages/accounting/AccountingReportsPage.tsx index 4127fb4..e50cc46 100644 --- a/src/pages/accounting/AccountingReportsPage.tsx +++ b/src/pages/accounting/AccountingReportsPage.tsx @@ -107,6 +107,9 @@ async function fetchAllGLLines(cid: string, to: string, select: string, from?: s .from("journal_entry_lines") .select(select) .eq("journal_entries.company_id", cid) + // Archived accounts stay off the financial statements (their history + // remains visible in the General Ledger report, which queries directly). + .eq("accounts.is_archived", false) .lte("journal_entries.date", to); if (from) q = q.gte("journal_entries.date", from); const { data, error } = await q.order("id", { ascending: true }).range(offset, offset + GL_PAGE - 1); @@ -128,7 +131,7 @@ function useReportData(cid: string, from: string, to: string) { const [inv, bills, accs, exp, custs, vends, ob, ytdInv, ytdExp, ytdBills, allBills, glRes, glCumRes, allInvRes, companyRes] = await Promise.all([ accounting.from("invoices").select("number,total,paid_amount,status,issue_date,customers(name)").eq("company_id", cid).gte("issue_date", from).lte("issue_date", to), accounting.from("bills").select("number,total,paid_amount,status,issue_date,due_date,vendors(name)").eq("company_id", cid).gte("issue_date", from).lte("issue_date", to), - accounting.from("accounts").select("id,name,code,type,subtype,balance,is_bank").eq("company_id", cid), + accounting.from("accounts").select("id,name,code,type,subtype,balance,is_bank").eq("company_id", cid).eq("is_archived", false), accounting.from("expenses").select("date,category,amount,vendor_name,vendors(name)").eq("company_id", cid).gte("date", from).lte("date", to), accounting.from("customers").select("id,name,balance,email,phone,property_address,lot_number").eq("company_id", cid).order("name"), accounting.from("vendors").select("id,name").eq("company_id", cid), @@ -1794,7 +1797,7 @@ function BudgetVsActuals({ companyId, from, to, currency, companyName, rangeLabe const { data: accounts = [] } = useQuery({ queryKey: ["accounts", companyId], enabled: !!companyId, - queryFn: async () => (await accounting.from("accounts").select("*").eq("company_id", companyId).order("code")).data ?? [], + queryFn: async () => (await accounting.from("accounts").select("*").eq("company_id", companyId).eq("is_archived", false).order("code")).data ?? [], }); const { data: entries = [] } = useQuery({ diff --git a/src/pages/accounting/components/ReserveFundReport.tsx b/src/pages/accounting/components/ReserveFundReport.tsx index c181e33..2e51c71 100644 --- a/src/pages/accounting/components/ReserveFundReport.tsx +++ b/src/pages/accounting/components/ReserveFundReport.tsx @@ -82,6 +82,7 @@ export function ReserveFundReport({ .select("id,name,code,type,is_reserve") .eq("company_id", companyId) .eq("is_reserve", true) + .eq("is_archived", false) // archived accounts stay off reports .order("code", { ascending: true }); return (data ?? []) as ReserveAccount[]; }, diff --git a/src/pages/accounting/components/TrialBalanceReport.tsx b/src/pages/accounting/components/TrialBalanceReport.tsx index 34ac094..8be90bf 100644 --- a/src/pages/accounting/components/TrialBalanceReport.tsx +++ b/src/pages/accounting/components/TrialBalanceReport.tsx @@ -66,6 +66,7 @@ export function TrialBalanceReport({ companyId, companyName, logoUrl }: { compan .from("accounts") .select("id,name,code,type,subtype") .eq("company_id", companyId) + .eq("is_archived", false) // archived accounts stay off reports (GL report keeps them) .order("code", { ascending: true }); return (data ?? []) as Omit[]; },