Skip to content

AdjustingEntryForm

Templated by type. Auto-reverse defaults on for accruals.
Implemented
Status
Implemented
Family
9 of 13
Registry
@lopifi/adjusting-entry-form
npx shadcn@latest add @lopifi/theme @lopifi/adjusting-entry-form

The component, rendering

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

Preview

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.

components/ledger/adjusting-entry-form.tsx
"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.

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 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.

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.