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

V2 - Shipping 2 out of 3 items for the same order line doesn't transition the order to PartiallyShipped #2191

Closed
martijnvdbrug opened this issue May 23, 2023 · 0 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@martijnvdbrug
Copy link
Collaborator

martijnvdbrug commented May 23, 2023

Describe the bug
In one of our plugins, we partially fulfill and ship order items, but Vendure throws (not return as ErrorResult) an ORDER_STATE_TRANSITION_ERROR when we ship 2 of 3 items of the same order line. The issue is also reproducable via the Admin UI.

To Reproduce

  1. Create a settled order with 1 variant (thus 1 order line) with quantity 3
  2. Create a fulfillment via the Admin UI with quantity 2. This creates a fulfillment in state Pending
  3. Click on mark as shipped on the fulfillment
  4. An ORDER_STATE_TRANSITION_ERROR will be thrown, the order will stay in PaymentSettled and the fulfillment will stay in Pending

Expected behavior

  1. The fulfillment should transition to Shipped
  2. The order should transition to PartiallyShipped

Environment (please complete the following information):

  • @vendure/core version: 2.0.0-beta.2
  • Nodejs version 16
  • Database (mysql/postgres etc): SQLite

Additional context

The order doesn't transition to PartiallyShipped here, because the function orderItemsArePartiallyShipped returns false. That is because the function getOrderLineFulfilmentStates only returns the states when the fulfillment quantity is equal to the orderLine quantity, which in this case is never: only 2 out of 3 of the same orderline are fulfilled

Shouldn't it be something like this?

// https://github.com/vendure-ecommerce/vendure/blob/major/packages/core/src/service/helpers/utils/order-utils.ts#L68

- if (totalFulfilled === line.quantity) {
+ if (totalFulfilled > 0) {
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