mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
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:
@@ -137,20 +137,21 @@ export default function AccountingReconcileDetailPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { data: txs = [] } = useQuery({
|
const { data: txs = [] } = useQuery({
|
||||||
queryKey: ["recon-txs", accountId],
|
queryKey: ["recon-txs", accountId, active?.statement_end_date],
|
||||||
enabled: !!accountId && !!active,
|
enabled: !!accountId && !!active,
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
// Show EVERY uncleared item for this account, regardless of its (billed)
|
// Show every uncleared item dated ON OR BEFORE the statement date — this
|
||||||
// date — a transaction billed in one period often clears the bank in
|
// INCLUDES outstanding items from prior periods (no floor) but EXCLUDES
|
||||||
// another, so the transaction date must not gate which reconciliation it
|
// anything dated after the statement date. Constraints: not already
|
||||||
// can be cleared in. The only constraints: not already finalized into a
|
// finalized into a completed reconciliation (reconciliation_id is null)
|
||||||
// completed reconciliation (reconciliation_id is null) and not voided.
|
// and not voided.
|
||||||
const { data } = await accounting
|
const { data } = await accounting
|
||||||
.from("transactions")
|
.from("transactions")
|
||||||
.select("id,date,description,reference,amount,type,cleared,reconciliation_id,voided")
|
.select("id,date,description,reference,amount,type,cleared,reconciliation_id,voided")
|
||||||
.eq("account_id", accountId)
|
.eq("account_id", accountId)
|
||||||
.is("reconciliation_id", null)
|
.is("reconciliation_id", null)
|
||||||
.eq("voided", false)
|
.eq("voided", false)
|
||||||
|
.lte("date", active!.statement_end_date)
|
||||||
.order("date");
|
.order("date");
|
||||||
return (data ?? []) as Tx[];
|
return (data ?? []) as Tx[];
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user