Skip to content

JournalEntryTable

All entries, with the gapless-numbering check.
Implemented
Status
Implemented
Family
9 of 13
Registry
@lopifi/journal-entry-table
npx shadcn@latest add @lopifi/theme @lopifi/journal-entry-table

The component, rendering

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

Preview

The four-layer spec

All entries, filterable by period, source, account, dimension, actor. Gapless-numbering check surfaced as a banner when a gap exists.

Lifted verbatim from Accounting core (GL). 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/journal-entry-table.tsx

Lopifi dependencies · 10
accounting.typescnfiscal-periodformat-moneyiconsmoneymoney.typesreferencetooltipuse-scroll-edges
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/journal-entry-table.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/journal-entry-table.tsx
"use client";

import * as React from "react";
import { useScrollEdges } from "@/hooks/ledger/use-scroll-edges";
import type { EntrySource, JournalEntryRecord } from "@/lib/ledger/accounting.types";
import { cn } from "@/lib/ledger/cn";
import { formatDateShort } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { ExclamationTriangleIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";
import { Reference } from "@/components/ledger/reference";

export interface JournalEntryTableProps extends React.ComponentPropsWithoutRef<"div"> {
  entries: (JournalEntryRecord & { total: MoneyValue })[];
  /** Caps the scroller so the header and the entry column can freeze. */
  maxHeight?: number;
  /** Most tax regimes require sequence; a gap is an audit finding. */
  numberingGaps?: string[];
  onOpen?: (entry: JournalEntryRecord) => void;
}

const SOURCES: EntrySource[] = [
  "manual",
  "adjusting",
  "recurring",
  "subledger",
  "schedule",
  "elimination",
  "translation",
  "import",
];

export function JournalEntryTable({
  className,
  entries,
  numberingGaps = [],
  onOpen,
  maxHeight = 520,
  ...props
}: JournalEntryTableProps) {
  const scroller = useScrollEdges<HTMLDivElement>();
  const [source, setSource] = React.useState<EntrySource | "all">("all");
  const filtered = source === "all" ? entries : entries.filter((e) => e.source === source);

  return (
    <div className={cn("space-y-3", className)} {...props}>
      {numberingGaps.length > 0 ? (
        <p
          className="flex items-center gap-2 rounded-sm bg-negative-subtle px-3 py-2 text-body text-negative"
          role="alert"
        >
          <ExclamationTriangleIcon aria-hidden="true" className="size-4 shrink-0" />
          Entry numbering has {numberingGaps.length} gap
          {numberingGaps.length === 1 ? "" : "s"} ({numberingGaps.join(", ")}). Sequence is required, and a
          gap is an audit finding.
        </p>
      ) : null}

      <label className="inline-flex items-center gap-2">
        <span className="text-label font-medium text-text-secondary">Source</span>
        <select
          className="h-8 rounded-sm border border-border bg-surface px-2 text-label outline-none focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent-subtle"
          onChange={(e) => setSource(e.target.value as EntrySource | "all")}
          value={source}
        >
          <option value="all">All</option>
          {SOURCES.map((s) => (
            <option className="capitalize" key={s} value={s}>
              {s}
            </option>
          ))}
        </select>
      </label>

      <div
        className="ledger-frozen scrollbar-thin rounded-xl border border-border bg-surface"
        ref={scroller}
        style={{ maxHeight }}
      >
        <table className="w-full min-w-[720px]">
          <caption className="sr-only">Journal entries</caption>
          <thead>
            <tr className="border-b border-border-subtle">
              {["Entry", "Date", "Description", "Source", "Status", "Amount"].map((h, i) => (
                <th
                  className={cn(
                    "px-3 py-3 text-label font-medium text-text-secondary",
                    i === 5 ? "text-right" : "text-left",
                    i === 0 && "pl-6",
                    i === 5 && "pr-6",
                  )}
                  data-frozen={i === 0 ? "left" : undefined}
                  key={h}
                  scope="col"
                >
                  {h}
                </th>
              ))}
            </tr>
          </thead>
          <tbody>
            {filtered.map((e) => (
              <tr
                className="border-b border-border-subtle transition-colors duration-1 ease-standard hover:bg-surface-hover"
                key={e.id}
              >
                <td className="py-3 pl-6 pr-3" data-frozen="left">
                  <button className="text-left" onClick={() => onOpen?.(e)} type="button">
                    <Reference copyable={false} truncate={false} value={e.entryNumber} />
                  </button>
                </td>
                <td className="numeric px-3 py-3 text-figure-sm text-text-secondary">
                  {formatDateShort(e.date)}
                </td>
                <th
                  className="max-w-0 truncate px-3 py-3 text-left text-body font-normal"
                  data-frozen="none"
                  scope="row"
                >
                  {e.description}
                </th>
                <td className="px-3 py-3 text-caption capitalize text-text-secondary">{e.source}</td>
                <td className="px-3 py-3 text-caption capitalize text-text-secondary">{e.status}</td>
                <td className="py-3 pl-3 pr-6 text-right">
                  <Money accounting value={e.total} />
                </td>
              </tr>
            ))}
          </tbody>
        </table>
      </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 Accounting core (GL)

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 JournalEntryTable 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 Accounting core (GL) 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.