solidusio / solidusio/solidus

`Spree::Shipment#item_cost` is wrong for split shipments

Open
#2,919 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

changelog:solidus_core
Dominant language
Ruby
Stars
5.3k
Forks
1.4k
Avg merge
1d 22h
Merged PRs (30d)
62

Description

Steps to reproduce
  • Create an order with a line item that has a quantity > 1
  • Create a split shipment for that line item
  • Examine item_cost for each of the shipments
Expected behavior
  • shipment.item_cost should be the total of the items included only in the given shipment
Actual behavior
  • shipment.item_cost includes the entire cost of all line items associated with the shipment
System configuration

Solidus Version:

  • 2.6.0

Extensions in use:
n/a. This is solidus_core:

Notes

spree_shipments to spree_line_items is a many-to-many relationship via spree_inventory_units. Spree::Shipment#item_cost as written is only correct when there is a one (shipment) to many (line item) relationship:

https://github.com/solidusio/solidus/blob/853bc56249861803388eacfe2151b79ca8e125fa/core/app/models/spree/shipment.rb#L187-L189

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/app/models/spree/shipment.rb at the linked item_cost implementation, then inspect how shipments and line items are related through spree_inventory_units. Reproduce the split-shipment scenario from the issue and verify that each shipment's item_cost includes only the items assigned to that shipment.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.