* chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers
Remove 33 dead files, ~270 unreferenced exports/types, 13 dead i18n
namespaces and 4 unused dependencies; fold byte-identical helper copies
into one canonical home each (lib/utils chunk/sleep/utcDateStamp,
lib/dates/iso, lib/invariants/uuid, lib/xml/escape, lib/reports/sru/format,
lib/pdf/number-text, lib/browser/panel-request, lib/api/v1/body +
v1ValidationError rolled out to ~55 v1 routes, booking-template schemas).
No behaviour change: v1 bodies and status codes, MCP tool schemas, DB
writes and money math are untouched. Naive ore rounding was deliberately
not swapped for roundOre; see DECISIONS.md 2026-09-02 for the full list
of things left alone on purpose.
tsc, lint, 19588 unit tests and check:guards green; antipattern baseline
ratcheted (naive-ore-round 622 -> 620, hand-rolled-invariant 115 -> 113).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* test(transactions): import RawTransaction from @/types after the ingest re-export removal
CI's type ratchet (check:types, full tsconfig) caught the one test file
that still imported the type through lib/transactions/ingest.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* feat(reconciliation): skattekonto bridge engine, sync-time twin proposals, account-keyed facade
The engine half of the reconciliation page (design: Avstämningsmotorn).
- lib/reconciliation/skattekonto-reconciliation.ts: getSkattekontoReconciliationStatus
anchors at the saldo snapshot and returns the bridge (saldo hos Skatteverket,
händelser som saknas, 1630-rader utan händelse, ignorerade, ingående skillnad,
bokfört), the item buckets the page shows (proposed, unmatched external,
unmatched ledger, matched, ignored, upcoming), opening_difference,
unexplained_difference (0,00 by construction when data is consistent),
dead-link handling (a link to a reversed/draft entry counts as unlinked and is
flagged), awaiting_external for ledger lines within 5 days of the snapshot,
staleness, and a window that scopes item lists without hiding older rows.
Core reads skattekonto_transactions and the extension's snapshot row directly;
no @/extensions import.
- lib/reconciliation/gl-balance.ts: one ledger-balance helper with the
trial-balance predicate status IN (posted, reversed). The drift check summed
posted only, which misstated 1630 for any company with a storno on the account;
skattekonto-drift.ts now delegates to the helper.
- Proposals at sync: migration 20260823120000 adds suggested_journal_entry_id /
suggested_at (ON DELETE SET NULL, partial index on open rows); the sync calls
refreshSkattekontoProposals after the upsert. findMatchSuggestionsBulk now
assigns one-to-one across rows (AGI period first, then nearest date) and falls
back to an entry whose 1630 lines net to the amount (split lines); a proposal
is never a link.
- lib/reconciliation/service.ts + schemas.ts: the account-keyed facade
(bank:<cash_account_id> | skattekonto | manual:NNNN) with listReconciliationAccounts
(enabled cash accounts folded per IBAN, skattekonto when configured) and
getAccountStatus dispatching to the bank engine or the new one; shared Zod
shapes for the v1 registry, MCP schemas and the UI (PR 2).
Tests: identity on a mixed fixture, storno pair, stale snapshot, awaiting window,
window scoping, failed ledger read, live-linked entries never proposed; matcher
one-to-one and split-line cases; proposal refresh writes/clears; service
dedupe and dispatch. No UI in this PR.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(reconciliation): roundOre instead of inline öre rounding (guard ratchet)
The antipattern ratchet counts Math.round(x*100)/100; the new engine used it in
five places. Switch to roundOre from @/lib/money and ratchet the baseline down
by the three occurrences this removes net of the matcher rewrite.
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>