Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially Resolves #3557
Description
This is a partial fix for an issue is occurring dozens of times a week -- though I think most of those are frurstrated retries.
If there is no inventory item for a particular item when we attempt to complete a distribution, an exception is thrown, and the distribution does not complete (silently)
It turns out that we are deleting the inventory items when there is no current inventory. This has some other side effects (e.g. not seeing the inventory history)
To be discussed
Do we 1/ create new 0-quantity inventory items for the items that would have this problem (find by crawling the scheduled distributions), 2/ try somehow to connect back to existing history, or 3/ just let it ride?
I'm for option 1, I think -- option 2 is practically impossible, and option 3 will take some time to actually resolve.
NB*
This PR only fixes the base issue on a go-forward basis.
There are some side effects of having deleted the inventory items, though.
This solution does mean that if someone corrects a purchase back to 0, the inventory item will not be removed. I think that's fine -- Again, for reasons of keeping the history.
It also means that 0-quantity items will appear in the distribution drop downs. We could filter those out. I'm not sure how big a problem that will be perceived to be.
Type of change
How Has This Been Tested?