Class: WorkforceMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- WorkforceMailer
- Defined in:
- app/mailers/workforce_mailer.rb
Overview
HR: time-off, work-schedule, PTO, survey, and calendar notifications.
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
- #company_holiday_collision_notification(company_holiday, colliding_requests) ⇒ Object
- #delete_timeoff_event(event) ⇒ Object
-
#event_morning_notification(employee_id, event_ids) ⇒ Object
Morning-of summary for marketing-calendar event authors.
- #google_calendar_reconnection_request(employee) ⇒ Object
- #new_time_off_request(time_off_request) ⇒ Object
- #new_work_schedule_request(work_schedule) ⇒ Object
- #new_work_schedule_state(work_schedule) ⇒ Object
- #pending_time_off_requests(requests) ⇒ Object
- #pending_work_schedules(work_schedules) ⇒ Object
- #presence_alert(employee_phone_status, report_type) ⇒ Object
- #pto_year_end_rollover(employee:, previous_year:, rollover_data:, non_accruing_leave: nil) ⇒ Object
- #request_approved(time_off_request, approved_by: nil) ⇒ Object
- #request_cancelled(time_off_request, cancelled_by: nil) ⇒ Object
- #request_denied(time_off_request, denied_by: nil) ⇒ Object
- #review_budgets_alert(event) ⇒ Object
- #survey_admin_check(survey_enrollment) ⇒ Object
- #survey_employee_notification(survey_enrollment) ⇒ Object
- #time_off_attempt(employee, date) ⇒ Object
- #time_off_request(event) ⇒ Object
-
#time_off_request_amount_mismatch(details) ⇒ Object
Alerts the team when a time off request has an amount mismatch This typically indicates a JavaScript race condition in the form submission.
- #time_off_update_alert(time_off) ⇒ Object
- #work_schedule_update_alert(work_schedule) ⇒ Object
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#company_holiday_collision_notification(company_holiday, colliding_requests) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 |
# File 'app/mailers/workforce_mailer.rb', line 202 def company_holiday_collision_notification(company_holiday, colliding_requests) @company_holiday = company_holiday @colliding_requests = colliding_requests @company = company_holiday.company mail( from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'heatwaveteam@warmlyyours.com;vadepu@warmlyyours.com', subject: "Company Holiday Created: Time Off Requests Need Review (#{@company_holiday.holiday_name})" ) end |
#delete_timeoff_event(event) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'app/mailers/workforce_mailer.rb', line 54 def delete_timeoff_event(event) @event = event @employee = @event.employee @time_off = @employee.employee_time_offs.where(year: @event.date.year).last mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.employee_events_email_settings.map { |es| Employee.find(es.receiver_id).email unless es.receiver_id.nil? }.join(';').to_s, cc: "#{Employee.find(@event.employee_id).email};vadepu@warmlyyours.com", subject: "DELETED #{@event.status.humanize} request for #{Employee.find(@event.employee_id).full_name}") end |
#event_morning_notification(employee_id, event_ids) ⇒ Object
Morning-of summary for marketing-calendar event authors. Receives IDs
(not records) so the ActiveJob payload stays trivially serializable.
Caller (EventMorningNotificationWorker) has already filtered to events
whose "today" is today in the event's own time zone.
233 234 235 236 237 238 239 240 241 242 |
# File 'app/mailers/workforce_mailer.rb', line 233 def event_morning_notification(employee_id, event_ids) @employee = Employee.find_by(id: employee_id) @events = Event.where(id: event_ids).order(:start_time) return if @employee.blank? || @employee.email.blank? || @events.empty? subject = "Today on the marketing calendar — #{@events.size} #{@events.size == 1 ? 'event' : 'events'}" mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.email.to_s, subject: subject) end |
#google_calendar_reconnection_request(employee) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'app/mailers/workforce_mailer.rb', line 168 def google_calendar_reconnection_request(employee) @employee = employee @reconnect_url = Rails.application.routes.url_helpers.user_time_off_url( @employee, host: CRM_HOSTNAME, protocol: 'https' ) mail( to: @employee.email, subject: 'Action Required: Reconnect Your Google Calendar' ) end |
#new_time_off_request(time_off_request) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'app/mailers/workforce_mailer.rb', line 131 def new_time_off_request(time_off_request) @time_off_request = time_off_request @employee = @time_off_request.employee notification_recipients = @time_off_request.notification_recipients.join(';') @employee_email = @employee.email mail( to: notification_recipients, cc: @employee_email.to_s, subject: "New Time Off Request: #{@time_off_request.employee.name}" ) end |
#new_work_schedule_request(work_schedule) ⇒ Object
101 102 103 104 105 106 107 |
# File 'app/mailers/workforce_mailer.rb', line 101 def new_work_schedule_request(work_schedule) @employee = work_schedule.employee @work_schedule = work_schedule mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.manager.email, subject: "New Work Schedule pending Approval for #{@employee.full_name}") end |
#new_work_schedule_state(work_schedule) ⇒ Object
109 110 111 112 113 114 115 |
# File 'app/mailers/workforce_mailer.rb', line 109 def new_work_schedule_state(work_schedule) @employee = work_schedule.employee @work_schedule = work_schedule mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.email, subject: "Your Work Schedule has been #{@work_schedule.state.titleize}") end |
#pending_time_off_requests(requests) ⇒ Object
124 125 126 127 128 129 |
# File 'app/mailers/workforce_mailer.rb', line 124 def pending_time_off_requests(requests) @pending_time_off_requests = requests mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'epasek@warmlyyours.com;mgodawa@warmlyyours.com;srosenbaum@warmlyyours.com', subject: 'Time Off Requests Pending Approval') end |
#pending_work_schedules(work_schedules) ⇒ Object
117 118 119 120 121 122 |
# File 'app/mailers/workforce_mailer.rb', line 117 def pending_work_schedules(work_schedules) @pending_schedules = work_schedules mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'epasek@warmlyyours.com;mgodawa@warmlyyours.com;srosenbaum@warmlyyours.com;vadepu@warmlyyours.com', subject: 'Work Schedules Pending Approval') end |
#presence_alert(employee_phone_status, report_type) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/mailers/workforce_mailer.rb', line 12 def presence_alert(employee_phone_status, report_type) # epasek srosenbaum jcauley when ready recipients = ['callcenter_managers@warmlyyours.com'] if (employee_email = employee_phone_status.employee.email.presence) recipients << employee_email end @employee_phone_status = employee_phone_status @report_type = report_type mail( from: 'Call Center Managers <callcenter_managers@warmlyyours.com>', to: recipients.join(';'), subject: "Presence Alert for #{@employee_phone_status.employee.full_name}" ) end |
#pto_year_end_rollover(employee:, previous_year:, rollover_data:, non_accruing_leave: nil) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'app/mailers/workforce_mailer.rb', line 214 def pto_year_end_rollover(employee:, previous_year:, rollover_data:, non_accruing_leave: nil) @employee = employee @previous_year = previous_year @new_year = previous_year + 1 @data = rollover_data @non_accruing_leave = non_accruing_leave || [] return if @employee.email.blank? mail( to: @employee.email, subject: "🎉 Your #{@previous_year} PTO Summary & #{@new_year} Rollover" ) end |
#request_approved(time_off_request, approved_by: nil) ⇒ Object
144 145 146 147 148 149 150 |
# File 'app/mailers/workforce_mailer.rb', line 144 def request_approved(time_off_request, approved_by: nil) @time_off_request = time_off_request @employee = time_off_request.employee @approved_by = approved_by notification_recipients = @time_off_request.notification_recipients.join(';') mail(to: @employee.email, cc: notification_recipients, subject: 'Your Time Off Request Has Been Approved') end |
#request_cancelled(time_off_request, cancelled_by: nil) ⇒ Object
160 161 162 163 164 165 166 |
# File 'app/mailers/workforce_mailer.rb', line 160 def request_cancelled(time_off_request, cancelled_by: nil) @time_off_request = time_off_request @employee = time_off_request.employee @cancelled_by = cancelled_by notification_recipients = @time_off_request.notification_recipients.join(';') mail(to: @employee.email, cc: notification_recipients, subject: 'Your Time Off Request Has Been Cancelled') end |
#request_denied(time_off_request, denied_by: nil) ⇒ Object
152 153 154 155 156 157 158 |
# File 'app/mailers/workforce_mailer.rb', line 152 def request_denied(time_off_request, denied_by: nil) @time_off_request = time_off_request @employee = time_off_request.employee @denied_by = denied_by notification_recipients = @time_off_request.notification_recipients.join(';') mail(to: @employee.email, cc: notification_recipients, subject: 'Your Time Off Request Has Been Denied') end |
#review_budgets_alert(event) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'app/mailers/workforce_mailer.rb', line 83 def review_budgets_alert(event) @event = event @employee = @event.employee @time_off = @employee.employee_time_offs.where(year: @event.date.year).last mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'vadepu@warmlyyours.com', cc: (Employee.find(@employee.parent_id).email == 'jbillen@warmlyyours.com' ? @employee.email : Employee.find(@employee.parent_id).email).to_s, subject: "Alert: Review Budgets for #{@employee.full_name}") end |
#survey_admin_check(survey_enrollment) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/mailers/workforce_mailer.rb', line 27 def survey_admin_check(survey_enrollment) @survey_enrollment = survey_enrollment @survey = @survey_enrollment.survey mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'product_reviews@warmlyyours.com;jniemiec@warmlyyours.com', subject: "New Survey completed - #{@survey.name} - #{@survey_enrollment.id}") end |
#survey_employee_notification(survey_enrollment) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/mailers/workforce_mailer.rb', line 35 def survey_employee_notification(survey_enrollment) @survey_enrollment = survey_enrollment @employee = @survey_enrollment.employee @survey = @survey_enrollment.survey mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.email, subject: "You have been tagged in a new survey - #{@survey_enrollment.id}") end |
#time_off_attempt(employee, date) ⇒ Object
93 94 95 96 97 98 99 |
# File 'app/mailers/workforce_mailer.rb', line 93 def time_off_attempt(employee, date) @employee = Employee.find(employee) @date = date mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: (Employee.find(@employee.parent_id).email == 'jbillen@warmlyyours.com' ? @employee.email : Employee.find(@employee.parent_id).email).to_s, subject: "Time Off attempt on a blocked day from #{@employee.full_name}") end |
#time_off_request(event) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/mailers/workforce_mailer.rb', line 44 def time_off_request(event) @event = event @employee = @event.employee @time_off = @employee.employee_time_offs.where(year: @event.date.year).last mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.employee_events_email_settings.map { |es| Employee.find(es.receiver_id).email unless es.receiver_id.nil? }.join(';').to_s, cc: "#{Employee.find(@event.employee_id).email};vadepu@warmlyyours.com", subject: "New #{@event.status.humanize} request for #{Employee.find(@event.employee_id).full_name}") end |
#time_off_request_amount_mismatch(details) ⇒ Object
Alerts the team when a time off request has an amount mismatch
This typically indicates a JavaScript race condition in the form submission
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'app/mailers/workforce_mailer.rb', line 183 def time_off_request_amount_mismatch(details) @details = details @employee_name = details[:employee_name] || "Employee ##{details[:employee_id]}" @time_off_type = details[:time_off_type] || 'Unknown' @submitted_amount = details[:submitted_amount] @calculated_amount = details[:calculated_amount] @date_details = details[:date_details] || [] @is_new_record = details[:is_new_record] @start_date = details[:start_date] @end_date = details[:end_date] @notes = details[:notes] mail( from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'heatwaveteam@warmlyyours.com', subject: "Time Off Request Amount Mismatch - #{@employee_name} (#{@submitted_amount} vs #{@calculated_amount} hours)" ) end |
#time_off_update_alert(time_off) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/mailers/workforce_mailer.rb', line 74 def time_off_update_alert(time_off) @time_off = time_off @employee = @time_off.employee mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: (Employee.find(@employee.parent_id).email == 'jbillen@warmlyyours.com' ? @employee.email : Employee.find(@employee.parent_id).email).to_s, cc: @employee.email.to_s, subject: "Time Off budgets update for #{@employee.full_name}") end |
#work_schedule_update_alert(work_schedule) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'app/mailers/workforce_mailer.rb', line 64 def work_schedule_update_alert(work_schedule) @work_schedule = work_schedule @employee = @work_schedule.employee @time_off = @work_schedule.employee.employee_time_offs.where(year: Time.current.year).last mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: (Employee.find(@employee.parent_id).email == 'jbillen@warmlyyours.com' ? @employee.email : Employee.find(@employee.parent_id).email).to_s, cc: @employee.email.to_s, subject: "Work Schedule update for #{@employee.full_name}") end |