* fix(bokslut): make dispositions storno-safe and derive fond math from opening balances
A reversed year_end voucher kept its storno in the income statement while
the original was excluded (source_type asymmetry), inflating resultat fore
dispositioner by exactly the reversed amount, and the posted-only fond
balance produced a phantom negative 212X that leaked a bogus aterforing
proposal. Support case: a user double-booked periodiseringsfond, reversed
both correctly, and the dispositions page still showed wrong numbers.
- trial-balance excludeYearEndClosing now also excludes entries chained to
reversed year_end entries via reverses_id/correction_of_id (grammar
verified against staging PostgREST)
- listExistingPeriodiseringsfonder counts posted+reversed so storno pairs
cancel, and returns opening balances per fond
- schablonintakt per IL 30 kap 6a: opening balance base, rate = SLR per
closing year (1.96% FY2025, 2.55% FY2026), replacing the wrong SLR+1pp
0.0355 constant
- avsattning 25% cap is year-total: already-provisioned current-cohort
growth consumes headroom in both preview and commit, so re-running the
flow can no longer double-book the fond
- SLP posts before avsattning (deductible, shrinks the cap base) and is
posted-aware: no double proposal or double count on resumed runs
- sumPostedYearEndDispositions counts correction replacements of reversed
year_end entries and exposes the SLP portion
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(bokslut): use roundOre for new fond/disposition rounding
Satisfies the naive-ore-round ratchet that tightened on main; identical
arithmetic, pinned by the existing exact-value tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(bokslut): address PR #1063 review findings
- computeProposal receives the already-validated period row: a transient
DB failure can no longer silently skip a requested disposition (and two
redundant per-item period fetches are gone)
- getSchablonintaktRate fails closed for unmapped years instead of
falling back to the latest known rate: statutory rates are never
guessed; POST rate override remains the escape hatch
- listExistingPeriodiseringsfonder is opening-balance-entry aware:
a fond carried via the OB entry booked by year-end closing was counted
twice (once from history, once from the OB entry); balances now derive
from OB + current-period activity when an OB entry exists
- periodStart is validated as a real calendar date, not just a shape
- reversed year_end correction targets resolve company-wide in
sumPostedYearEndDispositions, matching the trial balance exclusion
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>