Skip to content

EntryReversalDialog

Hold-to-confirm. Never a delete.
Implemented
Status
Implemented
Family
9 of 13
Registry
@lopifi/entry-reversal-dialog
npx shadcn@latest add @lopifi/theme @lopifi/entry-reversal-dialog

The component, rendering

Real data, the shipped component. Switch the theme to check the claims the spec makes below.

Preview

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.

components/ledger/entry-reversal-dialog.tsx
"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)

See also

A component is specified in one place, defined in another, and running in a third. All three, from here.

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.

One address, no list rental, unsubscribe in one click.

Works in your QuickBooks Online or Xero file

Get your books closed every month

Lopifi is building AI bookkeeping that keeps your books closed on US GAAP as transactions happen, with a CPA review every quarter, for $200 a month. We’re not open yet.

$200/month when we open. No card now.