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

[2.0.5] addFulfillmentToOrder() allows exceeding OrderLine.quantity in AdminUI #2329

Closed
devtrylah opened this issue Aug 2, 2023 · 1 comment
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@devtrylah
Copy link

Describe the bug
In version 2.0.5, the addFulfillmentToOrder() function called from AdminUI can create a fulfillment with a quantity exceeding the initial order line quantity. This creates a fulfillmentLine in the database with an incorrect quantity (OrderLineInput.quantity > orderLine.quantity). This operation should throw an error, but it doesn't.

To Reproduce
Steps to reproduce the behavior:

  1. Carry out the following operations: addItemToOrder(), SetOrderShippingMethod(), transitionOrderToState(), addPaymentToOrder().
  2. Go to the newly placed order in the AdminUI. If necessary, 'Settle payment', then click on 'Fulfill order'.
  3. Input a quantity that is larger than the unfulfilled quantity. For instance, if the order line quantity is 2, input 3 in the fulfillment quantity. Fill 'Method' and 'Tracking code' with any string.
  4. Execute 'Create Fulfillment'. It will run successfully.
  5. Back in the order details page, the newly created fulfillment displays 3 units, despite the original order line quantity being 2. The 'Quantity' column for the order line will display 'No items fulfilled'.

Expected behavior
When a fulfillment is attempted with a quantity exceeding the original order line quantity, the system should throw an error.

Analysis
The OrderService.requestedFulfillmentQuantityExceedsLineQuantity() function seems to return false when it queries for linesToBeFulfilled and no matching records are found (e.g., for new order lines without preceding fulfillment lines). One potential fix could be to compare the requested fulfillment quantity with the original order line quantity in cases where no matching records are found in linesToBeFulfilled.

@devtrylah devtrylah added the type: bug 🐛 Something isn't working label Aug 2, 2023
@michaelbromley michaelbromley moved this to 📋 Backlog in Vendure OS Roadmap Aug 7, 2023
@michaelbromley michaelbromley moved this from 📋 Backlog to 🏗 In progress in Vendure OS Roadmap Aug 7, 2023
@michaelbromley
Copy link
Member

Thanks for the report & the suggestion - that was helpful! 👍

@michaelbromley michaelbromley moved this from 🏗 In progress to ✅ Done in Vendure OS Roadmap Aug 11, 2023
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
Status: 🚀 Shipped
Development

No branches or pull requests

2 participants