Skip to content

JournalEntry

Debit and credit as two columns. No signed-column variant.
Implemented
Status
Implemented
Family
9 of 13
Registry
@lopifi/journal-entry
npx shadcn@latest add @lopifi/theme @lopifi/journal-entry

The component, rendering

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

Preview

The four-layer spec

Debit and credit as two columns. There is no single-signed-column variant.

  JE-2026-0841 · 30 Sep 2026 · Adjusting · Posted        [Reverse] [Audit trail]
  Accrue September professional fees

  Account                         Dept    Debit       Credit
  6410 · Professional fees        G&A    12,000.00
  2150 · Accrued liabilities                        12,000.00
                                        ─────────   ─────────
                                        12,000.00   12,000.00   ✓ balanced
  ⟲ Reverses 1 Oct 2026 · Evidence: Baker & Co engagement letter.pdf

Layer 4: 3 sizes (title-md header · body labels · figure-sm amounts), 2 weights. tnum + case on both amount columns; the columns are independently right-aligned and each hugs its own gutter.

Rules: balance check always visible · unbalanced is a prominent error with the difference stated · source and status on the header · no delete action on a posted entry — absent, not disabled · reversal linked bidirectionally, both entries remain visible · evidence inline.

Motion: none. Server-safe (no "use client") — a 400-line entry renders on the server.

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.tsx

Lopifi dependencies · 11
accounting.typescnfiscal-periodformat-moneyiconsinfo-tipmoneymoney.typesreferenceruletooltip
npm packages
@base-ui-components/reactclass-variance-authorityclsxtailwind-merge
Registry entry
/r/journal-entry.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.tsx
import * as React from "react";
import type { JournalEntryRecord } from "@/lib/ledger/accounting.types";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { ArrowUturnLeftIcon, CheckIcon, ExclamationTriangleIcon, PaperClipIcon } from "@/components/ledger/icons";
import { InfoTip } from "@/components/ledger/info-tip";
import { Money } from "@/components/ledger/money";
import { Reference } from "@/components/ledger/reference";
import { Rule } from "@/components/ledger/rule";
import { Tooltip } from "@/components/ledger/tooltip";

export interface JournalEntryProps extends React.ComponentPropsWithoutRef<"article"> {
  actions?: React.ReactNode;
  currency: string;
  entry: JournalEntryRecord;
  totalCredit: MoneyValue;
  /** Totals passed in, already computed. */
  totalDebit: MoneyValue;
}

const SOURCE_LABEL: Record<string, string> = {
  adjusting: "Adjusting",
  elimination: "Elimination",
  import: "Import",
  manual: "Manual",
  recurring: "Recurring",
  schedule: "Schedule",
  subledger: "Subledger",
  translation: "Translation",
};

/**
 * Debit and credit as two columns. There is no single-signed-column variant.
 *
 * A posted entry is never edited or deleted — it is reversed. The delete
 * action is **absent**, not disabled.
 *
 * Server-safe: a 400-line entry renders on the server.
 */
export const JournalEntry = React.forwardRef<HTMLElement, JournalEntryProps>(
  ({ className, entry, currency, totalDebit, totalCredit, actions, ...props }, ref) => {
    const balanced = Number(totalDebit.amount) === Number(totalCredit.amount);
    const difference = Number(totalDebit.amount) - Number(totalCredit.amount);

    return (
      <article className={cn("rounded-xl border border-border bg-surface", className)} ref={ref} {...props}>
        <header className="flex flex-wrap items-start justify-between gap-4 border-b border-border-subtle px-6 py-4">
          <div>
            <p className="flex flex-wrap items-center gap-2 text-caption text-text-secondary">
              <Reference truncate={false} value={entry.entryNumber} />
              <span aria-hidden="true">·</span>
              <span className="numeric">{formatDate(entry.date)}</span>
              <span aria-hidden="true">·</span>
              {SOURCE_LABEL[entry.source] ?? entry.source}
              <span aria-hidden="true">·</span>
              <span className="capitalize">{entry.status}</span>
            </p>
            <p className="mt-1 text-body font-medium">{entry.description}</p>
          </div>
          {/* No delete. Absent, not disabled. */}
          <div className="flex gap-2">{actions}</div>
        </header>

        {/* Never sortable: the lines of one entry read debits first, then
            credits, and that order is the double-entry itself rather than a
            default the reader is free to change. */}
        <table className="w-full" data-sortable="false">
          {/* A width *preference*, not a fixed layout. Auto layout still honours
              each money column's content minimum, so a figure can never be
              clipped; the percentages only stop the account column from being
              squeezed to three wrapped lines while the credit column sits half
              empty. `table-fixed` does the opposite and clips the money. */}
          <colgroup>
            <col className="w-[44%]" />
            <col className="w-[20%]" />
            <col className="w-[18%]" />
            <col className="w-[18%]" />
          </colgroup>
          <caption className="sr-only">
            Journal entry {entry.entryNumber}, {entry.lines.length} lines
          </caption>
          <thead>
            <tr className="border-b border-border-subtle">
              <th className="px-6 py-2 text-left text-label font-medium text-text-secondary" scope="col">
                Account
              </th>
              <th className="px-3 py-2 text-left text-label font-medium text-text-secondary" scope="col">
                Dimensions
              </th>
              <th className="px-3 py-2 text-right text-label font-medium text-text-secondary" scope="col">
                Debit
              </th>
              <th className="px-6 py-2 text-right text-label font-medium text-text-secondary" scope="col">
                Credit
              </th>
            </tr>
          </thead>
          <tbody>
            {entry.lines.map((line) => (
              <tr className="border-b border-border-subtle" key={line.id}>
                <th className="px-6 py-2 text-left font-normal" scope="row">
                  <span className="reference-numeric text-caption text-text-tertiary">
                    {line.accountNumber}
                  </span>{" "}
                  <span className="text-body">{line.accountName}</span>
                  {line.memo ? (
                    // A line memo is auditor-relevant but rarely the thing being
                    // scanned. It keeps its own line and truncates; the full text
                    // is one hover away rather than three wrapped lines deep.
                    <Tooltip content={line.memo} display="block">
                      <span className="block truncate text-caption text-text-secondary">{line.memo}</span>
                    </Tooltip>
                  ) : null}
                </th>
                <td className="px-3 py-2 text-left text-caption text-text-secondary">
                  {dimensionSummary(line.dimensions)}
                </td>
                <td className="px-3 py-2 text-right align-top">
                  {line.debit ? <Money accounting value={line.debit} /> : null}
                </td>
                <td className="px-6 py-2 text-right align-top">
                  {line.credit ? <Money accounting value={line.credit} /> : null}
                </td>
              </tr>
            ))}
          </tbody>
          <tfoot>
            <tr>
              <td colSpan={2} />
              <td className="px-3">
                <Rule variant="subtotal" />
              </td>
              <td className="px-6">
                <Rule variant="subtotal" />
              </td>
            </tr>
            <tr>
              <th className="px-6 py-2 text-left text-label font-medium" colSpan={2} scope="row">
                Totals
              </th>
              <td className="px-3 py-2 text-right">
                <Money accounting size="md" value={totalDebit} />
              </td>
              <td className="px-6 py-2 text-right">
                <Money accounting size="md" value={totalCredit} />
              </td>
            </tr>
            <tr>
              <td colSpan={2} />
              <td className="px-3">
                <Rule variant="total" />
              </td>
              <td className="px-6">
                <Rule variant="total" />
              </td>
            </tr>
          </tfoot>
        </table>

        <div className="space-y-2 px-6 py-4">
          <p
            className={cn(
              "flex items-center gap-2 rounded-sm px-3 py-2 text-body",
              balanced ? "bg-positive-subtle text-positive" : "bg-negative-subtle text-negative",
            )}
            role={balanced ? undefined : "alert"}
          >
            {balanced ? (
              <CheckIcon aria-hidden="true" className="size-4 shrink-0" />
            ) : (
              <ExclamationTriangleIcon aria-hidden="true" className="size-4 shrink-0" />
            )}
            {balanced ? (
              "Balanced."
            ) : (
              <>
                Out of balance by <Money tone="inherit" value={{ amount: Math.abs(difference), currency }} />
                <InfoTip
                  about="What an out-of-balance entry means"
                  label="This entry cannot post"
                  triggerClassName="text-negative"
                >
                  Debits and credits must agree to the cent before an entry reaches the ledger. Correct a
                  line, or add the balancing one.
                </InfoTip>
              </>
            )}
          </p>

          {/* One reversal line, not three stacked sentences. Each fact is short
              enough to sit beside the others; the one piece of doctrine —
              that reversal never removes the original — is the tooltip. */}
          {entry.autoReverseOn || entry.reversalOf || entry.reversedBy ? (
            <p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-caption text-text-secondary">
              <ArrowUturnLeftIcon aria-hidden="true" className="size-3.5 shrink-0" />
              {entry.autoReverseOn ? (
                <span>
                  Reverses <span className="numeric">{formatDate(entry.autoReverseOn)}</span>
                </span>
              ) : null}
              {entry.reversalOf ? (
                <>
                  {entry.autoReverseOn ? <span aria-hidden="true">·</span> : null}
                  <span>Reverses {entry.reversalOf}</span>
                </>
              ) : null}
              {entry.reversedBy ? (
                <>
                  {entry.autoReverseOn || entry.reversalOf ? <span aria-hidden="true">·</span> : null}
                  <span>Reversed by {entry.reversedBy}</span>
                </>
              ) : null}
              <InfoTip about="How reversal works" label="Reversal, not deletion">
                A posted entry is never edited or removed. The original and its reversal both stay in the
                ledger, and the audit trail shows both.
              </InfoTip>
            </p>
          ) : null}

          {entry.evidence?.length ? (
            <ul className="flex flex-wrap gap-2">
              {entry.evidence.map((e) => (
                <li
                  className="inline-flex items-center gap-1.5 rounded-sm border border-border px-2 py-1 text-caption"
                  key={e.name}
                >
                  <PaperClipIcon aria-hidden="true" className="size-3 text-text-tertiary" />
                  {e.name}
                  <span className="reference-numeric text-text-tertiary">{e.hash.slice(0, 8)}</span>
                </li>
              ))}
            </ul>
          ) : null}
        </div>
      </article>
    );
  },
);
JournalEntry.displayName = "JournalEntry";

function dimensionSummary(dimensions: Record<string, string | undefined>): string {
  return Object.entries(dimensions)
    .filter(([, v]) => v)
    .map(([, v]) => v)
    .join(" · ");
}

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 JournalEntry 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.