ScheduleTable
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/schedule-table
npx shadcn@latest add @lopifi/theme @lopifi/schedule-tableThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
One component, configured per schedule type. Prepaids, accruals, deferred revenue, fixed assets, intangibles, leases, debt.
Columns are type-specific; the shell, the totals row, and the tie-out are shared. Every row drills to the entries behind it, and they sum to the row. Fully-released items shown then dropped — silently disappearing rows make a schedule impossible to follow.
Variants ship as presets: prepaid · accrual · deferred-revenue · fixed-asset · intangible · lease · debt.
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/schedule-table.tsx
- Lopifi dependencies · 9
- accounting.typescnfiscal-periodformat-moneymoneymoney.typesruletooltipuse-scroll-edges
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/schedule-table.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 { useScrollEdges } from "@/hooks/ledger/use-scroll-edges";
import type { ScheduleType } 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 { Money } from "@/components/ledger/money";
import { Rule } from "@/components/ledger/rule";
export type ScheduleRow = {
id: string;
description: string;
startDate: Date;
endDate: Date;
original: MoneyValue;
opening: MoneyValue;
periodMovement: MoneyValue;
closing: MoneyValue;
/** Fully-released items are shown, then dropped — silently disappearing
rows make a schedule impossible to follow. */
fullyReleased?: boolean;
extra?: Record<string, React.ReactNode>;
};
/** Columns are type-specific; the shell, totals and tie-out are shared. */
const PRESETS: Record<ScheduleType, { title: string; movementLabel: string; extraColumns: string[] }> = {
accrual: { extraColumns: [], movementLabel: "Released this period", title: "Accrued liabilities" },
debt: { extraColumns: ["Rate", "Maturity"], movementLabel: "Principal movement", title: "Debt" },
"deferred-revenue": {
extraColumns: ["Obligation"],
movementLabel: "Recognized this period",
title: "Deferred revenue",
},
"fixed-asset": {
extraColumns: ["In service", "Life", "Method"],
movementLabel: "Depreciation this period",
title: "Fixed assets",
},
intangible: {
extraColumns: ["Life", "Method"],
movementLabel: "Amortization this period",
title: "Intangible assets",
},
lease: {
extraColumns: ["Classification", "Discount rate"],
movementLabel: "Liability movement",
title: "Leases",
},
prepaid: { extraColumns: [], movementLabel: "Amortized this period", title: "Prepaid expenses" },
};
export interface ScheduleTableProps extends React.ComponentPropsWithoutRef<"div"> {
/** Caps the scroller so the header and the item column can freeze. */
maxHeight?: number;
onDrilldown?: (row: ScheduleRow) => void;
periodLabel: string;
rows: ScheduleRow[];
totals: { opening: MoneyValue; movement: MoneyValue; closing: MoneyValue };
type: ScheduleType;
}
/**
* One component, seven presets. Every row drills to the entries behind it,
* and they sum to the row.
*/
export const ScheduleTable = React.forwardRef<HTMLDivElement, ScheduleTableProps>(
({ className, type, periodLabel, rows, totals, onDrilldown, maxHeight = 520, ...props }, ref) => {
const scroller = useScrollEdges<HTMLDivElement>();
const preset = PRESETS[type];
const [showReleased, setShowReleased] = React.useState(true);
const visible = showReleased ? rows : rows.filter((r) => !r.fullyReleased);
const releasedCount = rows.filter((r) => r.fullyReleased).length;
return (
<div className={cn("space-y-3", className)} ref={ref} {...props}>
<div className="rounded-xl border border-border bg-surface">
<div className="px-6 pb-4 pt-6">
<p className="text-title-sm font-medium">{preset.title}</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-[900px]">
<caption className="sr-only">
{preset.title}. {periodLabel}
</caption>
<thead>
<tr className="border-b border-border-subtle">
<th
className="py-3 pl-6 pr-3 text-left text-label font-medium text-text-secondary"
scope="col"
>
Item
</th>
<th className="px-3 py-3 text-left text-label font-medium text-text-secondary" scope="col">
Term
</th>
{preset.extraColumns.map((c) => (
<th
className="px-3 py-3 text-left text-label font-medium text-text-secondary"
key={c}
scope="col"
>
{c}
</th>
))}
<th className="px-3 py-3 text-right text-label font-medium text-text-secondary" scope="col">
Opening
</th>
<th className="px-3 py-3 text-right text-label font-medium text-text-secondary" scope="col">
{preset.movementLabel}
</th>
<th
className="py-3 pl-3 pr-6 text-right text-label font-medium text-text-secondary"
scope="col"
>
Closing
</th>
</tr>
</thead>
<tbody>
{visible.map((r) => (
<tr
className={cn(
"border-b border-border-subtle transition-colors duration-1 ease-standard hover:bg-surface-hover",
r.fullyReleased && "text-text-secondary",
)}
key={r.id}
>
<th className="py-3 pl-6 pr-3 text-left font-normal" scope="row">
<button
className="text-left text-body hover:underline"
onClick={() => onDrilldown?.(r)}
type="button"
>
{r.description}
</button>
{r.fullyReleased ? (
<span className="ml-2 text-caption text-text-tertiary">Fully released</span>
) : null}
</th>
<td className="numeric px-3 py-3 text-caption text-text-secondary">
{formatDate(r.startDate)} – {formatDate(r.endDate)}
</td>
{preset.extraColumns.map((c) => (
<td className="px-3 py-3 text-caption text-text-secondary" key={c}>
{r.extra?.[c] ?? "—"}
</td>
))}
<td className="px-3 py-3 text-right">
<Money accounting value={r.opening} />
</td>
<td className="px-3 py-3 text-right">
<Money accounting value={r.periodMovement} />
</td>
<td className="py-3 pl-3 pr-6 text-right">
<Money accounting value={r.closing} />
</td>
</tr>
))}
</tbody>
<tfoot>
<tr>
<td colSpan={2 + preset.extraColumns.length} />
<td className="px-3">
<Rule variant="subtotal" />
</td>
<td className="px-3">
<Rule variant="subtotal" />
</td>
<td className="pr-6">
<Rule variant="subtotal" />
</td>
</tr>
<tr>
<th className="py-3 pl-6 pr-3 text-left text-label font-medium" scope="row">
Total
</th>
<td colSpan={1 + preset.extraColumns.length} />
<td className="px-3 py-3 text-right">
<Money accounting size="md" value={totals.opening} />
</td>
<td className="px-3 py-3 text-right">
<Money accounting size="md" value={totals.movement} />
</td>
<td className="py-3 pl-3 pr-6 text-right">
<Money accounting size="md" value={totals.closing} />
</td>
</tr>
<tr>
<td colSpan={4 + preset.extraColumns.length} />
<td className="pr-6">
<Rule variant="total" />
</td>
</tr>
</tfoot>
</table>
</div>
</div>
{releasedCount > 0 ? (
<button
aria-pressed={showReleased}
className="text-caption font-medium text-accent hover:underline"
onClick={() => setShowReleased((v) => !v)}
type="button"
>
{showReleased ? "Hide" : "Show"} {releasedCount} fully released item
{releasedCount === 1 ? "" : "s"}
</button>
) : null}
</div>
);
},
);
ScheduleTable.displayName = "ScheduleTable";
export { PRESETS as SCHEDULE_PRESETS };
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.
- Deferred revenueConsideration received, or unconditionally due, before the goods or services are transferred — a liability until the performance obligation is satisfied. ASC 606 calls it a contract liability
- Fixed assetA tangible asset held for use in operations over more than one period — property, plant and equipment — carried at cost less accumulated depreciation
- Tie-outProving a GL balance against supporting evidence
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.
- AccountRegisterGL detail with a running balance.
- 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.
- 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
- Deferred revenueConsideration received, or unconditionally due, before the goods or services are transferred — a liability until the performance obligation is satisfied. ASC 606 calls it a contract liabilityTerm
Elsewhere in the system
Where ScheduleTable 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.
- ScheduleTable, runningThe gl showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Prepaid & deferred releaseA premium paid on the 17th does not release in twelve equal slices. Day-weighted, or even — your call.Tool
- Day count & proration30/360 is wrong about the calendar and right about the contract. Both are here.Tool
- Depreciation scheduleStraight-line, declining balance or SYD, with the convention that decides the first period.Tool
- Lease — ASC 842 / IFRS 16PV of the payments at your IBR, the liability unwind and the ROU asset — straight-line for a finance lease, the plug to a level cost for an operating one.Tool
- Loan amortisationLevel payment solved, then walked in minor units so the last payment clears the balance exactly.Tool
- 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.