500 error when adding a CCE item with the same serial no., type and model

Description

I noticed an issue when I was testing OLMIS-3326. When one first adds an inventory item and then, tries to add another one with the same serial number, type and model, the 500 error occurs, no matter what one enters in any of the other fields (e.g. name, reference name, functional status, program or facility).

Reproduction steps:

1. Go to CCE Management > CCE Inventory.
2. Add e.g. a freezer with Haier as model. Choose any facility and program.
3. Complete all required fields with any data.
4. Choose any functional status.
5. The freezer should be added.
6. Add another freezer with Haier as model. Choose any facility and program.
7. Enter the same serial number as in step #3. Fill in all other fields with any data.
8. Choose any functional status and try to add the item.
9. The 500 error occurs.

Acceptance criteria:

1. The system should not allow a user to add a CCE inventory item that has the same serial number, type and model as one that already exists. Validation needs to be added.
2. Instead of the Internal Server Error, the 400 "Bad Request" code should be returned when trying to add another piece of equipment of the same model, type and serial number as one that already exists in the inventory.
3. When adding the inventory item, after clicking the "Update" button in the "Equipment Functional Status" modal, a helpful error message should appear in a modal stating: "Equipment of the same serial number, type, and model already exists." The duplicate inventory item will not be saved to the database.
4. The user will be directed back to the modal. From there they can make changes to the serial number, type, or model. OR the user can click Cancel to exit out of the modal.

Environment

None

Assignee

Klaudia Pałkowska

Reporter

Joanna Bebak

Labels

None

Story Points

2

Time tracking

12h

Components

Sprint

None

Fix versions

Affects versions

Priority

Major
Configure