AdjustingEntryForm
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/adjusting-entry-form
npx shadcn@latest add @lopifi/theme @lopifi/adjusting-entry-formThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Templated by adjustment type — accrual, deferral, depreciation, amortization, provision, reclass, true-up. autoReverse defaults to true for accruals, with the reversal date shown inline ("Reverses 1 Oct 2026"). The scheduled reversal is visible in the next period before it posts.
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/adjusting-entry-form.tsx
- Lopifi dependencies · 14
- account-pickeraccounting.typesbuttoncncutoff-warningdimension-pickerfiscal-periodformat-moneyiconsjournal-entry-formmoneymoney.typesruletooltip
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/adjusting-entry-form.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 type { Account, AdjustmentType } from "@/lib/ledger/accounting.types";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import { ArrowUturnLeftIcon } from "@/components/ledger/icons";
import { JournalEntryForm } from "@/components/ledger/journal-entry-form";
const TYPES: { key: AdjustmentType; label: string; autoReverse: boolean; hint: string }[] = [
{ autoReverse: true, hint: "Expense incurred, not yet invoiced.", key: "accrual", label: "Accrual" },
{
autoReverse: false,
hint: "Cash received or paid ahead of the period it belongs to.",
key: "deferral",
label: "Deferral",
},
{
autoReverse: false,
hint: "Periodic charge against a fixed asset.",
key: "depreciation",
label: "Depreciation",
},
{
autoReverse: false,
hint: "Periodic charge against an intangible or prepaid.",
key: "amortization",
label: "Amortization",
},
{ autoReverse: false, hint: "Estimated liability or allowance.", key: "provision", label: "Provision" },
{
autoReverse: false,
hint: "Moves a balance between accounts; no P&L effect.",
key: "reclass",
label: "Reclassification",
},
{ autoReverse: false, hint: "Corrects an earlier estimate to actual.", key: "true-up", label: "True-up" },
];
export interface AdjustingEntryFormProps {
accounts: Account[];
className?: string;
closedThrough?: Date;
currency: string;
periodEnd: Date;
}
/**
* Templated by adjustment type. `autoReverse` defaults to **true** for
* accruals, with the reversal date shown inline — and that scheduled
* reversal is visible in the next period before it posts.
*/
export function AdjustingEntryForm({
accounts,
currency,
periodEnd,
closedThrough,
className,
}: AdjustingEntryFormProps) {
const [type, setType] = React.useState<AdjustmentType>("accrual");
const config = TYPES.find((t) => t.key === type) ?? TYPES[0];
const [autoReverse, setAutoReverse] = React.useState(config.autoReverse);
React.useEffect(() => {
setAutoReverse(TYPES.find((t) => t.key === type)?.autoReverse ?? false);
}, [type]);
const reversalDate = new Date(periodEnd.getFullYear(), periodEnd.getMonth() + 1, 1);
return (
<div className={cn("space-y-4", className)}>
<fieldset>
<legend className="mb-2 text-label font-medium text-text-secondary">Adjustment type</legend>
<div className="flex flex-wrap gap-2">
{TYPES.map((t) => (
<button
aria-checked={type === t.key}
className={cn(
"press h-8 rounded-sm border px-3 text-label font-medium",
type === t.key
? "border-accent bg-accent-subtle text-accent"
: "border-border hover:bg-surface-hover",
)}
key={t.key}
onClick={() => setType(t.key)}
role="radio"
type="button"
>
{t.label}
</button>
))}
</div>
<p className="mt-2 text-caption text-text-secondary">{config.hint}</p>
</fieldset>
<label className="flex items-start gap-2 rounded-sm bg-surface-sunken p-3">
<input
checked={autoReverse}
className="mt-0.5 size-4 accent-[var(--accent)]"
onChange={(e) => setAutoReverse(e.target.checked)}
type="checkbox"
/>
<span>
<span className="flex items-center gap-1.5 text-body">
<ArrowUturnLeftIcon aria-hidden="true" className="size-3.5 text-text-tertiary" />
Reverse automatically
</span>
<span className="mt-0.5 block text-caption text-text-secondary">
{autoReverse
? `Reverses ${formatDate(reversalDate)}. The reversal is visible in that period before it posts.`
: "No reversal will be scheduled."}
</span>
</span>
</label>
<JournalEntryForm accounts={accounts} closedThrough={closedThrough} currency={currency} />
</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.
- AccrualAn expense incurred, or revenue earned, before it is invoiced — recorded at period end so it lands in the right period
- Adjusting entryA close entry to apply accrual accounting
- AmortizationSpreading the cost of a finite-lived intangible, a prepaid or a debt discount over the periods it serves
- DeferralCash paid or received ahead of the expense or revenue it relates to, held on the balance sheet — as a prepaid or deferred revenue — until consumed or earned
- DepreciationSpreading the cost of a fixed asset over the periods it serves
- ReversalAn offsetting entry that undoes a posted entry
- True-upThe adjustment that replaces an estimate with the actual amount once it is known
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.
- 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
- AccrualAn expense incurred, or revenue earned, before it is invoiced — recorded at period end so it lands in the right periodTerm
Elsewhere in the system
Where AdjustingEntryForm 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.