Add bill start dates and past payment linking
DA
5d ago+1180+1180+0123456789012345678901234567890123456789-87-87-01234567890123456789
Problem
Bills had no editable start date, so a manually declared bill could not show or link payments from months before it was added. The manual payment form also defaulted to today rather than the cycle's own month, and closed cycles could not accept a linked transaction without reopening them.
What changed
- Add
recurring_transactions.started_onandrecurring_occurrences.historical. - Generate up to 12 past cycles from the start date, keep them as history, and exclude them from current overdue/KPI/paycheck/insight/calendar surfaces.
- Show historical open cycles in the bill History list, with "No payment linked" and the cycle amount.
- Allow linking a transaction to a historical or paid cycle, with server-side eligibility checks aligned to the picker.
- Freeze each historical cycle's expected amount to the price in force on its due date.
- Record undated manual payments and Mark paid on the day entered; linked transactions keep their transaction date.
- Carry both new fields through family export/import.
- Keep the history cap at 12 cycles; no pagination or entire-history view.
Validation
- Full Rails suite: 18,576 runs, 113,854 assertions, 0 failures, 0 errors.
- Bill system tests: 9 runs, 55 assertions, 0 failures.
- RuboCop, ERB lint, Biome, and Brakeman are clean.
Scope notes
- Backdating before an installment/Once anchor is rejected.
- API and assistant create/update parity for
started_onis not included in this change. - History is capped at 12 cycles by design.
Summary by cubic
Bills can now record a start date and show up to 12 earlier cycles in History, so users can link past payments without treating those cycles as current debt.
Details
- Historical cycles keep the amount in effect on their due date and stay out of overdue, KPI, calendar, planning, and assistant current-cycle views; resuming a dated bill trims and regenerates that history without touching payments.
- Transactions can be linked to historical or paid cycles; undated manual payments and Mark paid use today's date, while linked transactions keep their transaction date.
- Family exports and imports preserve bill start dates and historical-cycle state; imports skip schedule-bounds validation and history reconstruction until recurrence rules are restored, unchanged start dates aren't revalidated against a retained overdue row, and blank boolean import values fall back to the caller's default.
Summary by CodeRabbit
-
New Features
- Set or update a start date for recurring bills and income to include up to 12 earlier cycles in bill history, with amounts reflecting past price changes.
- View and link payments to backdated cycles, including cycles already marked as paid. Payment dates default to today when not specified.
- Export and import recurring start dates and historical-cycle details.
-
Bug Fixes
- Historical cycles no longer appear as upcoming or overdue in planners, calendars, or bill overviews.
- Transactions that don’t match a bill’s account, currency, amount direction, or eligibility are rejected with a clear message.
- Historical bill rows show their past due date and whether a payment is linked.