* fix: resolve BFL compliance violations in general ledger and trial balance
Fix two compliance violations and a pre-existing double-counting bug:
1. .in(entryIds) truncation (BFL 5:2 completeness) — general-ledger.ts and
journal-register.ts used .in() with dynamic ID arrays that silently
truncate at ~1000 rows. Migrated to joined queries with fetchAllRows
pagination, matching the pattern already used by trial-balance.ts.
2. Trial balance missing IB columns (BFNAR 2013:2) — opening_debit and
opening_credit were hardcoded to 0. Now computed from the
opening_balance_entry (set by year-end closing) or by summing prior-
period entries as a fallback.
3. Double-counting after year-end closing — the opening_balance_entry's
lines were counted as both IB and period activity. Now excluded from
period queries via .neq() when the OB entry exists.
Extracted shared getOpeningBalances() helper used by both trial balance
and general ledger. Refactored test mocks from positional arrays to
table-keyed queues for readability.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add pagination and user_id filter to OB entry query
Address review feedback: the obEntryId fast path in getOpeningBalances
used a bare single-shot query without fetchAllRows (inconsistent with
the PR's truncation fix) and lacked the user_id defense-in-depth
filter required by CLAUDE.md guidelines.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>