Backend validation for supply partner resource

Description

Currently, we have only basic validation to make sure that related resources - like facility, orderable - exist in the system. As part of this ticket, we should introduce additional validations to make sure that supply partner resource will be correct and to avoid problems with using resources by other services.

Acceptance criteria

  • facilities in associations should be related to the given regular supervisory node by requisition group. In other words, it should be impossible to add any facility but only facilities from a req group which is connected to the given regular supervisory node.

  • only orderables for which FTAPs exists could be in associations. A list of available FTAPs should be retrieved based on facility types from facilities that are in the same association.

    • for example, if in an association there is a facility with a type, only orderables from FTAPs for the facility type should be in the association.

  • the given supply partner should have only one association for the given program/node combo

    • a new constraint on the database layer should be added

  • the given supply partner should have only one association for the given program/node/facility/orderable combo,

    • the check should be global. It means that other supply partner cannot have the same combo.

  • the user should see an appropriate error message

  • The validations happen when supply partner is modified and user clicks save

Activity

Show:
Joanna Szymańska
November 19, 2018, 11:04 AM

I checked again and everything works fine.

Joanna Szymańska
November 16, 2018, 2:42 PM
Edited

I checked this ticket again and everything works correctly, according to the acceptance criteria, I noticed only small typos:
After removing the name from json in the response I receive the message: "Supply parnter code is required" instead of "Supply partner name is required", also in the message is a typo "parnter", should be "partner".
After creating a new SP, and then sending a PUT with the same data as the existing Supply Partner, I get the answer in which there is a typo: "There is a supply partner that have assocation for the given program ARV(...)" should be an "association".

Joanna Szymańska
November 14, 2018, 2:36 PM

While checking this ticket I noticed several cases when instead of specific error information I receive 500 Internal Server Error:

  1. When I use PUT api/supplyPartners/id for existing Supply Partner and I do not change any data;

  2. Appears when I change the code or name for SP: changes can be made for the new Supply Partner, however, when I delete the name, the reply is given to the user that the code is required, not the name (400"Supply parnter code is required.");

  3. When I enter the same facility again in associations;

  4. When I enter a facility that does not belong to the correct requisition group(instead of the correct information);

  5. When I enter the same program in associations again;

  6. When I added another program in associations;

  7. When I added the same program, facility, supervisoryNode and orderables as in the previous Supply Partner.

Łukasz Lewczyński
November 2, 2018, 8:32 AM
Edited

I updated ticket about checking what facilities and orderables could be in an association.

Łukasz Lewczyński
October 23, 2018, 9:39 AM

FYI:

Done

Assignee

Łukasz Lewczyński

Reporter

Łukasz Lewczyński

Labels

Story Points

5

Time tracking

0m

Time remaining

1h

Components

Sprint

None

Fix versions

Priority

Major