# S19-08 Assumptions — Year-End Carry-Forward

## Task
Implement `CloseYearEnd` action: close P&L accounts to surplus, create next FY period.

## Assumptions

1. **Carry-forward is cumulative**: The system derives BS balances cumulatively from all posted transactions. Explicit opening balance entries are NOT created for the new FY — the prior year's closing balances are automatically the new year's opening balances. This satisfies the tender requirement "dibawa ke hadapan secara automatik" without redundant data.

2. **Surplus/Deficit account**: The caller must pass a `surplusAccountId` pointing to an equity-type CoA account. No automatic discovery of the surplus account — this is a tenant configuration choice.

3. **Closing entry creates a Transaction + TransactionLines**: We add `year_end_close` to the `chk_txn_type` constraint and the `TransactionType` enum. The closing JE uses `JournalEntry` with `TransactionLine` records (consistent with AR/AP pattern).

4. **Pre-close validation**: All monthly periods in the fiscal_year must be in state `closed`, `re_closed`, or `locked`. If any are `open` or `draft`, the year-end close is blocked.

5. **Year-end period**: A `period_type = 'year_end'` `AccountingPeriod` must exist for the FY being closed. The closing JE is posted to this period. If no year_end period exists, one is created covering the last day of the fiscal year.

6. **New FY period**: A new `period_type = 'month'` period for January of the next FY is created as a `future` period. The caller can open it subsequently.

7. **Cannot reopen**: Closed year-end periods cannot be reopened via the existing `ReopenPeriod` action (which only handles monthly periods). Reopening a year-end requires a new dedicated action — out of scope for S19-08.

8. **Domain location**: Action lives in `app/Domain/Accounting/Actions/` (not Period/), consistent with other period management actions.
