'use client' import { AccountNumber } from '@/components/ui/account-number' import { buildCorrectionRows, formatSignedAmount, type CorrectionLineInput, } from '@/components/bookkeeping/correction-preview-rows' import type { JournalEntryLine } from '@/types' interface Props { originalLines: JournalEntryLine[] correctedLines: CorrectionLineInput[] } function signClass(n: number): string { if (n > 0) return 'text-success' if (n < 0) return 'text-destructive' return 'text-muted-foreground' } export default function CorrectionPreview({ originalLines, correctedLines }: Props) { const rows = buildCorrectionRows(originalLines, correctedLines) const hasAnyCorrection = correctedLines.some((l) => { if (l.account_number.length !== 4) return false const d = typeof l.debit_amount === 'string' ? parseFloat(l.debit_amount) : l.debit_amount const c = typeof l.credit_amount === 'string' ? parseFloat(l.credit_amount) : l.credit_amount return (Number.isFinite(d) && d > 0) || (Number.isFinite(c) && c > 0) }) if (rows.length === 0) return null return (

Effekt per konto

Debet − Kredit

{rows.map((row) => ( ))}
Konto Original Storno Rättelse Förändring
{formatSignedAmount(row.original)} {formatSignedAmount(row.storno)} {hasAnyCorrection ? formatSignedAmount(row.correction) : '–'} {hasAnyCorrection ? formatSignedAmount(row.delta) : '–'}
{rows.map((row) => (
{hasAnyCorrection ? formatSignedAmount(row.delta) : '–'}
Original
{formatSignedAmount(row.original)}
Storno
{formatSignedAmount(row.storno)}
Rättelse
{hasAnyCorrection ? formatSignedAmount(row.correction) : '–'}
))}

Förändring = storno + rättelse. Det är det netto som tillkommer ovanpå originalet när du bokför.

) }