Skip to content

fix(spp_case_base): clear is_current when an intervention plan is completed - #478

Open
LunarCapsule127 wants to merge 2 commits into
OpenSPP:19.0from
LunarCapsule127:case_intervention
Open

fix(spp_case_base): clear is_current when an intervention plan is completed#478
LunarCapsule127 wants to merge 2 commits into
OpenSPP:19.0from
LunarCapsule127:case_intervention

Conversation

@LunarCapsule127

Copy link
Copy Markdown

Why is this change needed?

action_complete marked a plan state = "completed" and stamped actual_end_date, but never released is_current. Since the only other writer of is_current = False was the revision path, a plan that finished normally stayed the case's current plan indefinitely.

That left every consumer of the pair reading an incoherent state: current_plan_id (derived purely from is_current) kept pointing at completed work, while "has an active plan" derivations read False. It also tripped the one-current-plan-per-case constraint, blocking anyone from marking a fresh plan as current.

Fixes #458.

How was the change implemented?

Folded "is_current": False into the existing action_complete write, so completing a plan ends its tenure as the case's current plan the same way action_create_revision already does. The change goes through write(), so downstream overrides observe it (the reporter noted a local override they can drop once this lands).

New unit tests

test_complete_clears_is_current in spp_case_base/tests/test_case_intervention_plan.py: creates a current plan, confirms it is the case's current_plan_id, completes it, then asserts state == "completed", is_current is False, and the case has no current plan.

Unit tests executed by the author

(fill in after you run them; see the command below)

How to test manually

  1. Open a case and create an intervention plan. Confirm it shows as the case's current plan.
  2. Take the plan through to completion (Complete action).
  3. Confirm the case no longer reports it as the current plan, and that you can now mark a new plan as current without hitting the one-current-plan constraint.

Related links

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.

spp_case_base: action_complete never clears is_current, leaving a finished plan as the case's current plan

1 participant