Dev Helpers
← Back

Receivables balance

Place this file at app/billing/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/billing/page.tsx

export default function ReceivablesBalance() {
  const invoices = [
    { id: "A", cents: 3200, paid: true, due: "2028-01-10" },
    { id: "B", cents: 7900, paid: false, due: "2028-02-15" },
    { id: "C", cents: 4600, paid: false, due: "2028-03-20" },
  ];
  return (
    <output>
      Outstanding:{" "}
      {(invoices.filter((i) => !i.paid).reduce((s, i) => s + i.cents, 0) / 100).toFixed(
        2,
      )}
    </output>
  );
}