* feat(vat): book the momsrapport as an editable settlement verifikat (#980)
Adds a "Bokfor momsrapporten" card under the VAT declaration that builds
an editable verifikat proposal from the report and books it through the
ordinary journal entry form:
- lib/reports/vat-settlement.ts: proposal builder. Clears each 26xx
account at exact ore, books the net on 2650 (att betala) or 1650 (att
aterfa) at the filed whole-krona amount (buildFiledAmounts, oretal
faller bort per SFL 22 kap 1 par), balances the gap on 3740. Surfaces
existing vat_settlement entries in the period so the UI can warn
before a double booking.
- GET /api/reports/vat-declaration/settlement-proposal: same period
params as the sibling report routes.
- VatBookingCard (reports view): fetches the proposal, warns when the
period already has a posted settlement or draft, and opens the
JournalEntryForm (bare, prefilled, source_type vat_settlement) in a
dialog so every line is editable before committing. Booking uses the
existing engine path: balance validation, period locks, voucher
series per source type.
- vat_settlement entries are excluded from the declaration projection
(calculateVatDeclaration via new shared fetchVatAccountTotals, and
the MCP computeVatReport for parity): a pure-projection report would
otherwise read zero, and a later Skatteverket submission would file
zeros, the moment the settlement is booked.
No migration needed: the vat_settlement source type shipped in
20260708100000.
Closes#980
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(vat): block re-booking a settled period, fail loud on lookup errors (CodeRabbit)
The proposal is not delta-aware (it re-clears the FULL period), so a
second booking while a posted settlement exists would corrupt the 26xx
balances: disable "Skapa verifikat" until that verifikat is annulled
(storno restores the balances). And since the existing-settlement
lookup now gates that button, a swallowed query error would silently
re-enable it: throw instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>