* fix(bokslut): surface unbooked transactions and AR/AP tie-outs in year-end preflight
Two gaps in the year-end readiness layer:
1. Unbooked bank transactions were enforced only by lockPeriod, which runs
at step 7 of executeYearEndClosing, AFTER the closing entry has posted at
step 4. A period with unbooked transactions reported ready: true from
gnubok_year_end_readiness and the wizard, then aborted mid-flow, leaving
a posted closing entry on an unlocked, unclosed period. The readiness
check now runs the same counter as the lock guard
(countUnbookedInPeriod, so the number reconciles with the "att bokföra"
badge) as a blocking error, failing closed if the check cannot run. The
lockPeriod guard stays as defense in depth. The MCP classifier tags the
new blocker as kind unbooked_transactions.
2. The Phase-1 avstamningar (kundreskontra vs 1510, leverantörsreskontra vs
2440) existed as reports (lib/reports/ar-reconciliation.ts,
supplier-reconciliation.ts) but were wired only to the ledger report
routes, never to the bokslut preflight. The readiness aggregator now runs
both tie-outs and surfaces mismatches as warning-severity reminders with
deep links, mirroring the bank-reconciliation reminder. Warnings only,
never blockers: a difference can be legitimate (FX-settled partials).
Skipped entirely for kontantmetod companies, where open invoices are
deliberately not on 1510/2440 until the year-end conversion exists and
the tie-out is permanently unreconciled by construction. Unconvertible-FX
rows produce a "could not reconcile" message instead of a phantom
difference.
YearEndValidation gains an optional unbookedTransactionCount field; the v1
compliance endpoint and MCP readiness tool pick the new blocker up
automatically since they share the same engine.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mcp): classify the next-period-IB readiness blocker instead of kind other
The blocker "Nästa räkenskapsperiod har redan ingående balanser bokförda"
was the only validateYearEndReadiness error with no classifier regex, so it
always surfaced as kind: 'other'.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(bokslut): log swallowed AR/AP tie-out failures in the readiness aggregator
Compliance-review finding: a rejected tie-out produced no reminder and no
log entry, making a failed avstämning control indistinguishable from a
reconciled one. Still degrades to no reminder (advisory check), but the
rejection reason is now traceable, mirroring the unbooked-transaction
check's logging.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>