Before when a product was added to an order and subsequently went out of stock before submission, the system incorrectly showed a success message "Your order is being submitted" while leaving the order in draft status. Now it shows "Order can not be submitted! Product not available in requested quantity!".
I don't like my solution but I didn't know how to do it better. I see a few problems here:
There is no information which product is out stock, and it will be hard to get.
We assume that if order is not submitted then it is becasue of out of stock products. This assumption might not work in the future when e.g., an order is not submitted because it cannot be shipped to a certain location.
It feels weird to fetch a read model to check the result of a command
I didn't know how to do it better because the error InventoryNotAvailable" is rescued in the ReservationProcess event handler and I would have to delete a lot of code to rescue this error in the controller and show this flash, which I think would break the intended original design.
I'm happy to close this PR if it doesn't fit the architecture, no hard feelings 😄
Issue: https://github.com/RailsEventStore/ecommerce/issues/375
Before when a product was added to an order and subsequently went out of stock before submission, the system incorrectly showed a success message "Your order is being submitted" while leaving the order in draft status. Now it shows "Order can not be submitted! Product not available in requested quantity!".
I don't like my solution but I didn't know how to do it better. I see a few problems here:
I didn't know how to do it better because the error
InventoryNotAvailable"
is rescued in theReservationProcess
event handler and I would have to delete a lot of code to rescue this error in the controller and show this flash, which I think would break the intended original design.I'm happy to close this PR if it doesn't fit the architecture, no hard feelings 😄