EntryReversalDialog
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/entry-reversal-dialog
npx shadcn@latest add @lopifi/theme @lopifi/entry-reversal-dialogThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
AlertDialog with hold-to-confirm, stating exactly what will happen: "Reverse JE-2026-0841? This creates an offsetting entry dated 30 Sep 2026. The original stays in the ledger." A reversal in a closed period is dated in the current open period, and the closed date isn't offered.
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/entry-reversal-dialog.tsx
- Lopifi dependencies · 5
- buttoncnfiscal-periodhold-to-confirmuse-media-query
- npm packages
- @base-ui-components/reactclass-variance-authorityclsxtailwind-merge
- Registry entry
- /r/entry-reversal-dialog.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 { Dialog } from "@base-ui-components/react/dialog";
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import { Button } from "@/components/ledger/button";
import { HoldToConfirm } from "@/components/ledger/hold-to-confirm";
export interface EntryReversalDialogProps {
/** A reversal in a closed period is dated in the current open period,
and the closed date is not offered. */
closedThrough?: Date;
currentPeriodStart: Date;
entryDate: Date;
entryNumber: string;
onConfirm: (reversalDate: Date) => void;
onOpenChange: (open: boolean) => void;
open: boolean;
}
/** Never a delete. Says exactly what will happen, and to what. */
export function EntryReversalDialog({
open,
onOpenChange,
entryNumber,
entryDate,
closedThrough,
currentPeriodStart,
onConfirm,
}: EntryReversalDialogProps) {
const cancelRef = React.useRef<HTMLButtonElement>(null);
const inClosedPeriod = closedThrough != null && entryDate <= closedThrough;
const reversalDate = inClosedPeriod ? currentPeriodStart : entryDate;
return (
<Dialog.Root onOpenChange={onOpenChange} open={open}>
<Dialog.Portal>
<Dialog.Backdrop className="fixed inset-0 z-overlay bg-[oklch(0.21_0.02_265/0.4)]" />
<Dialog.Popup
className={cn(
"fixed left-1/2 top-1/2 z-dialog w-[calc(100vw-32px)] max-w-[460px]",
"-translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-surface-raised p-6",
"shadow-elevation-4 outline-none",
)}
/* Destructive dialog: focus lands on Cancel, never on the confirm. */
initialFocus={cancelRef}
role="alertdialog"
>
<Dialog.Title className="text-title-md font-medium">Reverse {entryNumber}?</Dialog.Title>
<Dialog.Description className="mt-2 text-body text-text-secondary">
This creates an offsetting entry dated {formatDate(reversalDate)}. The original stays in the
ledger.
{inClosedPeriod ? (
<span className="mt-2 block text-text-primary">
{formatDate(entryDate)} is in a closed period, so the reversal is dated in the current open
period instead.
</span>
) : null}
</Dialog.Description>
<div className="mt-6 flex flex-col gap-3">
<HoldToConfirm
label="Hold to reverse"
onConfirm={() => {
onConfirm(reversalDate);
onOpenChange(false);
}}
typedConfirmation={entryNumber}
/>
<Dialog.Close render={<Button ref={cancelRef} variant="secondary" />}>Cancel</Dialog.Close>
</div>
</Dialog.Popup>
</Dialog.Portal>
</Dialog.Root>
);
}
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 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.
- 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
- ReversalAn offsetting entry that undoes a posted entryTerm
Elsewhere in the system
Where EntryReversalDialog 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.