Files
accounted/components/reports
Jakob Wennberg 027734ffc7 fix(reconciliation): scope bank avstämning to a fiscal period so the IB stops counting (#751) (#754)
* fix(reconciliation): scope bank reconciliation to a fiscal period so the IB stops counting (#751)

The bank reconciliation widget defaulted its date window to "full history"
(empty dateFrom). With no lower bound the GL side spans the fiscal-year
boundary: a prior period's movements on the account net to exactly the
opening balance, and the new period's IB entry adds another copy. The IB
*summary* was excluded but the prior-period *detail* stayed in the period
movement while the bank feed only covered the current period — a phantom
difference equal to the IB (the "räknar med IB fast den säger borträknad"
report in #751).

- Server: getReconciliationStatus now floors the window at the most recent
  opening-balance date on the account (effectiveFrom = max(dateFrom, ibDate))
  and clamps both the GL movement set and the bank-feed set identically.
  Derived from the already-fetched lines — no extra query. A no-op when the
  caller already passes period_start; a safety net otherwise.
- UI: BankReconciliationView scopes to a fiscal period via FiscalYearSelector
  (defaults to the newest period), seeding dateFrom/dateTo and gating the
  initial fetch so the full-history numbers never flash.
- Tests: two regression cases reproducing the cross-period scenario.

Proven against prod: full-history -> difference -10 172,94 (matched the
screenshot); period-bounded -> 0,00.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(reconciliation): re-fetch on fiscal-period switch; document IB-floor choice

Review follow-up on #754:
- BankReconciliationView: add selectedPeriodId to the gated fetch effect deps
  so switching räkenskapsår re-fetches with the new window, and a late period
  selection (selector signalling ready before the company context hydrates) still
  triggers the real period-scoped fetch instead of leaving the empty-window
  result. Manual date edits still stay on the explicit "Filtrera" action.
- getReconciliationStatus: comment why ibFloor takes the LATEST opening-balance
  date (one IB per period invariant; across a multi-year window the most recent
  IB is the intended floor; same-date duplicates cancel).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(reconciliation): cover mid-period window (dateFrom after the IB date)

Review follow-up on #754: documents that a per-month reconciliation window
starting after the fiscal-year IB correctly excludes the IB and reconciles on
the in-window movements alone (gl_1930_opening_balance = 0 by design).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 13:49:00 +02:00
..
2026-06-08 07:37:24 +02:00