human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Invalid item inventory

Open dorner opened this issue 6 months ago • 15 comments

As per discussion with @cielf .

Currently, we allow items to be turned inactive even when it has inventory in a storage location, or is included in an active kit. Both of those things shouldn't be allowed, because it puts the system in an unknown state (what does it mean to have inventory of an item that isn't valid? Or to distribute kits that have invalid items in them?)

This PR makes a number of changes to make this flow stricter.

  • First, a migration to reactivate any inactive items that are currently in active kits.
  • Second, a migration to delete any inventory of inactive items.
  • Remove options to show inactive inventory (e.g. on the storage location or audit page).
  • Do not allow an item to be deactivated if it's in an active kit or in storage location inventory.
  • Do not allow a kit to be reactivated if it contains an inactive item (the user will be prompted to reactivate the item first).

This will help with the event sourcing project as we will not need to track the active status of items for querying them on an inventory basis.

dorner avatar Dec 22 '23 16:12 dorner