Found a bug in development that could have caused some confusion if it ever bubbled up to userland. I suspect the small and controlled scale of the application affected why this never showed up in production, but it should be dealt with nonetheless.
To reproduce:
Open a tab and add 2 copies of a card through manage inventory
Open another tab, go to make a new sale, and attempt to add the two cards to the sale list
Navigate back to tab 1 and remove the cards from inventory
Switch back to sales and click "finalize sale". The sale completes, despite those cards not being in inventory!
Usually step 4 is mitigated by the fact that employees physically pull cards to inspect them prior to sale. However, we perform this validation on sale suspension, so it naturally makes sense for us to do the same with proper sales.
In this PR, I've extracted the validation interactor that originally existed in createSuspendedSale, tested it, and integrated it into the finishSaleValidationController to stop sales in their tracks should it throw an error.
Note: Unsuspended sales are deleted entirely on submission, and inventory is restored prior to selling one, so they remain un-affected as inventory is reconciled properly.
Summary
Found a bug in development that could have caused some confusion if it ever bubbled up to userland. I suspect the small and controlled scale of the application affected why this never showed up in production, but it should be dealt with nonetheless.
To reproduce:
Usually step 4 is mitigated by the fact that employees physically pull cards to inspect them prior to sale. However, we perform this validation on sale suspension, so it naturally makes sense for us to do the same with proper sales.
In this PR, I've extracted the validation interactor that originally existed in
createSuspendedSale
, tested it, and integrated it into thefinishSaleValidationController
to stop sales in their tracks should it throw an error.Note: Unsuspended sales are deleted entirely on submission, and inventory is restored prior to selling one, so they remain un-affected as inventory is reconciled properly.