Permissions error updating CCE functional status at my facility

Description

Summary
If the user "rivo" tries to set a non-functional Functionality Status of a CCE item at their home facility, Depósito Provincial Niassa, they receive an error:

"There was an error with this request, please contact the server administrator.
There is no supervisory node for program 418bdc1d-c303-4bd0-b2d3-d8901150a983 and facility 0898dcd6-53f2-41b6-ba7d-b2f5122ffb44"

Found this bug during test case during execution round "3.3 RC Phase 1 - second round (correct one)"

Steps to Reproduce
1. Follow all steps in (log in as "rivo", navigate to CCE Management > CCE Inventory, click Search to search at home facility, Depósito Provincial Niassa with EPI program)
2. Click edit on a CCE inventory item that is already functioning, such as Fridge #12. Change functionality status to "Awaiting Repair" or "Unserviceable". Choose a reason and, if prompted, a decommission date.
3. Click Update to save your changes.
4. ERROR: error message appears and your changes are not saved:

"There was an error with this request, please contact the server administrator.
There is no supervisory node for program 418bdc1d-c303-4bd0-b2d3-d8901150a983 and facility 0898dcd6-53f2-41b6-ba7d-b2f5122ffb44"

Note that saving WORKS if you are changing to Functioning. Issue reported on Chrome on UAT on April 17, 2018.

Root Cause
Is this an error in our permissions handling or in demo data? TBD

Q: Would it only impact "rivo" or impact any country users?
A: This error can impact other users that have home facility not associated with any supervisory node (by requisition groups)

Q: Why does the error only happen for non-functioning status (is the permissions problem happening when it goes to manipulate the reason?)
A: Error is only happening for non-functioning status because we send email about non-functioning device to users with inventory edit rights for given program and facility. What is happening in details:
1. rivo create inventory because it has required rights (CCE_INVENTORY_EDIT for home facility and given program)
2. there is no validation that "rivo can't create inventory because there is no facility in Requisition Group for any supervisory node"
4. rivo change status to non-functioning because it has required rights (CCE_INVENTORY_EDIT for home facility and given program)
5. System tries to send notification but it fails (can't find supervisory node for facility)

Acceptance Criteria

  • Need to determine source problem, fix it, perhaps add automated test

  • we shouldn't be throwing an exception if supervisory node is not found. There's no such requirement when creating inventory item. If there's no SN, we just do not search for users at this SN.

Environment

None

Status

Assignee

Paweł Albecki

Reporter

Brandon Bowersox-Johnson

Labels

Story Points

1

Time tracking

12h

Components

Sprint

None

Fix versions

Affects versions

3.3

Priority

Blocker