Reconciliation: cap unreconciled list at the statement date

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 11:17:13 -04:00
parent 6ad7688fbd
commit ab6c2747fa
@@ -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[];
},