# Portable accounting-period handoff

This is a local educational interchange for a categorized **cash-basis ledger for one cash account**, in USD. It is not a bank feed, a general ledger import, an accrual P&L, or evidence that an account is reconciled. Use the native Ledger and Workbook Studio tools for real books, multicurrency activity, accrual/noncash items, account mappings and postings. Only transactions dated in their stated period are represented; prior-period items still outstanding require the native reconciliation workflow.

Download `fictional-accounting-period.csv` to try the complete flow. It contains February comparison activity and March activity, both fictional. One file yields March P&L inputs, March reconciliation inputs, and—after explicit confirmation—week one's cash opening balance. The file is read through a browser file input. No row, balance or handoff is sent to an endpoint or saved in application storage. JSON downloads are local portable files that the person chooses to keep and share. Use fictional or de-identified material with public connected-agent endpoints.

The header must be exactly:

```csv
period,currency,basis,opening_book_cash,statement_ending_cash,date,reference,description,amount,category,bank_status
```

Each row represents an already-recorded cash ledger movement. Repeat its period's opening book cash and statement ending cash on every row; disagreements fail. Dates must be real dates within `period` (`YYYY-MM`). `currency` is `USD`; `basis` is `cash`. Amounts are plain decimal dollars with at most two decimal places: cash receipts positive, cash payments negative. No grouping commas, currency symbols, scientific notation or implicit rounding are accepted. Quoted CSV fields support commas, escaped quotes and embedded newlines.

Supply a distinct `reference` within each period and a description. There is no inferred matching by amount or description. Duplicate references remain visible and block operation inputs.

Choose `category` explicitly: `revenue`, `cost-of-sales`, `operating-expense`, `other-income`, `other-expense` or `non-pnl`. Revenue and other income normally have positive amounts, costs and expenses normally negative; signed reversals are preserved. `non-pnl` is an explicitly classified cash movement outside income and expenses, such as the fixture's owner withdrawal. Unclassified activity must use an unresolved label; it blocks preparation until the person corrects it.

Choose `bank_status` explicitly: `cleared`, `deposit-in-transit` for a positive receipt, or `outstanding-payment` for a negative payment. These are the preparer's assertions, not verified bank matches. Unknown or unresolved statuses block preparation. Bank charges, interest or other adjustments must already be recorded and categorized in the supplied ledger; the handoff never creates a balancing entry or marks an unrecorded statement line posted.

Select the working period and, optionally, an explicit comparison period. `accountingPeriodHandoff` produces the same `{tool, arguments}` shape as the guide scenario operations. With no comparison selection, prior P&L inputs remain missing. Unknown rows produce `status: needs_review`, full row issues and no operation inputs. All source rows travel in the handoff for review.

For March in the fixture, revenue is $15,000, cost of sales $4,000 and operating expenses $4,000. Ending book cash is $21,500 after a $500 owner withdrawal. The $20,000 statement ending balance plus $3,000 in transit minus a $1,500 outstanding payment equals $21,500. Equality establishes arithmetic only. A separate checked confirmation and cash handoff action carries $21,500 into week one; the minimum buffer and all thirteen weekly flows stay missing until supplied.

Exports:

```js
import { parseAccountingPeriodCSV, accountingPeriodHandoff, cashOpeningHandoff,
  bindAccountingPeriodInput } from './accounting-period.js';
const parsed = parseAccountingPeriodCSV(csvText);
const handoff = accountingPeriodHandoff(parsed, { period: '2026-03', priorPeriod: '2026-02' });
const seed = cashOpeningHandoff(handoff, { confirmed: true }); // separate person-approved action
```

`bindAccountingPeriodInput(panel, onHandoff)` binds a reusable panel with `data-accounting-file`, `data-accounting-period`, optional `data-accounting-prior`, `data-accounting-prepare`, `data-accounting-download` and `data-accounting-status`. Optional `data-accounting-cash` requires a checked `data-accounting-confirm`; `data-accounting-clear` releases local data and download URLs. Neither file selection nor period selection invokes the callback. Only explicit preparation and carry-forward actions do. The return value disposes listeners and download URLs. A newer selection or clear action cancels an older asynchronous file read.
