diff --git a/src/pages/accounting/AccountingBankingPage.tsx b/src/pages/accounting/AccountingBankingPage.tsx index b739654..6392985 100644 --- a/src/pages/accounting/AccountingBankingPage.tsx +++ b/src/pages/accounting/AccountingBankingPage.tsx @@ -172,16 +172,29 @@ export default function AccountingBankingPage() { const { data: txs = [] } = useQuery({ queryKey: ["transactions", cid, activeAccountId], enabled: !!cid && !!activeAccountId, - queryFn: async () => - ( - await accounting + queryFn: async () => { + // PostgREST caps each response at 1000 rows; an account with a long + // register (e.g. an imported bank account) would truncate, throwing off + // the running balance. Page through all rows ordered by a stable key. + const PAGE = 1000; + const out: any[] = []; + for (let offset = 0; ; offset += PAGE) { + const { data, error } = await accounting .from("transactions") .select("*, bank_account:accounts!account_id(name), coa:accounts!coa_account_id(name), vendors(name), customers(name)") .eq("company_id", cid) .eq("account_id", activeAccountId) .order("date", { ascending: true }) .order("created_at", { ascending: true }) - ).data ?? [], + .order("id", { ascending: true }) + .range(offset, offset + PAGE - 1); + if (error) throw error; + const rows = data ?? []; + out.push(...rows); + if (rows.length < PAGE) break; + } + return out; + }, }); const register = useMemo(() => {