AccountRegister
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/account-register
npx shadcn@latest add @lopifi/theme @lopifi/account-registerThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
GL detail for one account: every entry, with a running balance column. The register is where an accountant goes when a tie-out fails. Opening balance row, closing balance row, and both tie to the trial balance.
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/account-register.tsx
- Lopifi dependencies · 10
- cnfiscal-periodformat-moneyiconsmoneymoney.typesreferenceruletooltipuse-scroll-edges
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/account-register.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
import * as React from "react";
import { useScrollEdges } from "@/hooks/ledger/use-scroll-edges";
import { cn } from "@/lib/ledger/cn";
import { formatDateShort } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Money } from "@/components/ledger/money";
import { Reference } from "@/components/ledger/reference";
import { Rule } from "@/components/ledger/rule";
export type RegisterLine = {
id: string;
date: Date;
entryNumber: string;
memo: string;
debit: MoneyValue | null;
credit: MoneyValue | null;
/** Passed in, already computed. */
runningBalance: MoneyValue;
};
export interface AccountRegisterProps extends React.ComponentPropsWithoutRef<"div"> {
accountName: string;
accountNumber: string;
closingBalance: MoneyValue;
lines: RegisterLine[];
/** Caps the scroller so the header and the date column can freeze. */
maxHeight?: number;
openingBalance: MoneyValue;
periodLabel: string;
}
/**
* Where an accountant goes when a tie-out fails. Opening balance row,
* closing balance row, and a running balance column — both ends tie to the
* trial balance.
*/
export const AccountRegister = React.forwardRef<HTMLDivElement, AccountRegisterProps>(
(
{
className,
accountNumber,
accountName,
periodLabel,
openingBalance,
closingBalance,
lines,
maxHeight = 520,
...props
},
ref,
) => {
const scroller = useScrollEdges<HTMLDivElement>();
return (
<div className={cn("rounded-xl border border-border bg-surface", className)} ref={ref} {...props}>
<div className="px-6 pb-4 pt-6">
<p className="text-title-sm font-medium">
<span className="reference-numeric text-text-tertiary">{accountNumber}</span> {accountName}
</p>
<p className="text-caption text-text-secondary">{periodLabel}</p>
</div>
<div className="ledger-frozen scrollbar-thin" ref={scroller} style={{ maxHeight }}>
<table
className="w-full min-w-[760px]"
/* Never sortable. The running balance column is only a running balance
in date order — re-order the rows and every figure in it becomes a
number that was never true. Declared here rather than left to the
caller, because the register is what knows it. */
data-sortable="false"
>
<caption className="sr-only">
Register for {accountNumber} {accountName}. {periodLabel}
</caption>
<thead>
<tr className="border-b border-border-subtle">
{["Date", "Entry", "Memo", "Debit", "Credit", "Balance"].map((h, i) => (
<th
className={cn(
"px-3 py-3 text-label font-medium text-text-secondary",
i >= 3 ? "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>
<tr className="border-b border-border-subtle bg-surface-sunken">
<th
className="py-2 pl-6 pr-3 text-left text-label font-medium"
colSpan={5}
data-frozen="none"
scope="row"
>
Opening balance
</th>
<td className="py-2 pl-3 pr-6 text-right">
<Money accounting value={openingBalance} />
</td>
</tr>
{lines.map((l) => (
<tr className="border-b border-border-subtle" key={l.id}>
<td
className="numeric py-2 pl-6 pr-3 text-figure-sm text-text-secondary"
data-frozen="left"
>
{formatDateShort(l.date)}
</td>
<td className="px-3 py-2">
<Reference copyable={false} truncate={false} value={l.entryNumber} />
</td>
<th
className="max-w-0 truncate px-3 py-2 text-left text-body font-normal"
data-frozen="none"
scope="row"
>
{l.memo}
</th>
<td className="px-3 py-2 text-right">
{l.debit ? <Money accounting value={l.debit} /> : null}
</td>
<td className="px-3 py-2 text-right">
{l.credit ? <Money accounting value={l.credit} /> : null}
</td>
<td className="py-2 pl-3 pr-6 text-right">
<Money accounting tone="secondary" value={l.runningBalance} />
</td>
</tr>
))}
</tbody>
<tfoot>
<tr>
<td colSpan={5} />
<td className="pr-6">
<Rule variant="subtotal" />
</td>
</tr>
<tr>
<th
className="py-3 pl-6 pr-3 text-left text-label font-medium"
colSpan={5}
data-frozen="none"
scope="row"
>
Closing balance
</th>
<td className="py-3 pl-3 pr-6 text-right">
<Money accounting size="md" value={closingBalance} />
</td>
</tr>
<tr>
<td colSpan={5} />
<td className="pr-6">
<Rule variant="total" />
</td>
</tr>
</tfoot>
</table>
</div>
</div>
);
},
);
AccountRegister.displayName = "AccountRegister";
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.
- AccountA GL account in the chart of accounts. Always qualify when a bank account is meant.
- General ledgerThe complete set of accounts, holding every posted entry
- Tie-outProving a GL balance against supporting evidence
- Trial balanceEvery account's balance in two columns, proving that total debits equal total credits
Also in Accounting core (GL)
- JournalEntryDebit and credit as two columns. No signed-column variant.
- JournalEntryFormLine grid with live balance check and dimension capture.
- JournalEntryTableAll entries, with the gapless-numbering check.
- AccountPickerShows the normal balance. Blocks non-postable accounts.
- ChartOfAccountsHierarchy, statement mapping, unsupported-account flags.
- DimensionPickerEntity always required; renders what the account demands.
- AdjustingEntryFormTemplated by type. Auto-reverse defaults on for accruals.
- RecurringEntryTemplateTemplate editable; instances read-only.
- EntryReversalDialogHold-to-confirm. Never a delete.
- ScheduleTableOne shell, seven presets. Prepaids through debt.
- RollForwardOpening → movements → closing → tie. The universal shape.
- AccountTieOutEvery BS account, proven against its evidence.
- SchedulePreviewWhat the schedules will post, before they post.
- RevenueWaterfallDeferred balance recognizing by future period.
- DepreciationScheduleBook and tax in parallel. In-service date, not purchase date.
- LeaseScheduleROU asset and liability on diverging curves.
- AllowanceRollForwardWith the methodology shown, not just the number.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Accounting core (GL) — the family specThe four-layer specification this component was built against, before it was written.Doc
- General ledger and accounting coreThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- AccountA GL account in the chart of accounts. Always qualify when a bank account is meant.Term
Elsewhere in the system
Where AccountRegister 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.
- AccountRegister, runningThe gl showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Journals and the general ledgerCan you get the actual general ledger out?API
- Accounting core (GL)The general ledger layer. Specs for 18 React components: JournalEntry, JournalEntryForm, JournalEntryTable, AccountPicker and 14 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 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.