{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "author": "Lopifi (https://lopifi.com)",
  "categories": [
    "accounting-core-gl",
    "finance",
    "accounting"
  ],
  "dependencies": [],
  "description": "What the schedules will post, before they post.",
  "files": [
    {
      "content": "\"use client\";\n\nimport { useScrollEdges } from \"@/hooks/ledger/use-scroll-edges\";\nimport { cn } from \"@/lib/ledger/cn\";\nimport { formatDate } from \"@/lib/ledger/fiscal-period\";\nimport type { MoneyValue } from \"@/lib/ledger/money.types\";\nimport { Button } from \"@/components/ledger/button\";\nimport { Money } from \"@/components/ledger/money\";\nimport { Rule } from \"@/components/ledger/rule\";\n\nexport type PreviewEntry = {\n  id: string;\n  schedule: string;\n  description: string;\n  debitAccount: string;\n  creditAccount: string;\n  amount: MoneyValue;\n};\n\nexport interface SchedulePreviewProps {\n  className?: string;\n  entries: PreviewEntry[];\n  /** Caps the scroller so the header and the schedule column can freeze. */\n  maxHeight?: number;\n  onPostBatch?: () => void;\n  periodEnd: Date;\n  total: MoneyValue;\n}\n\n/**\n * Every entry the period's schedules will generate, with totals, **before**\n * anything posts. A close should never be surprised by its own automation.\n *\n * Posts as one batch with one audit record.\n */\nexport function SchedulePreview({\n  periodEnd,\n  entries,\n  total,\n  onPostBatch,\n  maxHeight = 520,\n  className,\n}: SchedulePreviewProps) {\n  const scroller = useScrollEdges<HTMLDivElement>();\n  return (\n    <div className={cn(\"space-y-3\", className)}>\n      <div className=\"rounded-xl border border-border bg-surface\">\n        <div className=\"px-6 pb-4 pt-6\">\n          <p className=\"text-title-sm font-medium\">Schedule entries to be posted</p>\n          <p className=\"text-caption text-text-secondary\">\n            Period ending {formatDate(periodEnd)} · nothing has posted yet\n          </p>\n        </div>\n        <div className=\"ledger-frozen scrollbar-thin\" ref={scroller} style={{ maxHeight }}>\n          <table className=\"w-full min-w-[820px]\">\n            <caption className=\"sr-only\">\n              Schedule entries to be posted for the period ending {formatDate(periodEnd)}\n            </caption>\n            <thead>\n              <tr className=\"border-b border-border-subtle\">\n                {[\"Schedule\", \"Description\", \"Debit\", \"Credit\", \"Amount\"].map((h, i) => (\n                  <th\n                    className={cn(\n                      \"px-3 py-3 text-label font-medium text-text-secondary\",\n                      i === 4 ? \"pr-6 text-right\" : \"text-left\",\n                      i === 0 && \"pl-6\",\n                    )}\n                    key={h}\n                    scope=\"col\"\n                  >\n                    {h}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {entries.map((e) => (\n                <tr className=\"border-b border-border-subtle\" key={e.id}>\n                  <td className=\"py-3 pl-6 pr-3 text-caption capitalize text-text-secondary\">{e.schedule}</td>\n                  <th className=\"px-3 py-3 text-left text-body font-normal\" scope=\"row\">\n                    {e.description}\n                  </th>\n                  <td className=\"px-3 py-3 text-caption text-text-secondary\">{e.debitAccount}</td>\n                  <td className=\"px-3 py-3 text-caption text-text-secondary\">{e.creditAccount}</td>\n                  <td className=\"py-3 pl-3 pr-6 text-right\">\n                    <Money accounting value={e.amount} />\n                  </td>\n                </tr>\n              ))}\n            </tbody>\n            <tfoot>\n              <tr>\n                <td colSpan={4} />\n                <td className=\"pr-6\">\n                  <Rule variant=\"subtotal\" />\n                </td>\n              </tr>\n              <tr>\n                <th\n                  className=\"py-3 pl-6 pr-3 text-left text-label font-medium\"\n                  colSpan={4}\n                  data-frozen=\"none\"\n                  scope=\"row\"\n                >\n                  Total to post\n                </th>\n                <td className=\"py-3 pl-3 pr-6 text-right\">\n                  <Money accounting size=\"md\" value={total} />\n                </td>\n              </tr>\n              <tr>\n                <td colSpan={4} />\n                <td className=\"pr-6\">\n                  <Rule variant=\"total\" />\n                </td>\n              </tr>\n            </tfoot>\n          </table>\n        </div>\n      </div>\n\n      <Button onClick={onPostBatch} variant=\"primary\">\n        Post {entries.length} entries as one batch\n      </Button>\n      <p className=\"text-caption text-text-tertiary\">\n        Posting creates one audit record covering the whole batch.\n      </p>\n    </div>\n  );\n}\n",
      "path": "components/ledger/schedule-preview.tsx",
      "target": "components/ledger/schedule-preview.tsx",
      "type": "registry:component"
    }
  ],
  "name": "schedule-preview",
  "registryDependencies": [
    "@lopifi/theme",
    "@lopifi/button",
    "@lopifi/cn",
    "@lopifi/fiscal-period",
    "@lopifi/money",
    "@lopifi/money.types",
    "@lopifi/rule",
    "@lopifi/use-scroll-edges"
  ],
  "title": "SchedulePreview",
  "type": "registry:component"
}
