Feat: Update stock quanitity when chocolate order is created#10
Feat: Update stock quanitity when chocolate order is created#10keshavgoel787 wants to merge 3 commits intomainfrom
Conversation
… to ensure it is working
This reverts commit 66efc70.
BeWelsh
left a comment
There was a problem hiding this comment.
@keshavgoel787 Good job! Just remember to request Jerome + myself upon opening a PR. We would like a little more testing (if order doesn't go through, check if stock remains the same). Make sure to read the comment below for other changes
Additionally, it is important to update docstrings! Sorry but this was slightly evil of me, since I didn't mention it explicilty in the ticket, but updating docstrings to reflect changes in functionality (in this case, service + router for create_order) is very important!
Overall great job - once you make these changes request another review!
| item_total = chocolate["price"] * item["quantity"] | ||
| total_price += item_total | ||
|
|
||
| chocolate["stock_quantity"] -= item["quantity"] |
There was a problem hiding this comment.
@keshavgoel787 There is a slight issue in subtracting from stock quantity while still iteratively checking if there is sufficient stock. Just to clarify, if an order is not valid (there is a specific chocolate with too little stock fulfill the order), the order will not be placed and all stock will remain the same. If you now notice the issue, add a new commit with the changes + a test covering the edge case.
Description
What does this PR do?
Updates chocolate db when valid order is created
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
Updated current order test to check if db is updated before and after changes
Checklist: