Keep bills banner and notices to the bills the page lists

Merged
GA
2mo ago
+101-9

Problem

The Bills overview lists payable series only (payable_series_ids: active or inactive, amount > 0, no destination or a debt destination). Two surfaces on the same page counted series outside that set, so they could sit next to "No bills yet":

  • Awaiting-review banner. detected_awaiting_review counted every detected active series, detected income and savings transfers included. A family whose only series is a detected payroll got "We found 1 recurring payment… so the totals here match what you actually pay", but those totals leave income out.
  • Price-change notices. The price-change query joined any series in the family, with no status or type filter. An ended bill whose price changed 5 days ago rendered "Old Streaming changed price: …". Suggested and income series did the same.

Change

All of these now share the overview's scope, payable_series_ids, which already applies accessible_by(Current.user):

  • The banner counts only detected active series the overview lists.
  • Trial, renewal and price-change notices are built from the listed bills (where(id: payable_series_ids).active). Price changes for suggested series and income are dropped on purpose: a suggestion's price isn't news until it's a bill, and an income change belongs on the Income plan.
  • The "Needs review" payment queue (suggested_allocations) gets the same scope. The ticket asked to check whether the matcher can propose a payment for a series the page doesn't list. It can. Matcher#open_occurrences scores every scheduled occurrence of any non-transfer series, whatever its status, and ending or pausing a bill leaves its scheduled occurrences in place. So the queue could ask about a payment for a bill the user had deleted.

Screenshots

Before on the left, after on the right.

Detected payroll only: the banner no longer appears.
Banner before/after

Ended bill with a recent price change: no notice.
Price notice before/after

The month pulse and AI chips still showing on the empty page are #3905's change, not this one.

Validation

  • 3 new tests in test/controllers/bills_controller_test.rb, one per change, each failing on main:
    • Detected income and savings transfers don't raise the banner, and a detected bill still does.
    • Ended, suggested and income series raise no price notice. The suggested case runs on its own page, because the suggestion strip replaces the "No bills yet" empty state.
    • A suggestion against an ended bill stays out of the review queue.
  • bin/rails test: 10432 runs, 0 failures, 1 error. The error is in ReportsControllerTest#test_a_disposal_carried_in_a_third_currency… ("Date has already been taken", reports_controller_test.rb:57), a file this PR doesn't touch, and it fails on its own too. It looks date-dependent (cf. #3910).
  • bin/rubocop: clean. bin/brakeman: no warnings. No ERB or JS changed, so ERB lint and Biome don't apply.

Overlaps: #3895 and #3885 also edit bills_controller.rb, but in different methods.

Summary by CodeRabbit

  • Bug Fixes
    • The bills overview now limits notices and review counts to bills included in its payable-bills list.
    • Income and savings transfers no longer trigger the detected-bill review banner.
    • Price-change notices are suppressed for ended bills, income, and suggested bills.
    • Payment-review suggestions exclude ended bills and occurrences skipped in the previous month, and are limited to scheduled or paid occurrences shown on the overview.