'use client' import { useMemo } from 'react' import { formatCurrency } from '@/lib/utils' import { formatAccountWithName } from '@/lib/bookkeeping/client-account-names' import { computeProposalLines } from '@/lib/bookkeeping/proposal-lines' import type { ProposalLinesInput } from '@/lib/bookkeeping/proposal-lines' export type JournalEntryPreviewProps = ProposalLinesInput export default function JournalEntryPreview(props: JournalEntryPreviewProps) { const { amount, amountSek, category, vatTreatment, accountOverride, entityType, templateDebitAccount, templateCreditAccount, templateVatRate, templateVatTreatment, templateSupplierType, counterpartyLegacy, linePattern, settlementAccount, } = props // Line computation lives in lib/bookkeeping/proposal-lines.ts, shared with // the "Andra rader" prefill so preview and editable lines never drift. const lines = useMemo( () => computeProposalLines({ amount, amountSek, category, vatTreatment, accountOverride, entityType, templateDebitAccount, templateCreditAccount, templateVatRate, templateVatTreatment, templateSupplierType, counterpartyLegacy, linePattern, settlementAccount, }), [amount, amountSek, category, vatTreatment, accountOverride, entityType, templateDebitAccount, templateCreditAccount, templateVatRate, templateVatTreatment, templateSupplierType, counterpartyLegacy, linePattern, settlementAccount] ) if (lines.length === 0) return null return (
Verifikation