Split requisitions if necessary during approval

Description

This deals with implementing the logic to potentially split requisitions during the approval stage.

Multiple conditions to split a requisition:

  1. Parent node has a partner node

  2. There is a supply partner with an entry for that partner node and requisition's program

  3. That entry has a facility that matches the requisition's facility

  4. That entry has a product that matches any products in the requisition line items

All conditions must be met before splitting the requisition.

Acceptance Criteria

  • The splitting occurs after the first approval and if the above conditions are met.

  • After the split, there should be:

    • X requisitions, where X is the number of partners handling the requisition

    • the original requisition

      • data for products that are supplied by partners should be removed (or changed to zero) and in the remarks column there should be a text that informs the product is handled by supply partner

    • example: one standard requisition + one CHAZ requisition

    • for now, the edge case that one supply partner supplies all products from the requisition is out of scope from this ticket (because the situation never happens) but the implementation should be easy to modify to handle the situation.

  • For each of the partners there is a requisition created

    • Requisition should be in the IN_APPROVAL/APPROVED state (depending on the number of supervisory nodes the requisition is going through)

    • The original is added as a parameter in the extra data

    • requisition contains only products that they supply (all the same columns exist). It should not contain products supplied by any other partners.

    • CHAZ can edit the approved quantities

  • Standard requisition always contains all line items regardless of who supplies, but with comments or notes in the remarks column identifying there is a different supplier (this can also be some sort of visual identifier)

  • After the requisition is split, the created requisitions are not rejectable.

    • Once the requisition has been split, it cannot be rejected.

  • If requisition is not split then the requisition should follow the normal requisition workflow.

Attachments

5

Activity

Show:

Joanna Szymańska January 17, 2019 at 4:09 PM
Edited

I tested this ticket and it works according to the acceptance criteria. The issues mentioned above will be placed on separate tickets.

Joanna Szymańska January 17, 2019 at 3:14 PM

Thank you for explaining, I will prepare a ticket regarding this issue.

Łukasz Lewczyński January 17, 2019 at 7:29 AM

I provided required changes but the issue in the last your comment is more related with configuration. I mean you get an error that there is duplication because of the same program, facility, and node but you get the error because your partner nodes have the same parent node. We probably should somehow verify that before we allow to save supervisory node but this is for a new ticket. I will move the ticket back to QA when my changes pass the review.

Joanna Szymańska January 16, 2019 at 11:32 AM

I also noticed that I can't approve requisition for Family Planning Balaka District Hospital.
Reproduction steps:

  1. Create a new supply partner with two associations (FP approval sub point 2 and FP approval point), choose for them facility Balaka District Hospital and any number of products.

  2. Initiate a requisition for Family Planning and Balaka District Hospital and fill in one product, skip the others, submit and authorize.

  3. Go to Requisitions > Approve.

  4. Click "View Requisition" next to the new requisition and try to approve.

Result:

  • An error appears: "could not execute statement; SQL [n/a]; constraint [req_prod_fac_per_node]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement".

  • When I try to change the approved quantity, another error occurs: "The requisition with ID b0fc5fb4-6807-48d3-99d1-d290fe548340 has a newer version on the server; the server version will be used, and you will need to remake your changes."

Joanna Szymańska January 16, 2019 at 10:57 AM

I am still testing, as soon as I finish I will move the ticket to you.

Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Original estimate

Time tracking

1w 3d 1h logged

Components

Sprint

Fix versions

Priority

Time Assistant

Created August 2, 2018 at 9:30 AM
Updated November 29, 2020 at 4:14 PM
Resolved January 17, 2019 at 4:07 PM