{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "author": "Lopifi (https://lopifi.com)",
  "categories": [
    "accounting-core-gl",
    "finance",
    "accounting"
  ],
  "dependencies": [],
  "description": "Templated by type. Auto-reverse defaults on for accruals.",
  "files": [
    {
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport type { Account, AdjustmentType } from \"@/lib/ledger/accounting.types\";\nimport { cn } from \"@/lib/ledger/cn\";\nimport { formatDate } from \"@/lib/ledger/fiscal-period\";\nimport { ArrowUturnLeftIcon } from \"@/components/ledger/icons\";\nimport { JournalEntryForm } from \"@/components/ledger/journal-entry-form\";\n\nconst TYPES: { key: AdjustmentType; label: string; autoReverse: boolean; hint: string }[] = [\n  { autoReverse: true, hint: \"Expense incurred, not yet invoiced.\", key: \"accrual\", label: \"Accrual\" },\n  {\n    autoReverse: false,\n    hint: \"Cash received or paid ahead of the period it belongs to.\",\n    key: \"deferral\",\n    label: \"Deferral\",\n  },\n  {\n    autoReverse: false,\n    hint: \"Periodic charge against a fixed asset.\",\n    key: \"depreciation\",\n    label: \"Depreciation\",\n  },\n  {\n    autoReverse: false,\n    hint: \"Periodic charge against an intangible or prepaid.\",\n    key: \"amortization\",\n    label: \"Amortization\",\n  },\n  { autoReverse: false, hint: \"Estimated liability or allowance.\", key: \"provision\", label: \"Provision\" },\n  {\n    autoReverse: false,\n    hint: \"Moves a balance between accounts; no P&L effect.\",\n    key: \"reclass\",\n    label: \"Reclassification\",\n  },\n  { autoReverse: false, hint: \"Corrects an earlier estimate to actual.\", key: \"true-up\", label: \"True-up\" },\n];\n\nexport interface AdjustingEntryFormProps {\n  accounts: Account[];\n  className?: string;\n  closedThrough?: Date;\n  currency: string;\n  periodEnd: Date;\n}\n\n/**\n * Templated by adjustment type. `autoReverse` defaults to **true** for\n * accruals, with the reversal date shown inline — and that scheduled\n * reversal is visible in the next period before it posts.\n */\nexport function AdjustingEntryForm({\n  accounts,\n  currency,\n  periodEnd,\n  closedThrough,\n  className,\n}: AdjustingEntryFormProps) {\n  const [type, setType] = React.useState<AdjustmentType>(\"accrual\");\n  const config = TYPES.find((t) => t.key === type) ?? TYPES[0];\n  const [autoReverse, setAutoReverse] = React.useState(config.autoReverse);\n\n  React.useEffect(() => {\n    setAutoReverse(TYPES.find((t) => t.key === type)?.autoReverse ?? false);\n  }, [type]);\n\n  const reversalDate = new Date(periodEnd.getFullYear(), periodEnd.getMonth() + 1, 1);\n\n  return (\n    <div className={cn(\"space-y-4\", className)}>\n      <fieldset>\n        <legend className=\"mb-2 text-label font-medium text-text-secondary\">Adjustment type</legend>\n        <div className=\"flex flex-wrap gap-2\">\n          {TYPES.map((t) => (\n            <button\n              aria-checked={type === t.key}\n              className={cn(\n                \"press h-8 rounded-sm border px-3 text-label font-medium\",\n                type === t.key\n                  ? \"border-accent bg-accent-subtle text-accent\"\n                  : \"border-border hover:bg-surface-hover\",\n              )}\n              key={t.key}\n              onClick={() => setType(t.key)}\n              role=\"radio\"\n              type=\"button\"\n            >\n              {t.label}\n            </button>\n          ))}\n        </div>\n        <p className=\"mt-2 text-caption text-text-secondary\">{config.hint}</p>\n      </fieldset>\n\n      <label className=\"flex items-start gap-2 rounded-sm bg-surface-sunken p-3\">\n        <input\n          checked={autoReverse}\n          className=\"mt-0.5 size-4 accent-[var(--accent)]\"\n          onChange={(e) => setAutoReverse(e.target.checked)}\n          type=\"checkbox\"\n        />\n        <span>\n          <span className=\"flex items-center gap-1.5 text-body\">\n            <ArrowUturnLeftIcon aria-hidden=\"true\" className=\"size-3.5 text-text-tertiary\" />\n            Reverse automatically\n          </span>\n          <span className=\"mt-0.5 block text-caption text-text-secondary\">\n            {autoReverse\n              ? `Reverses ${formatDate(reversalDate)}. The reversal is visible in that period before it posts.`\n              : \"No reversal will be scheduled.\"}\n          </span>\n        </span>\n      </label>\n\n      <JournalEntryForm accounts={accounts} closedThrough={closedThrough} currency={currency} />\n    </div>\n  );\n}\n",
      "path": "components/ledger/adjusting-entry-form.tsx",
      "target": "components/ledger/adjusting-entry-form.tsx",
      "type": "registry:component"
    }
  ],
  "name": "adjusting-entry-form",
  "registryDependencies": [
    "@lopifi/theme",
    "@lopifi/accounting.types",
    "@lopifi/cn",
    "@lopifi/fiscal-period",
    "@lopifi/icons",
    "@lopifi/journal-entry-form"
  ],
  "title": "AdjustingEntryForm",
  "type": "registry:component"
}
