AuditTrail
- Status
- Implemented
- Family
- 12 of 13
- Registry
- @lopifi/audit-trail
npx shadcn@latest add @lopifi/theme @lopifi/audit-trailThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
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/audit-trail.tsx
- Lopifi dependencies · 3
- cnfiscal-periodicons
- npm packages
- clsxtailwind-merge
- Registry entry
- /r/audit-trail.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
"use client";
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatTimestamp } from "@/lib/ledger/fiscal-period";
import { UserCircleIcon } from "@/components/ledger/icons";
export type AuditRecord = {
id: string;
at: Date;
actor: string;
role: string;
/** Delegated and support access renders explicitly, never silently. */
onBehalfOf?: string;
action: string;
/** Field-level diffs: "Amount changed from $1,240.00 to $1,420.00". */
diffs?: { field: string; from: string; to: string }[];
};
export interface AuditTrailProps {
className?: string;
records: AuditRecord[];
/** Server UTC, with the zone displayed. */
timeZone?: string;
}
/**
* A timeline on **every** financial object, not a hidden admin log.
* Append-only. Filters narrow the view and say so.
*/
export function AuditTrail({ records, timeZone = "UTC", className }: AuditTrailProps) {
const [filter, setFilter] = React.useState("");
const filtered = filter
? records.filter(
(r) =>
r.actor.toLowerCase().includes(filter.toLowerCase()) ||
r.action.toLowerCase().includes(filter.toLowerCase()),
)
: records;
return (
<div className={cn("rounded-xl border border-border bg-surface p-6", className)}>
<div className="flex flex-wrap items-baseline justify-between gap-3">
<h3 className="text-title-sm font-medium">Audit trail</h3>
<input
aria-label="Filter audit trail"
className="h-8 w-56 rounded-sm border border-border bg-surface px-2 text-label outline-none focus-visible:border-accent"
onChange={(e) => setFilter(e.target.value)}
placeholder="Filter by actor or action"
value={filter}
/>
</div>
{filter ? (
<p aria-live="polite" className="mt-1 text-caption text-text-secondary">
Showing <span className="numeric">{filtered.length}</span> of{" "}
<span className="numeric">{records.length}</span> events.
</p>
) : (
<p className="mt-1 numeric text-caption text-text-tertiary">{records.length} events · append-only</p>
)}
<ol className="mt-4 space-y-4">
{filtered.map((r) => (
<li className="border-l-2 border-border pl-4" key={r.id}>
<p className="text-body">{r.action}</p>
{r.diffs?.length ? (
<ul className="mt-1 space-y-0.5">
{r.diffs.map((d) => (
<li className="text-caption text-text-secondary" key={d.field}>
<span className="font-medium text-text-primary">{d.field}</span> changed from{" "}
<span className="numeric">{d.from}</span> to <span className="numeric">{d.to}</span>
</li>
))}
</ul>
) : null}
<p className="mt-1 flex flex-wrap items-center gap-1 text-caption text-text-tertiary">
<span className="text-text-secondary">
{r.actor} ({r.role})
</span>
{r.onBehalfOf ? (
<span className="inline-flex items-center gap-1 rounded-xs bg-warning-subtle px-1.5 py-0.5 text-warning">
<UserCircleIcon aria-hidden="true" className="size-3" />
on behalf of {r.onBehalfOf}
</span>
) : null}
<span aria-hidden="true">·</span>
<span className="numeric">{formatTimestamp(r.at, timeZone)}</span>
</p>
</li>
))}
</ol>
</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 Close, controls & consolidation
- PeriodStatusState, provenance, and the next action.Spec
- CutoffWarningInline, with both legitimate remedies named.
- CloseStatusThe seven-section gated pipeline.Spec
- EvidencePanelInline rendering, content hash, never deleted.Spec
- IntegrityCheckPanelEleven continuous assertions. A failure owns the screen.Spec
- MaterialityPolicyBoth thresholds must be exceeded. Threshold displayed.Spec
- ApprovalPolicyEditorSeparate-approver shown as fixed, not a toggle.Spec
- RoleMatrixController ≠ Treasurer. Admin cannot transact.Spec
- SubsequentEventLogAdjusting vs. non-adjusting, decision recorded.Spec
- RestatementBannerMarks a restated comparative everywhere.Spec
- AuditorModeRead-only server-side, scope immutable, itself audited.Spec
- SamplingToolMethod and seed recorded — reproducible selection.Spec
- EvidenceBundleEntries + documents + approvals + trail, with a manifest.Spec
- EntitySelectorExplicit scope. Standalone vs. consolidated visually distinct.Spec
- ConsolidationViewEntity columns, eliminations, NCI, group total.Spec
- IntercompanyMatrixMust net to zero. Break types named.Spec
- EliminationEntryConsolidation-level only, boundary visible.Spec
- NciPanelOn both statements.Spec
- TranslationSummaryRates by type, with sources and methodology.Spec
- CtaRollForwardIts own equity line, never buried.Spec
- FxRevaluationMonetary items only, derived from classification.Spec
- FxGainLossPanelRealized and unrealized never combined.Spec
- RateTableRate type is not optional. A missing rate blocks.Spec
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Close, controls & consolidation — the family specThe four-layer specification this component was built against, before it was written.Doc
- Month-end close and controlsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- Audit trailThe immutable record of every state changeTerm
Elsewhere in the system
Where AuditTrail 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.
- AuditTrail, runningThe gl showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Attachments and the audit trailCan you see who changed what, and get the source document?API
- Close, controls & consolidationClose, controls & consolidation — specs for 24 React components: PeriodStatus, CutoffWarning, CloseStatus, AuditTrail and 20 more.Doc
Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.
Told when Close, controls & consolidation 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.