Repository navigation
feat: close financial year wizard - #50
Merged
Merged
Conversation
Add migration 050 with the fiscal_year_close_batches table and rollover columns on cost_records, a service module that plans, executes, and reverts a close, and admin-only endpoints under /api/cost-records/close-year. Execute locks services and cost records, rechecks the plan hash, converts estimated records to actual in place, and creates one summed next-year estimate per service. Revert restores chained closes in order. Includes CI unit tests and opt-in PostgreSQL tests (CATALOGIT_DB_TESTS=1).
Add the /costs/close-year wizard (pick year, review and edit, confirm by typing the year, done) with previous closes and revert, plus an admin-only entry button on the Costs report. The Costs report accepts year and mode query params.
Cover the close rules, flags, revert, and yearly cost effects in the README and release notes, list the new MCP tool, and update the spec with the decisions made during implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a guided "Close financial year" action for service costs, as described in
docs/superpowers/specs/2026-11-06-close-fiscal-year-design.md.Closing year X:
estimatedservice cost records toactualin place.estimatedrecord per service in X+1. Its amount is the sum of the year's actuals, with an optional uplift.Archived services, budget records, and hardware costs are left out. Admins review and edit every row in a wizard before confirming. Each close is stored as a batch and can be reverted.
Changes
050:fiscal_year_close_batchestable, plusrollover_batch_id,rollover_actionandrollover_created_batch_idoncost_records.app/services/fiscal_year_close.py. The plan logic is pure functions, so it can be tested without a DB; async functions handle execute and revert./api/cost-records/close-year:POST /preview,POST /execute,POST /revert,GET /batches. Every endpoint requires admin plus financial visibility.409, and nothing is written.DecimalwithROUND_HALF_UP. Validation errors return400./costs/close-yearwizard with four steps: pick year, review and edit, confirm, done.409reloads the preview.yearandmodequery params.preview_close_fiscal_yeartool. There are no execute or revert tools.Decisions beyond the original spec
rollover_created_batch_idcolumn fixes this:409 Revert these later closes first: FY....is_activepart of the hash stable until commit.uplift_pct, conversionnotesandpayment_method_id, andexisting_actual_payment_method_ids. The wizard uses the last one to update themixed_payment_methodsflag live.GET /batchestimestamps carry a UTC offset. User names fall back to the user's email.Known limitations
changed_since_closecan miss an edit whose transaction started before the close and committed after it.backend/tests/test_fiscal_year_close_db.py) are opt-in, and CI skips them. They need a disposable*_testdatabase andCATALOGIT_DB_TESTS=1.Test plan
uv run --locked --with pytest pytest -q: 262 passed, 1 skipped (the opt-in DB module)409, running the close twice, revert (including chained closes and archived services),GET /batcheswithchanged_since_close, history rows, a concurrent execute, and a cost record PUT that waits for the close's locks.050upgrade, downgrade to049, and upgrade again on the test databasenpm run lint,npm test(53 tests),npm run builduv run --locked --with pytest pytest -q: 53 passed