From ab6c2747facb55fe6853a1512553550ddc780389 Mon Sep 17 00:00:00 2001 From: renee-png Date: Sat, 13 Jun 2026 11:17:13 -0400 Subject: [PATCH] Reconciliation: cap unreconciled list at the statement date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show outstanding items dated on/before the statement_end_date (prior periods included), but hide anything dated after it — e.g. a 2/28/2026 statement shows 2/28 and earlier, nothing later. Co-Authored-By: Claude Opus 4.8 --- .../accounting/AccountingReconcileDetailPage.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/accounting/AccountingReconcileDetailPage.tsx b/src/pages/accounting/AccountingReconcileDetailPage.tsx index cfb7f6b..2fa9099 100644 --- a/src/pages/accounting/AccountingReconcileDetailPage.tsx +++ b/src/pages/accounting/AccountingReconcileDetailPage.tsx @@ -137,20 +137,21 @@ export default function AccountingReconcileDetailPage() { }); const { data: txs = [] } = useQuery({ - queryKey: ["recon-txs", accountId], + queryKey: ["recon-txs", accountId, active?.statement_end_date], enabled: !!accountId && !!active, queryFn: async () => { - // Show EVERY uncleared item for this account, regardless of its (billed) - // date — a transaction billed in one period often clears the bank in - // another, so the transaction date must not gate which reconciliation it - // can be cleared in. The only constraints: not already finalized into a - // completed reconciliation (reconciliation_id is null) and not voided. + // Show every uncleared item dated ON OR BEFORE the statement date — this + // INCLUDES outstanding items from prior periods (no floor) but EXCLUDES + // anything dated after the statement date. Constraints: not already + // finalized into a completed reconciliation (reconciliation_id is null) + // and not voided. const { data } = await accounting .from("transactions") .select("id,date,description,reference,amount,type,cleared,reconciliation_id,voided") .eq("account_id", accountId) .is("reconciliation_id", null) .eq("voided", false) + .lte("date", active!.statement_end_date) .order("date"); return (data ?? []) as Tx[]; },