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

Change inventory unit state to "canceled" when order canceled #3719

Open
mdamian322 opened this issue Jul 23, 2020 · 3 comments
Open

Change inventory unit state to "canceled" when order canceled #3719

mdamian322 opened this issue Jul 23, 2020 · 3 comments
Labels
type:bug Error, flaw or fault

Comments

@mdamian322
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When I cancel and order, the inventory units remain on_hand

# Canceled order
order.inventory_units.pluck(:state) => ["on_hand"]

Steps to recreate

  • Create an order and complete it
  • Cancel the order by clicking the "Cancel" button
  • Notice that the order state is canceled, the shipment state it canceled, but the inventory units states remain on_hand (see screenshot below)

Describe the solution you'd like

When I cancel an order, the inventory units state should also change to canceled

# Desired return for canceled order
order.inventory_units.pluck(:state) => ["canceled"]`

Describe alternatives you've considered

Additional context

The issue we've specifically had has been with our warehouse system. The inventory units have to be canceled so our CSRs have to cancel and order, and cancel all the items under the "Cancel Items" tab. But it does seem strange that when you cancel an order the inventory units are not also canceled. We set the shipment state to cancelled so I would assume we do the same for the inventory units.
cancelled-order

@kennyadsl
Copy link
Member

I think it's a good concern and before an in-depth investigation about why is currently this way, I think you are right: we should cancel (and restock?) inventory units when the order is canceled.

@stefano-sarioli
Copy link
Contributor

stefano-sarioli commented Sep 23, 2020

I've investigated this issue a bit, here are my findings:

  • The stocks' level after an order cancelation is maintained thanks to the Spree::ShippingManifest. When a Spree::Shipment is canceled it use the ShippingManifest to restock the items.
  • If an order is resumed, after it was canceled, the Shipment will take care to re-update the stocks' level correctly, using the Manifest as a source of truth.
  • In this process, the shipment's inventory_units stay untouched.

We can probably update the inventory_units state when we change the state of the Shipment.
Is possible that there are some corner cases when we resume an order that I'm not able to catch.

I can try to open a PR to see how the code would look like, and if we catch some corner cases with the tests.

What do you think @kennyadsl?

@kennyadsl
Copy link
Member

Sure, go ahead. Thank you @stefano-sarioli!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants