Skip to content

CutoffWarning

Inline, with both legitimate remedies named.
Implemented
Status
Implemented
Family
12 of 13
Registry
@lopifi/cutoff-warning
npx shadcn@latest add @lopifi/theme @lopifi/cutoff-warning

The component, rendering

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

Preview

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/cutoff-warning.tsx

Lopifi dependencies · 3
cnfiscal-periodicons
npm packages
clsxtailwind-merge
Registry entry
/r/cutoff-warning.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/cutoff-warning.tsx
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import { formatDate } from "@/lib/ledger/fiscal-period";
import { ExclamationTriangleIcon } from "@/components/ledger/icons";

export interface CutoffWarningProps extends React.ComponentPropsWithoutRef<"div"> {
  closedThrough: Date;
  entryDate: Date;
  onPostAccrual?: () => void;
  onRequestReopen?: () => void;
}

/**
 * Inline at the date field, never a toast. States the consequence **and both
 * legitimate remedies** — a bare rejection leaves the user with no path.
 */
export const CutoffWarning = React.forwardRef<HTMLDivElement, CutoffWarningProps>(
  ({ className, entryDate, closedThrough, onRequestReopen, onPostAccrual, ...props }, ref) => {
    const postingPeriod = new Date(closedThrough.getFullYear(), closedThrough.getMonth() + 1, 1);
    return (
      <div
        className={cn("flex items-start gap-2 rounded-sm bg-warning-subtle px-3 py-2", className)}
        ref={ref}
        role="alert"
        {...props}
      >
        <ExclamationTriangleIcon aria-hidden="true" className="mt-0.5 size-4 shrink-0 text-warning" />
        <p className="text-body text-text-primary">
          This is dated {formatDate(entryDate)}, in a closed period. It will post to{" "}
          {postingPeriod.toLocaleDateString("en-GB", { month: "long", year: "numeric" })} and be flagged for
          cutoff review. If it belongs in the earlier period,{" "}
          <button
            className="text-accent underline underline-offset-2"
            onClick={onRequestReopen}
            type="button"
          >
            request a reopen
          </button>{" "}
          or{" "}
          <button className="text-accent underline underline-offset-2" onClick={onPostAccrual} type="button">
            post an accrual
          </button>
          .
        </p>
      </div>
    );
  },
);
CutoffWarning.displayName = "CutoffWarning";

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 Close, controls & consolidation

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 CutoffWarning 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 Close, controls & consolidation 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.