Class: Inventory::QuotePlanningReminder

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

Overview

Service object: quote planning reminder.

Instance Method Summary collapse

Instance Method Details

#processObject



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

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 }
    emails[f.quote.primary_sales_rep] << record unless emails[f.quote.primary_sales_rep].include?(record)
  end
  emails.each do |rep, forecasts|
    SalesMailer.confirm_quote_planning(rep, forecasts).deliver_later
  end
  "E-mail reminders sent"
end