21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/generators/price_log/templates/price_log_entry.rb', line 21
def resolve_dates
_all_ = PriceLogEntry.all_for_priceable(self.priceable_type, self.priceable_id, self.priceable_field_name)
prev_start_date = nil
self.logger.info "Recalculates #{self.priceable_type}, #{self.priceable_id}, #{self.priceable_field_name}"
_all_.order("start_date DESC").each do |ple|
unless prev_start_date.nil?
ple.end_date = prev_start_date
ple.save!
end
prev_start_date = ple.start_date
end
true
end
|