mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #4911 from luisramos0/3-0-manifest
[Spree 2.1] Change Shipment#manifest to include deleted variants (again, this time in rails 4)
This commit is contained in:
@@ -15,13 +15,14 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
# The shipment manifest is built by loading inventory units and variants from the DB
|
||||
# These variants come unscoped
|
||||
# So, we need to scope the variants just after the manifest is built
|
||||
def manifest_with_scoping
|
||||
manifest_without_scoping.each { |item| scoper.scope(item.variant) }
|
||||
def manifest
|
||||
inventory_units.group_by(&:variant).map do |variant, units|
|
||||
states = {}
|
||||
units.group_by(&:state).each { |state, iu| states[state] = iu.count }
|
||||
scoper.scope(variant)
|
||||
OpenStruct.new(variant: variant, quantity: units.length, states: states)
|
||||
end
|
||||
end
|
||||
alias_method_chain :manifest, :scoping
|
||||
|
||||
def scoper
|
||||
@scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
|
||||
|
||||
Reference in New Issue
Block a user