bcgov / bcgov/entity

Business-API - Cancel Review Record When Continuation In Filing is Deleted

Open
#25,385 5 comments 0 reactions 0 assignees View on GitHub
Entities Team Priority2
Dominant language
JavaScript
Stars
23
Forks
62
Avg merge
24m
Merged PRs (30d)
1

Description

### Description:
When a user deletes a Continuation In filing from the BRD (while it is in AWAITING_REVIEW or DRAFT status), the linked Review record remains in AWAITING_REVIEW status. This causes the filing to appear on the staff review dashboard even though the filing no longer exists, potentially causing staff to action a review that is no longer required.

To fix this, the status should be changed to "Cancelled".

Example of a continuation authorization reviews that show as Awaiting Review even though the continuation authorization was deleted:
image.png

Desired status for deleted continuation authorization reviews:
image.png

### User Story

None at this time.

### Impact

Staff may review a deleted (cancelled) continuation authorization.

Staff do not see the actual status of the continuation review.

### Chance of Occurring

Probably low: I expect that few users will submit a Continuation Authorization then delete it.

### Pre-Conditions

See Change of Occurring above.

### Steps to Reproduce

1. user creates and submit Continuation Authorization
2. user deletes Continuation Authorization (which is in Awaiting Review status) from BRD
3. staff see this Continuation Authorization on the staff dashboard

### Actual Results

The continuation authorization review is displayed as "Awaiting Review".

### Expected Behaviour

The continuation authorization review should appear as "Cancelled".

### Screenshots

See description above.

### Root Cause Analysis

Unknown without investigation.

### To Do:

- [ ] Add `CANCELLED` status to Filing and Review model
- [ ] Create an migration script to add `CANCELLED` to the `ReviewStatus` enum in the database
- [ ] Add `CANCELLED` to the status exemption list in the `receive_before_change` SQLAlchemy event listener so it doesn't get overwritten to `DRAFT` on save
- [ ] Create a new PATCH endpoint to update the filing and review status to `CANCELLED`
- [ ] Add validation to guard against invalid cancellation state transitions
- [ ] Update/add unit tests

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the Filing and Review models, the ReviewStatus migration, and the receive_before_change SQLAlchemy event listener mentioned in the task list. Trace how deletion is handled and identify the PATCH endpoint and unit tests that cover status changes. Done means deleted continuation filings and their reviews reach CANCELLED without invalid transitions or later being reset to DRAFT.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, postgres, python, sqlalchemy
Domain
api, backend, database, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.