Class: Inventory::QuotePlanningReminder

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/inventory/quote_planning_reminder.rb

Instance Method Summary collapse

Instance Method Details

#processObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/inventory/quote_planning_reminder.rb', line 3

def process
  forecasts = ItemDemandForecastAddition.where('quote_id is not null and date >= ?', Date.current).includes(:quote => :primary_sales_rep)
  emails = {}
  forecasts.each do |f|
    emails[f.quote.primary_sales_rep] ||= []
    record = {quote: f.quote, date: f.date}
    unless emails[f.quote.primary_sales_rep].include?(record)
      emails[f.quote.primary_sales_rep] << record
    end
  end
  emails.each do |rep, forecasts|
    InternalMailer.confirm_quote_planning(rep, forecasts).deliver_later
  end
  return "E-mail reminders sent"
end