PI refactoring

This commit is contained in:
Matt-Yorkley
2017-03-18 00:12:42 +00:00
parent e76a818fde
commit 6e2de0d6ac

View File

@@ -174,13 +174,12 @@ Spree::Product.class_eval do
order_cycle.variants_distributed_by(distributor).where(product_id: self)
end
# Get the most recent import_date of a product's variants
def import_date
# Get the most recent import_date of a product's variants
imports = []
variants.each do |v|
imports.append(v) unless v.import_date.blank?
end
imports.sort_by(&:import_date).last.try(:import_date)
variants.map do |variant|
next if variant.import_date.blank?
variant.import_date
end.sort.last
end
# Build a product distribution for each distributor