Skip to content

fix(strr-api+strr-examiner-web): count provisionally approved renewals as approved, and keep older ones in Review Renew (REGBACKLOG-391) - #1969

Open
severinbeauvais wants to merge 5 commits into
bcgov:feature-REGBACKLOG-391-v2from
severinbeauvais:REGBACKLOG-391-todos-non-terminal
Open

severinbeauvais wants to merge 5 commits into
bcgov:feature-REGBACKLOG-391-v2from
severinbeauvais:REGBACKLOG-391-todos-non-terminal

Conversation

@severinbeauvais

@severinbeauvais severinbeauvais commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Issue:

Description of changes:

When a renewal is auto-approved provisionally (PROVISIONAL_REVIEW, "Approved – Provisional"), the registration's expiry is extended at once, while the renewal waits for an examiner. The 409 check counted that renewal as still in progress, and it doesn't filter by date. So in the host's next renewal window, /todos offered Renew but submitting it returned 409 RENEWAL_ALREADY_IN_PROGRESS. In Production, about 12,100 registrations have a latest renewal in PROVISIONAL_REVIEW. Their next windows open from December 2026.

This PR also addresses the Copilot comment on #1964: /todos and the 409 check now use the same rule. It also addresses Jacky's comment on #1964 (#1964 (comment)): the 409 check now also runs when a renewal draft is submitted.

  • Shared status lists in application_service.py:
    • RENEWAL_APPROVED_STATES: FULL_REVIEW_APPROVED, PROVISIONALLY_APPROVED, AUTO_APPROVED, PROVISIONAL_REVIEW, PROVISIONAL_REVIEW_NOC_PENDING, PROVISIONAL_REVIEW_NOC_EXPIRED
    • RENEWAL_DECLINED_STATES: DECLINED, PROVISIONALLY_DECLINED
    • RENEWAL_FINISHED_STATES: both of the above
  • 409 check: a new renewal is refused only while another renewal for the registration and account is in progress, that is, not finished. It's no longer refused because of a provisionally approved renewal.
  • 409 check on submit: the check used to run only when a renewal was started, so submitting an existing draft created an invoice even while another renewal was in progress. That's how H353013514 paid for two renewals on 2026-06-14, from drafts started before the check went live. It now also runs when a renewal draft is submitted; saving a draft still isn't checked, since that creates no invoice. find_non_terminal_renewal_for_payment_account takes an optional exclude_application_id, so the draft being submitted isn't its own conflict. In Production, 52 registrations have a renewal draft beside another unfinished renewal on the same account (38 beside PAYMENT_DUE, 14 beside another DRAFT), all from before the check went live on 2026-06-01.
  • /todos: Renew is hidden while a renewal is in progress, whenever it was submitted, matching the 409 check. It's also hidden once a renewal submitted in the current window is approved, provisionally or in full. Declined renewals never hide it.
  • Unchanged: NOC_PENDING and NOC_EXPIRED without the provisional prefix belong to full reviews that haven't been approved. They still count as in progress.
  • Review Renew filter: now that a provisionally approved renewal doesn't block the next one, a newer renewal (even a draft) became the registration's latest application and hid an older renewal still awaiting review. _review_renew_condition now matches a registration with no registration-level decider when any of its renewals is in PROVISIONAL_REVIEW or PROVISIONALLY_APPROVED with no decider. In Production, 102 registrations have an undecided provisional renewal with a newer application after it; in 95 of them the newer one is a leftover DRAFT or PAYMENT_DUE renewal, which REGBACKLOG-494 and REGBACKLOG-495 remove.
  • Review Renew on the examiner dashboard row: isReviewRenew in dashboard.vue now uses the same rule as the filter, so a row the filter returns is labelled Review Renew instead of Approved or "-". The Renewal badge follows it.
  • Versions: strr-api goes to 0.3.50. strr-examiner-web goes to 0.2.75.

Notes for reviewers:

  • Web changes are only on the examiner dashboard: the host and platform apps take Renew from /todos.
  • Merge conflict to expect with fix(strr-api): ignore unfiled applications in the registration sub-status filters (REGBACKLOG-391) #1970: fix(strr-api): ignore unfiled applications in the registration sub-status filters (REGBACKLOG-391) #1970 changes hasRenewalApplication in dashboard.vue, which this PR removes. Whichever PR merges second should keep this PR's isReviewRenew.
  • Open question: if an older provisional renewal is still unreviewed when the next cycle starts, should it stay in the Review Renew queue at all? It does for now. If not, the filter and the row label should drop it together. See the discussion in the comments.
  • This PR depends on the renewal window, so it mustn't go to main without it. Before this PR, AUTO_APPROVED already counted as finished, and in Production H564079612 renewed again 10 seconds after its first renewal was auto-approved, paying twice. This PR makes PROVISIONAL_REVIEW count as finished too, which would widen that gap. The renewal window closes it: once a renewal is approved, the expiry moves a year on, so a new renewal gets RENEWAL_WINDOW_NOT_OPEN.
  • No database migrations.
  • A question for the business, not changed here: if an examiner rejects or withdraws a PROVISIONAL_REVIEW renewal directly, without an NOC, the renewal becomes DECLINED and the registration stays active with its extended expiry. Rejecting after an NOC gives PROVISIONALLY_DECLINED and cancels the registration. This hasn't happened in Production yet; it's tracked in REGBACKLOG-501.

How this was tested:

  • Unit and integration tests:
    • The full strr-api suite passed: 889 passed, 6 skipped.
    • A new parametrized test checks the 409 against nine existing-renewal statuses.
    • test_draft_is_submitted_only_while_no_other_renewal_is_in_progress checks that saving a draft always works, and that submitting it gets a 409, with no invoice and the draft left as a DRAFT, only while another renewal is in progress. Its three conflict cases fail without the fix.
    • The /todos tests now include the provisional and NOC statuses.
    • test_get_todos_with_submitted_renewal_recent_and_old now uses an approved renewal from last year. A PAID one is still in progress, so it correctly hides Renew.
    • test_search_registrations_review_renew_keeps_older_provisional_renewal_after_newer_renewal covers an older provisional renewal followed by a newer DRAFT or AUTO_APPROVED renewal. It fails on the old query and passes now.
    • black and isort are clean. pylint reports no new warnings.
    • New parametrized dashboard tests cover an older renewal awaiting review under a newer DRAFT, PAYMENT_DUE, AUTO_APPROVED, or examiner-decided PROVISIONALLY_APPROVED renewal. All four fail without the fix and pass with it.
    • The full examiner-web unit suite passed: 323 tests. eslint is clean.
  • Manual, local and database checks: the Production counts above came from read-only queries.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the BC Registry and Digital Services BSD 3-Clause License

…he 409 check and /todos (REGBACKLOG-391)

A renewal in PROVISIONAL_REVIEW, or in one of its NOC statuses, has already extended the registration, but the 409 check treated it as in progress. It refused the host's next renewal with RENEWAL_ALREADY_IN_PROGRESS, whenever that one was submitted, while /todos still offered Renew.

- Add RENEWAL_APPROVED_STATES (including the provisional statuses), RENEWAL_DECLINED_STATES and RENEWAL_FINISHED_STATES; the 409 check now refuses a new renewal only while another is in neither list
- /todos hides Renew while a renewal is in progress, whenever it was submitted, matching the 409 check, or once a renewal submitted in this window is approved, provisionally or in full
- Bump strr-api to 0.3.50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A new renewal draft or auto-approved renewal can hide an older unresolved provisional renewal from the examiner’s review queue; the queue query needs correction and regression coverage.

1 open issue
What changed in this PR

Updates renewal eligibility so provisional approvals no longer block the next renewal cycle, aligning /todos with the API conflict check.

Changes:

  • Shares approved, declined, and finished renewal status lists.
  • Updates conflict checks and todo visibility, with regression tests.
  • Bumps strr-api to 0.3.50.
File Description
strr-api/​tests/​unit/​resources/​test_renewal_window_api.py Tests conflicts across renewal statuses.
strr-api/​tests/​unit/​resources/​test_renewal_todos_api.py Expands status and window coverage.
strr-api/​tests/​unit/​resources/​test_registrations.py Uses an approved prior-year renewal.
strr-api/​src/​strr_api/​services/​application_service.py Defines shared renewal status lists.
strr-api/​src/​strr_api/​resources/​registrations.py Updates Renew todo visibility.
strr-api/​src/​strr_api/​resources/​application.py Allows renewals after provisional approval.
strr-api/​src/​strr_api/​models/​application.py Updates conflict-query parameter terminology.
strr-api/​pyproject.toml Bumps API version to 0.3.50.

Review effort: Balanced

Comment on lines +233 to +235
finished_status_values = tuple(s.value for s in RENEWAL_FINISHED_STATES)
conflicting = ApplicationModel.find_non_terminal_renewal_for_payment_account(
account_id, registration_id, terminal_status_values
account_id, registration_id, finished_status_values

@severinbeauvais severinbeauvais Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Now that a provisionally approved renewal no longer blocks the next one, the newer renewal became the "latest application", and the queue only looked at that one.

_review_renew_condition now matches a registration with no registration-level decider when any of its renewals is in PROVISIONAL_REVIEW or PROVISIONALLY_APPROVED with no decider, so an older renewal awaiting review stays in the queue whatever is filed after it.

I added test_search_registrations_review_renew_keeps_older_provisional_renewal_after_newer_renewal, which covers a newer DRAFT and a newer AUTO_APPROVED renewal; it fails on the old query and passes now.

Fixed in new commit.

@severinbeauvais

severinbeauvais commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator Author
  • A question for the business, not changed here: if an examiner rejects or withdraws a PROVISIONAL_REVIEW renewal directly, without an NOC, the renewal becomes DECLINED and the registration stays active with its extended expiry. Rejecting after an NOC gives PROVISIONALLY_DECLINED and cancels the registration. This hasn't happened in Production yet; it will get its own ticket.

I've created this ticket for that: https://hous-hpb.atlassian.net/browse/REGBACKLOG-501

…ue (REGBACKLOG-391)

Now that a provisionally approved renewal no longer blocks the next one, a newer renewal (even a draft) became the registration's latest application and hid the older renewal from reviewRenew=true. The queue now matches a registration with no registration-level decider when any of its renewals is in PROVISIONAL_REVIEW or PROVISIONALLY_APPROVED with no decider.

Adds a regression test for an older provisional renewal followed by a newer DRAFT or AUTO_APPROVED renewal.

@Jacky-Pham Jacky-Pham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep Review Renew on the Examiner row when an older renewal is pending review and a newer one is approved?

@severinbeauvais

Copy link
Copy Markdown
Collaborator Author

Can we keep Review Renew on the Examiner row when an older renewal is pending review and a newer one is approved?

Yes, that makes sense, but the case is rare. The rule that only one renewal can be open at a time is no longer strict. With this PR, a renewal in PROVISIONAL_REVIEW counts as finished, so it doesn't block the next renewal. What stops the next renewal now is the renewal window.

Here's how two renewals can exist side by side:

  1. The host renews this year. It's auto-approved into PROVISIONAL_REVIEW, and the expiry moves a year on right away.
  2. No examiner reviews it.
  3. About 11 months later, the next year's window opens: roughly a month before expiry for hosts and platforms, two months for strata hotels. The host starts a draft or files the next renewal.
  4. That newer application is now the registration's latest. The older renewal is still waiting for review.

Even so, the dashboard should match the filter. Otherwise, a row that the "Review Renew" filter returns would be labelled "Approved", or carry a draft's label.

But this raises a question: If an older provisional renewal is still unreviewed when the next cycle starts, should it stay in the review queue at all? If no then both the filter and the label should drop it.

I ran a query in Prod. Your case isn't theoretical. About 95 registrations show it today. They aren't caused by a year-long review backlog, though. They're caused by unfinished renewals left on top of the one awaiting review. However, https://hous-hpb.atlassian.net/browse/REGBACKLOG-494 will delete the duplicate draft renewals and https://hous-hpb.atlassian.net/browse/REGBACKLOG-495 will clean up early payment-due renewals with unpaid invoices.

@severinbeauvais

Copy link
Copy Markdown
Collaborator Author

But this raises a question: If an older provisional renewal is still unreviewed when the next cycle starts, should it stay in the review queue at all? If no then both the filter and the label should drop it.

What do you guys think?

I'll commit a change to make the row label match the filter that's already on this PR. If we decide to "drop it" instead then the API filter and the label would need to be changes in a follow-up commit.

… review (REGBACKLOG-391)

The dashboard row showed Review Renew only when the latest application was a renewal in the provisional review queue. Now that a provisionally approved renewal doesn't block the next one, a newer renewal (draft, unpaid, or approved) hid an older one still awaiting review, so the row was labelled Approved or "-" even though the reviewRenew filter returned it.

- isReviewRenew now uses the same rule as the API's reviewRenew filter: no registration-level decider, and any renewal in PROVISIONAL_REVIEW or PROVISIONALLY_APPROVED with no decider. The Renewal badge follows it.
- strr-examiner-web goes to 0.2.75.
@severinbeauvais severinbeauvais changed the title fix(strr-api): count provisionally approved renewals as approved in the 409 check and /todos (REGBACKLOG-391) fix(strr-api+strr-examiner-web): count provisionally approved renewals as approved, and keep older ones in Review Renew (REGBACKLOG-391) Dec 3, 2026
return false
}
const applications = reg.header?.applications ?? []
return applications.some(app =>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make the Approved filter match the row label? when an older renewal still needs review and a newer one is auto-approved, the row says Review Renew in the Approved filter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! The row label is right: once an older renewal is still awaiting review, the row should stay in Review Renew. So I fixed the filter instead. The Approved filter now leaves out registrations that Review Renew picks up. That covers your case and one more: a newer provisional renewal where the examiner decision is only on the application. While I was there, I also made Review + Approved selected together return exactly what the two filters return separately. Before, it matched on the latest application's status alone, so labels could disagree there too. Tests now check each filter for the case where an older renewal is still awaiting review and a newer one exists.

See new commit.

…s submitted (REGBACKLOG-391)

The 409 RENEWAL_ALREADY_IN_PROGRESS check ran only when a renewal was started, so submitting an existing draft created an invoice even while another renewal was in progress. That's how H353013514 paid for two renewals on 2026-06-14, from drafts started before the check went live. In Production, 52 registrations still have a renewal draft beside another unfinished renewal.

- The check now also runs when a renewal draft is submitted. Saving a draft still isn't checked, since that creates no invoice.
- find_non_terminal_renewal_for_payment_account takes an optional exclude_application_id, so the draft being submitted isn't its own conflict.
- Adds test_draft_is_submitted_only_while_no_other_renewal_is_in_progress.

Addresses review feedback on bcgov#1964.
@severinbeauvais

Copy link
Copy Markdown
Collaborator Author
  • 409 check on submit: the check used to run only when a renewal was started, so submitting an existing draft created an invoice even while another renewal was in progress. That's how H353013514 paid for two renewals on 2026-06-14, from drafts started before the check went live. It now also runs when a renewal draft is submitted; saving a draft still isn't checked, since that creates no invoice. find_non_terminal_renewal_for_payment_account takes an optional exclude_application_id, so the draft being submitted isn't its own conflict. In Production, 52 registrations have a renewal draft beside another unfinished renewal on the same account (38 beside PAYMENT_DUE, 14 beside another DRAFT), all from before the check went live on 2026-06-01.

@Jacky-Pham ^^^ in response to your comment on #1964.

…BACKLOG-391)

- The Approved filter now leaves out registrations that the Review Renew filter returns, so a row labelled Review Renew (an older renewal awaiting review, with a newer auto/full-review approved or application-decided renewal) no longer shows under Approved.
- Review and Approved selected together now return exactly the union of the two filters, instead of matching on the latest application's status alone.
- The Review Renew subquery is joined once and shared by both filters.
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the renewal eligibility and Review Renew queue changes.

1 open issue

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants