Skip to content

CashFlowStatement

Operating / investing / financing.
Implemented
Status
Implemented
Family
6 of 13
Registry
@lopifi/cash-flow-statement
npx shadcn@latest add @lopifi/theme @lopifi/cash-flow-statement

The component, rendering

Real data, the shipped component. Switch the theme to check the claims the spec makes below.

Preview

The four-layer spec

Operating / Investing / Financing, with the reconciliation to the change in cash. Supports both direct and indirect methods. The beginning-cash → ending-cash tie-out is displayed and asserted, same as the balance sheet's identity.

Lifted verbatim from Statements. The doc and this page are the same paragraphs, so they cannot disagree.

What lands in your repository

One component is never one file. Everything below is copied into your project, where you own it.

Files

components/ledger/cash-flow-statement.tsx

Lopifi dependencies · 14
cncolumn-managerfiscal-periodformat-moneyiconsmoneymoney.typespercentperiod-changerulestatement-tabletooltipuse-scroll-edgesvariance-cell
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/cash-flow-statement.json

The whole component

No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.

components/ledger/cash-flow-statement.tsx
"use client";

import { cn } from "@/lib/ledger/cn";
import { CheckIcon, ExclamationTriangleIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";
import { type StatementHeader, type StatementLine, StatementTable } from "@/components/ledger/statement-table";

export interface CashFlowStatementProps {
  className?: string;
  /** Offer the period columns to hide. See `StatementTable`. */
  columnManager?: boolean;
  header: Omit<StatementHeader, "statement">;
  lines: StatementLine[];
  /** Caps the scroller so the column headers freeze. See `StatementTable`. */
  maxHeight?: number;
  method?: "indirect" | "direct";
  periods: string[];
  /** Beginning + net change = ending, and ending must equal the balance
      sheet cash line. Asserted and displayed. */
  tieOut: {
    beginningCash: number[];
    netChange: number[];
    endingCash: number[];
    balanceSheetCash: number[];
  };
}

/**
 * The working-capital sign convention is inverted and it confuses everyone:
 * an *increase* in AR is a *use* of cash. The lines are labelled
 * "(Increase) / decrease in …" exactly so, because the parenthetical is
 * what makes the sign readable.
 */
export function CashFlowStatement({
  header,
  periods,
  method = "indirect",
  lines,
  tieOut,
  maxHeight,
  columnManager,
  className,
}: CashFlowStatementProps) {
  return (
    <div className={cn("w-full", className)}>
      <StatementTable
        columnManager={columnManager}
        header={{
          ...header,
          statement: `Statement of cash flows (${method} method)`,
        }}
        lines={lines}
        maxHeight={maxHeight}
        periods={periods}
      />

      <div className="mt-4 space-y-2">
        {periods.map((p, i) => {
          const computed = tieOut.beginningCash[i] + tieOut.netChange[i];
          const tiesInternally = computed === tieOut.endingCash[i];
          const tiesToBalanceSheet = tieOut.endingCash[i] === tieOut.balanceSheetCash[i];
          const ok = tiesInternally && tiesToBalanceSheet;

          return (
            <div
              className={cn(
                "flex flex-wrap items-center gap-2 rounded-md border px-4 py-3",
                ok ? "border-positive bg-positive-subtle" : "border-negative bg-negative-subtle",
              )}
              key={p}
              role={ok ? undefined : "alert"}
            >
              {ok ? (
                <CheckIcon aria-hidden="true" className="size-4 shrink-0 text-positive" />
              ) : (
                <ExclamationTriangleIcon aria-hidden="true" className="size-4 shrink-0 text-negative" />
              )}
              <span className="text-caption text-text-secondary">{p}:</span>
              <span className="flex flex-wrap items-baseline gap-1 text-body">
                Beginning{" "}
                <Money accounting value={{ amount: tieOut.beginningCash[i], currency: header.currency }} />
                <span aria-hidden="true">+</span>
                Net change{" "}
                <Money accounting value={{ amount: tieOut.netChange[i], currency: header.currency }} />
                <span aria-hidden="true">=</span>
                Ending{" "}
                <Money accounting value={{ amount: tieOut.endingCash[i], currency: header.currency }} />
              </span>
              <span className={cn("text-body font-medium", ok ? "text-positive" : "text-negative")}>
                {ok
                  ? "Ties to the balance sheet cash line."
                  : tiesInternally
                    ? "Does not tie to the balance sheet cash line."
                    : "Beginning plus net change does not equal ending cash."}
              </span>
            </div>
          );
        })}
      </div>
    </div>
  );
}

The accounting it encodes

Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.

Also in Statements

See also

A component is specified in one place, defined in another, and running in a third. All three, from here.

Elsewhere in the system

Where CashFlowStatement sits in the rest of the system — the live section it renders in, the calculators that compute what it displays, and the ledger payloads it is fed from.

Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.

Told when Statements changes

Components are copied into your repo, so a fix here does not reach you on its own. One email when a component in this family changes in a way that needs a migration — and nothing when it does not.

One address, no list rental, unsubscribe in one click.

Works in your QuickBooks Online or Xero file

Get your books closed every month

Lopifi is building AI bookkeeping that keeps your books closed on US GAAP as transactions happen, with a CPA review every quarter, for $200 a month. We’re not open yet.

$200/month when we open. No card now.