Skip to content

TransactionDetail

Full detail sheet with attachments and audit trail.
Implemented
Status
Implemented
Family
5 of 13
Registry
@lopifi/transaction-detail
npx shadcn@latest add @lopifi/theme @lopifi/transaction-detail

The component, rendering

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

Preview

The four-layer spec

A sheet on phone, a side panel on desktop. Everything: full amounts, FX detail if converted, attachments, the categorization rule that fired, the full audit trail with actor and timestamp. Inline editing for category and memo, with optimistic update and rollback on failure.

Lifted verbatim from Ledger & tables. 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/transaction-detail.tsx

Lopifi dependencies · 23
clipboardcncolumn-headerentity-markfigurefiscal-periodformat-moneygroup-rowsiconsmoneymoney.typesreferencesheetstatus-pilltable-sorttooltiptransaction-cardtransaction-tableuse-column-priorityuse-column-widthsuse-densityuse-grid-navuse-table-sort
npm packages
@base-ui-components/react@tanstack/react-virtualclass-variance-authorityclsxtailwind-mergevaul
Registry entry
/r/transaction-detail.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/transaction-detail.tsx
"use client";

import type * as React from "react";
import { formatDate, formatTimestamp } from "@/lib/ledger/fiscal-period";
import { Figure } from "@/components/ledger/figure";
import { Reference } from "@/components/ledger/reference";
import { Sheet } from "@/components/ledger/sheet";
import { StatusPill } from "@/components/ledger/status-pill";
import type { Transaction } from "@/components/ledger/transaction-table";

export type AuditEvent = {
  at: Date;
  actor: string;
  role: string;
  action: string;
  onBehalfOf?: string;
};

export interface TransactionDetailProps {
  attachments?: { name: string; size: string }[];
  auditTrail?: AuditEvent[];
  /** The rule that fired, if any — shown, because it is editable context. */
  categorizationRule?: string;
  onOpenChange: (open: boolean) => void;
  open: boolean;
  transaction: Transaction | null;
}

/**
 * A sheet on phone, a side panel on desktop. Everything: full amounts, the
 * rule that fired, the attachments, and the full audit trail with actor,
 * role and timestamp.
 */
export function TransactionDetail({
  transaction: t,
  open,
  onOpenChange,
  auditTrail = [],
  categorizationRule,
  attachments = [],
}: TransactionDetailProps) {
  if (!t) return null;
  return (
    <Sheet
      description={formatDate(t.date)}
      onOpenChange={onOpenChange}
      open={open}
      side="right"
      title={t.description}
    >
      <div className="space-y-6">
        <div>
          <Figure colorBySign size="lg" value={t.amount} />
          <div className="mt-2">
            <StatusPill entity="Transaction" status={t.status} />
          </div>
        </div>

        <dl className="space-y-2">
          <Row label="Account">
            {t.account} <span className="reference-numeric">•••• {t.accountLast4}</span>
          </Row>
          <Row label="Category">{t.category}</Row>
          <Row label="Reference">
            <Reference truncate={false} value={t.reference} />
          </Row>
          {t.memo ? <Row label="Memo">{t.memo}</Row> : null}
          {t.createdBy ? <Row label="Created by">{t.createdBy}</Row> : null}
        </dl>

        {categorizationRule ? (
          <section>
            <h3 className="text-label font-medium text-text-secondary">Categorization rule</h3>
            <p className="mt-1 rounded-sm bg-surface-sunken p-3 text-body">{categorizationRule}</p>
          </section>
        ) : null}

        {attachments.length > 0 ? (
          <section>
            <h3 className="text-label font-medium text-text-secondary">Attachments</h3>
            <ul className="mt-2 space-y-1">
              {attachments.map((a) => (
                <li
                  className="flex items-center justify-between rounded-sm border border-border px-3 py-2 text-body"
                  key={a.name}
                >
                  <span className="truncate">{a.name}</span>
                  <span className="numeric text-caption text-text-tertiary">{a.size}</span>
                </li>
              ))}
            </ul>
          </section>
        ) : null}

        {auditTrail.length > 0 ? (
          <section>
            <h3 className="text-label font-medium text-text-secondary">Audit trail</h3>
            <ol className="mt-2 space-y-3">
              {auditTrail.map((e, i) => (
                <li className="border-l-2 border-border pl-3" key={i}>
                  <p className="text-body">{e.action}</p>
                  <p className="text-caption text-text-secondary">
                    {e.actor} ({e.role}){e.onBehalfOf ? ` on behalf of ${e.onBehalfOf}` : ""}
                  </p>
                  <p className="numeric text-caption text-text-tertiary">{formatTimestamp(e.at)}</p>
                </li>
              ))}
            </ol>
          </section>
        ) : null}
      </div>
    </Sheet>
  );
}

function Row({ label, children }: { label: string; children: React.ReactNode }) {
  return (
    <div className="flex items-baseline justify-between gap-6 border-b border-border-subtle pb-2">
      <dt className="text-body text-text-secondary">{label}</dt>
      <dd className="text-right text-body">{children}</dd>
    </div>
  );
}

export { Money } from "@/components/ledger/money";

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 Ledger & tables

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 TransactionDetail 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 Ledger & tables 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.