import Link from "next/link"; import { Badge } from "@/components/ui/badge"; import { tr } from "@/i18n/tr"; import { cn } from "@/lib/utils"; import { formatMoney } from "@/shared/format"; import { formatAssetQuantity } from "@/shared/assets"; import type { AssetsReport, ContactsReport } from "../extra"; import { dayLabel } from "./report-frame"; const signed = (n: number) => `${n > 0 ? "+" : n < 0 ? "−" : ""}${formatMoney(Math.abs(n))}`; const bp = (n: number | null) => n === null ? "" : ` (${n < 0 ? "−" : "+"}%${(Math.abs(n) / 100).toLocaleString("tr-TR", { maximumFractionDigits: 1 })})`; function Stat({ label, value, tone }: { label: string; value: string; tone?: string }) { return (
{label}
{value}
| {t.contact} | {t.direction} | {t.balance} | {t.due} |
|---|---|---|---|
| {c.name} | {c.balanceMinor > 0 ? t.owesMe : t.iOwe} | 0 ? "text-income" : "text-expense", )} > {formatMoney(Math.abs(c.balanceMinor))} |
{c.dueDate ? dayLabel(c.dueDate) : "—"}
{t.dueStates[c.due] ? (
|
{t.noContacts}
)}{t.inKindHint}
| {t.contact} | {t.direction} | {t.remaining} | {t.value} | {t.since} |
|---|---|---|---|---|
| {d.contactName} | {d.direction === "receivable" ? t.receivable : t.debt} | {d.remainingLabel} | {d.valueMinor === null ? "—" : formatMoney(d.valueMinor)} | {dayLabel(d.date)} |
{t.noInKind}
)} {data.inKindTotals.unpriced ? ({t.unpriced(data.inKindTotals.unpriced)}
) : null}{t.excluded(p.excluded)}
) : null}| {t.asset} | {t.quantity} | {t.cost} | {t.value} | {t.unrealized} | {t.realized} |
|---|---|---|---|---|---|
| {a.name || a.label} | {formatAssetQuantity(a.assetKey, a.summary.quantity)} | {formatMoney(a.summary.costMinor)} | {a.summary.currentValueMinor === null ? t.noPrice : formatMoney(a.summary.currentValueMinor)} | {a.summary.unrealizedMinor === null ? "—" : `${signed(a.summary.unrealizedMinor)}${bp(a.summary.unrealizedBp)}`} | {signed(a.summary.realizedMinor)} |
| {t.total} | {formatMoney(data.totals.costMinor)} | {formatMoney(data.totals.valueMinor)} | {signed(data.totals.unrealizedMinor)} | {signed(data.totals.realizedMinor)} |
{t.empty}
)}