fix(booking): explicit Ingen moms in quick review books exempt, not the derived default (#1450)

QuickReviewDialog collapsed 'none' to undefined on the wire, so the server
re-derived the category default and booked 25% moms against an explicit
no-VAT choice while the preview showed no VAT line. 'none' now maps to
'exempt' only when it deviates from the seeded default: untouched bookings
on exempt-default categories (bank fees) stay byte-identical, an explicit
Ingen moms books no VAT line with the classification the momsdeklaration
should see, and the class-2 account auto-'none' stops booking a stray moms
line. Same gap the swedish-compliance bot flagged on #1443.

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-08-07 14:58:46 +02:00
committed by GitHub
co-authored by Jakob Wennberg Claude Fable 5
parent 7c93d53fd5
commit 858ad49852
4 changed files with 58 additions and 2 deletions
@@ -15,6 +15,7 @@ import { getDefaultAccountForCategory } from '@/lib/bookkeeping/category-mapping
import { isCounterpartyTemplateId } from '@/lib/bookkeeping/counterparty-templates'
import { getVatRate } from '@/lib/bookkeeping/vat-entries'
import type { ReviewTemplate } from '@/lib/transactions/quick-review-defaults'
import { resolveExplicitVat } from '@/lib/transactions/quick-review-defaults'
import { resolveSekAmount } from '@/lib/bookkeeping/currency-utils'
import { formatAccountWithName } from '@/lib/bookkeeping/client-account-names'
import JournalEntryPreview from './JournalEntryPreview'
@@ -250,7 +251,12 @@ export default function QuickReviewDialog({
setIsProcessing(true)
setError(null)
try {
const resolvedVat = vatTreatment === 'none' ? undefined : vatTreatment
// 'none' as the seeded default stays off the wire (server derives, no
// VAT line); 'none' as a user deviation goes as explicit 'exempt'. The
// old unconditional collapse re-derived the default server-side and
// booked 25% moms against an explicit "Ingen moms" while the preview
// showed none. See resolveExplicitVat.
const resolvedVat = resolveExplicitVat(vatTreatment, defaultVat)
const catDefault = getDefaultAccountForCategory(category)
const override = accountOverride && accountOverride !== catDefault
? accountOverride