Blocks / Statement table

Statement table

A ledger with a running balance, sections, subtotals and a total; signed amounts; CSV export.

import { StatementTable, buildStatement, statementToCsv } from "@forgeron/ui";
/01 → Default
DateDescriptionReferenceAmountBalance
Opening balance€500.00
October
2026-10-03Invoice INV-0101INV-0101€2,400.00credit€2,900.00
2026-10-14Payment receivedPAY-77€1,500.00debit€1,400.00
Subtotal October€900.00credit€1,400.00
November
2026-11-02Invoice INV-0108INV-0108€980.00credit€2,380.00
2026-11-09Credit noteCN-0004€120.00debit€2,260.00
Subtotal November€860.00credit€2,260.00
Closing balance€1,760.00credit€2,260.00
import { StatementTable, type StatementEntry } from "@forgeron/ui";
import { useState } from "react";

const entries: StatementEntry[] = [
  {
    id: "1",
    date: "2026-10-03",
    description: "Invoice INV-0101",
    reference: "INV-0101",
    amount: 240000,
    group: "October",
  },
  {
    id: "2",
    date: "2026-10-14",
    description: "Payment received",
    reference: "PAY-77",
    amount: -150000,
    group: "October",
  },
  {
    id: "3",
    date: "2026-11-02",
    description: "Invoice INV-0108",
    reference: "INV-0108",
    amount: 98000,
    group: "November",
  },
  {
    id: "4",
    date: "2026-11-09",
    description: "Credit note",
    reference: "CN-0004",
    amount: -12000,
    group: "November",
  },
];

export default function Default() {
  const [last, setLast] = useState("");
  return (
    <div style={{ width: 760, maxWidth: "100%", display: "grid", gap: 8 }}>
      <StatementTable
        label="Customer account"
        entries={entries}
        currency="EUR"
        locale="en"
        opening={50000}
        onExport={({ csv }) => setLast(`${csv.split("\r\n").length} lines ready to save`)}
      />
      {last ? <p style={{ margin: 0, font: "12px var(--font-mono)" }}>{last}</p> : null}
    </div>
  );
}
/02 → Expenses
DateDescriptionAmountBalance
Opening balance€0.00
2026-11-02Train, Lyon to Paris€89.00debit-€89.00
2026-11-02Lunch with a client€32.40debit-€121.40
2026-11-05Cash advance returned€50.00credit-€71.40
Net spent€71.40debit-€71.40
import { StatementTable, type StatementEntry } from "@forgeron/ui";

const entries: StatementEntry[] = [
  { id: "1", date: "2026-11-02", description: "Train, Lyon to Paris", amount: -8900 },
  {
    id: "2",
    date: "2026-11-02",
    description: "Lunch with a client",
    reference: "R-12",
    amount: -3240,
  },
  { id: "3", date: "2026-11-05", description: "Cash advance returned", amount: 5000 },
];

export default function Expenses() {
  return (
    <div style={{ width: 640, maxWidth: "100%" }}>
      <StatementTable
        entries={entries}
        currency="EUR"
        locale="en"
        invert
        sort="date"
        showReference={false}
        totalLabel="Net spent"
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
entriesStatementEntry[]—{ id, date, description, reference?, amount (signed, minor units), group? }. Money in is positive.
currencystring—An ISO 4217 code (`EUR`, `USD`, `JPY`): every amount is in its minor units.
localestring—A BCP 47 tag for the numbers and the symbol; the device's by default.
openingnumber0The balance before the first entry.
groupedboolean—Sections with a subtotal each. By default when an entry has a `group`.
sort"date" | "none""none"Orders entries by date.
showBalance / showReferencebooleantrueThe columns.
invertbooleanfalseMoney out is normal (expenses): swaps the colours, the signs stay.
onOpenEntry(entry) => void—Rows become buttons.
onExport({ rows, csv }) => void—Adds an Export button. Saving the file is yours.
totalLabel / openingLabel / subtotalLabelstring—The words of the rows.
classNamestring—Extra classes.