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

Are we supposed to transfer a ready shipment to another stock location? #1684

Closed
kooinam opened this issue Jan 16, 2017 · 4 comments
Closed

Comments

@kooinam
Copy link

kooinam commented Jan 16, 2017

The UI show that we are allowed to transfer a shipment in READY state to another stock location but InventoryUnit did had destroy validation that forbid destroying associated with shipment in READY state. Is that a bug?

line 135 in inventory_unit.rb

    def ensure_can_destroy
      if !backordered? && !on_hand?
        errors.add(:state, :cannot_destroy, state: state)
        throw :abort
      end

      unless shipment.pending?
        errors.add(:base, :cannot_destroy_shipment_state, state: shipment.state)
        throw :abort
      end
    end
@kennyadsl
Copy link
Member

This seems to be related to #97. Looking at transfer to location code, when we remove the line item from order contents it also destroys all line item inventory units. Specs are passing because it uses an order factory that has a pending shipment state and probably, using auto-captured payments, will automatically move shipments into ready state, making not possible to transfer an item into another stock location.

I think what we currently have is not the expected behavior, we should let users transfer content of a ready shipment into another stock location.

@kooinam
Copy link
Author

kooinam commented Jan 16, 2017

So is it safe to replace

unless shipment.pending?

to

if !shipment.pending? and !shipment.ready?

because the things is the UI is currently allowing transferring stock location for a shipment in READY state

@kennyadsl
Copy link
Member

Honestly, I'm not sure if we'll have unexpected side effects allowing to destroy inventory units of ready shipments. Probably it's better to wait for someone else opinion/comment.

@mamhoff
Copy link
Contributor

mamhoff commented Mar 18, 2017

We discussed this in core, and we think this is an oversight. The transfer_to_* methods on Spree::Shipment, however, do have a number of other strange side effects: If the price of your line item is somehow different from the variant's price, the new line item you obtain after doing a full split (fulfilling all inventory from another stock location) will the variant's default price.

Also, going through order.contents.{add, remove} makes this operation really slow for shipments with many inventory units.

mamhoff added a commit to mamhoff/solidus that referenced this issue Mar 18, 2017
Prior to this commit, this would not work because the destruction
of the original shipment would result in an exception being thrown.

Ready shipments can be edited and thus have to be able to be destroyed, too.

Fixes solidusio#1684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants