Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stock and allocated are incorrectly updated due to multiple same orderline in one order #1028

Closed
simpian opened this issue Aug 11, 2021 · 0 comments · Fixed by #1029
Closed
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@simpian
Copy link
Contributor

simpian commented Aug 11, 2021

Describe the bug
A clear and concise description of what the bug is.

current apples in stock: 50
currently being allocated: 20
order

  1. apple x 10, delivery date 10/10/2021 (in memory product variant with allocated: 20)
  2. apple x 5, delivery date 10/12/2021 (in memory product variant with allocated: 20)

because apple are considered as two order items due to different delivery dates, however, they are the same product variant, current code will use the allocated number that is stored in memory to calculate new stock.

after the first loop:
the allocated number is 20 + 10 = 30 allocated,
however, the second loop will cause a bug because it is still using the old allocated number in memory to calculate new allocation: 20 + 5 = 25 instead of 30 + 5 = 35, the correct allocated number should be 20 + 10 + 5 = 35.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • @vendure/core version:
  • Nodejs version
  • Database (mysql/postgres etc):

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants