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:
Pau Pérez Fabregat
2020-03-12 12:47:45 +01:00
committed by GitHub

View File

@@ -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)