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

Fix issue 3164 - generate shipments for backend-added products when necessary #3197

Merged
merged 4 commits into from
Mar 12, 2020

Conversation

spaghetticode
Copy link
Member

@spaghetticode spaghetticode commented May 3, 2019

Description

This PR fixes issue #3164. See the issue for further details.

An error occurs when trying to add a product to an existing completed order in the backend and the product stock is not compatible with existing shipments.

This PR adds the ability, when necessary, to generate new shipments also when the order is completed.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change (if needed)

core/app/models/spree/order_inventory.rb Outdated Show resolved Hide resolved
core/app/models/spree/order.rb Outdated Show resolved Hide resolved
@spaghetticode spaghetticode changed the title Spaghetticode/fix issues 3164 Fix issue 3164 - generate shipments for backened-added products when necessary May 3, 2019
@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch from 4e8dbaa to 50c78cd Compare May 3, 2019 12:15
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @spaghetticode, great work. I just left some comments about things that maybe can be improved or questions, let me know your thoughts!

core/app/models/spree/order_inventory.rb Show resolved Hide resolved
core/app/models/spree/order_inventory.rb Outdated Show resolved Hide resolved
@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch from 50c78cd to 97a4c95 Compare May 6, 2019 08:18
@spaghetticode spaghetticode changed the title Fix issue 3164 - generate shipments for backened-added products when necessary Fix issue 3164 - generate shipments for backend-added products when necessary May 6, 2019
@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch 4 times, most recently from 111caef to eb4bd35 Compare May 7, 2019 14:23
@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch 4 times, most recently from d606968 to 135510f Compare May 9, 2019 15:43
kennyadsl
kennyadsl previously approved these changes May 9, 2019
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks, @spaghetticode!

@kennyadsl kennyadsl added the WIP label May 9, 2019
@kennyadsl kennyadsl dismissed their stale review May 9, 2019 20:49

Still not ready

@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch 2 times, most recently from d606968 to 98cedb1 Compare May 10, 2019 08:20
@kennyadsl kennyadsl removed the WIP label May 10, 2019
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work as usual @spaghetticode!

The new method builds missing inventory units for the specified line
item.

inventory_unit_builder
Sometimes necessity arises to create shipments for an order that is already
completed, for example when adding an item in the backend using the `Cart` tab.

The existing method `#create_proposed_shipments` cannot be used, as the order
is completed, so this new method creates only the missing shipments for the
newly added line item.
…t_shipment

As sometimes availability matters, it's better to choose an existing shipment
that leaves from a stock location that has enough availability for the chosen
variant, facilitating warehouse management.
When OrderInventory#determine_target_shipment cannot find a suitable shipment
that can accommodate the added variant, then it's necessary to create at least
one new shipment for that purpose.

This is done by leveraging Order#create_shipments_for_line_item, which creates
missing shipments for the newly added items.
@spaghetticode spaghetticode force-pushed the spaghetticode/fix-issues-3164 branch from 98cedb1 to 3847475 Compare March 6, 2020 13:14
Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@spaghetticode spaghetticode merged commit dd62a3b into solidusio:master Mar 12, 2020
@spaghetticode spaghetticode deleted the spaghetticode/fix-issues-3164 branch March 12, 2020 14:31
stem added a commit to stem/solidus_product_assembly that referenced this pull request Apr 18, 2020
solidusio/solidus#3197 add a mandatory parameter which we should send
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

Successfully merging this pull request may close these issues.

5 participants