import { useId, useState } from 'react' import { Stat } from '../ui' import { euroWhole } from '../../lib/financeFormat' import { breakdownRows, lowPointLines } from '../../lib/financeView' import { isNegText } from '../../lib/financeUi' const isNum = (v) => typeof v === 'number' && Number.isFinite(v) /** Block 1: Kontostand, „Verfügbar nach Rücklagen“ (mit Aufschlüsselung) und „Tiefster Stand in 30 Tagen“. */ export default function LiquidityHead({ kopf }) { const k = kopf && typeof kopf === 'object' ? kopf : {} const [open, setOpen] = useState(false) const listId = useId() const hasBalance = isNum(k.kontostandCents) const shortfall = isNum(k.verfuegbarCents) && k.verfuegbarCents < 0 const lows = lowPointLines(k) const balanceText = euroWhole(k.kontostandCents) return (
{shortfall &&
Rücklagen nicht gedeckt
} {isNum(k.verfuegbarCents) && ( <> {open && (
    {breakdownRows(k.aufschluesselung, k.verfuegbarCents).map((row) => (
  • {row.label} {row.text}
  • ))}
)} )} {!isNum(k.verfuegbarCents) &&
Ohne Kontostand nicht berechenbar
} } /> {lows.map( (low) => low && (
{low.label}: {low.amountText} am {low.dateText} {low.negative && · im Minus}
) )}
) : ( '–' ) } sub={lows.some(Boolean) ? '„erwartet“ zählt offene Rechnungen und Abos dazu' : 'Ohne Kontostand nicht berechenbar'} /> ) }