`Spree::Shipment#item_cost` is wrong for split shipments
Open
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_costfor each of the shipments
Expected behavior
shipment.item_costshould be the total of the items included only in the given shipment
Actual behavior
shipment.item_costincludes 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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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