'use client' import { ArrowDown } from 'lucide-react' import { formatCurrency, formatDate } from '@/lib/utils' interface MatchTransactionInvoicePreviewProps { data: Record } /** * Two-card preview for `match_transaction_invoice` operations. Mirrors * AttachDocumentPreview's layout so reviewers learn one matching idiom. */ export function MatchTransactionInvoicePreview({ data }: MatchTransactionInvoicePreviewProps) { const txDescription = (data.transaction_description as string) || '-' const txAmount = data.transaction_amount as number | undefined const txCurrency = (data.transaction_currency as string) || 'SEK' const txDate = data.transaction_date as string | undefined const invoiceNumber = (data.invoice_number as string) || '-' const invoiceTotal = data.invoice_total as number | undefined const invoiceCurrency = (data.invoice_currency as string) || txCurrency const invoiceDate = data.invoice_date as string | undefined const customerName = data.customer_name as string | undefined // BFL 5 kap 4§ requires bookings to be made "so soon as possible" relative // to the affärshändelse, so a transaction and invoice that diverge by more // than a calendar month deserve a second look before the reviewer approves // the match. The threshold is editorial, not legislated: it just nudges // the reviewer; it doesn't block. const showDateDriftHint = txDate && invoiceDate && Math.abs(new Date(txDate).getTime() - new Date(invoiceDate).getTime()) > 31 * 24 * 60 * 60 * 1000 return (
{txDate && } {invoiceDate && } {customerName && } {typeof invoiceTotal === 'number' && ( )}
matchas mot fakturan
{showDateDriftHint && (

Transaktionsdatum och fakturadatum skiljer sig med mer än en månad: kontrollera att matchningen avser rätt affärshändelse.

)}
) } function PreviewCard({ label, children }: { label: string; children: React.ReactNode }) { return (

{label}

{children}
) } function Row({ label, value, tabular }: { label: string; value: string; tabular?: boolean }) { return (
{label} {value}
) }