'use client' import { useTranslations } from 'next-intl' import { TD_CLASS, TH_CLASS } from '@/components/ui/dry-table' import type { ObservedRow, Register } from '@/lib/parties/register' import { formatCurrency } from '@/lib/utils' import { AccountNub } from './AccountNub' import { rhythmLabel } from './format' function money(n: number): string { return n ? formatCurrency(n) : '' } /** * "Bara i bokföringen": counterparts the ledger names that no party claims. * Computed, never stored; the generic band keeps unattributed spend visible * without inventing a supplier for "Inköp av varor". */ export function ObservedTable({ rows, generic }: { rows: ObservedRow[]; generic: Register['generic'] }) { const t = useTranslations('parties') return (
{rows.map((row) => ( ))} {generic.count > 0 ? ( ) : null}
{t('th_name')} {t('th_rhythm')} {t('th_vouchers')} {t('th_account')} {t('th_revenue')} {t('th_expense')}
{row.name} {row.label === 'unsure' ? {t('uncertain_name')} : null} {rhythmLabel(t, row.stats.rhythm)} {t('vouchers_count', { count: row.stats.occurrences })} {money(row.stats.revenueSek)} {money(row.stats.expenseSek)}
{t('generic_band', { count: generic.count })} {t('generic_band_description', { examples: generic.examples.join(' · ') })} {money(generic.expenseSek)}
) }