Class: OrdersMailer

Inherits:
InternalNotificationMailer show all
Defined in:
app/mailers/orders_mailer.rb

Overview

Order lifecycle: online/Amazon orders, profit review, payment auth.

Extracted from the former InternalMailer god object.

See Also:

  • InternalNotificationMailer
  • doc/tasks/202606131218_INTERNAL_MAILER_DECOMPOSITIONdoc/tasks/202606131218_INTERNAL_MAILER_DECOMPOSITION.md

Instance Method Summary collapse

Methods inherited from InternalNotificationMailer

#default_url_options

Methods included from SendgridSmtpApi::InternalMailerHeaders

#mail

Methods inherited from ApplicationMailer

#null_mail

Instance Method Details

#amazon_seller_central_fba_ci_invoices_notification(invoices) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/mailers/orders_mailer.rb', line 55

def amazon_seller_central_fba_ci_invoices_notification(invoices)
  return null_mail if invoices.blank?

  @invoices = invoices

  subject = "Amazon FBA Draft Invoices Created: #{@invoices.map(&:reference_number).join(', ')}"

  mail(from: 'Accounts Payable <ap@warmlyyours.com>',
       to: 'orders@warmlyyours.com, ap@warmlyyours.com',
       cc: 'ediadmin@warmlyyours.com',
       subject: subject)
end

#back_order_notification(order) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/mailers/orders_mailer.rb', line 9

def back_order_notification(order)
  @order = order
  @customer = @order.customer
  @rep = @order.customer.primary_sales_rep

  mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>',
       to: "#{ACCOUNTS_RECEIVABLE_EMAIL}, backorders@warmlyyours.com, ordernotifications@warmlyyours.com",
       cc: @rep&.email_with_name,
       subject: "Order #{@order.reference_number} went to back order state")
end

#online_order_notification(order) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/mailers/orders_mailer.rb', line 38

def online_order_notification(order)
  @order = order
  @customer = @order.customer
  @rep = @order.customer.primary_sales_rep

  subject = if @order.in_cr_hold? || @order.pending_release_authorization? || @order.in_management_hold?
              "Online Order On Hold #{@order.reference_number}"
            else
              "Online Order Confirmation #{@order.reference_number}"
            end

  mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>',
       to: 'ordernotifications@warmlyyours.com',
       cc: @rep&.email_with_name,
       subject: subject)
end

#order_profit_review_notification(order) ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/mailers/orders_mailer.rb', line 20

def order_profit_review_notification(order)
  @order = order
  @customer = @order.customer
  @rep = @customer.primary_sales_rep
  mail(from: 'Heatwave <salesmanagers@warmlyyours.com>',
       to: 'Sales Managers <salesmanagers@warmlyyours.com>, AR <ar@warmlyyours.com>',
       subject: "Order #{@order.reference_number} requires profit margin review")
end

#order_with_insuficient_payment(order) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'app/mailers/orders_mailer.rb', line 89

def order_with_insuficient_payment(order)
  @order = order
  @customer = @order.customer
  @rep = @order.customer.primary_sales_rep

  subject = "Order with pending balance #{@order.reference_number}"
  email_cc = 'orders@warmlyyours.com'
  email = @rep&.email_with_name
  email ||= @customer.customer_service_manager&.email_with_name
  if email.nil?
    email = 'orders@warmlyyours.com'
    email_cc = nil
  end

  mail(from: 'Orders <orders@warmlyyours.com>',
       to: email,
       cc: email_cc,
       subject: subject)
end

#payment_automatically_authorized(order) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'app/mailers/orders_mailer.rb', line 79

def payment_automatically_authorized(order)
  @order = order
  @customer = @order.customer
  @rep = @order.customer.primary_sales_rep

  mail(from: 'Orders <orders@warmlyyours.com>',
       to: 'orders@warmlyyours.com',
       subject: "Payment automatically authorized for #{@order.reference_number}")
end

#quote_profit_review_notification(quote) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/mailers/orders_mailer.rb', line 29

def quote_profit_review_notification(quote)
  @quote = quote
  @customer = @quote.customer
  @rep = @customer.primary_sales_rep
  mail(from: 'Heatwave <salesmanagers@warmlyyours.com>',
       to: 'Sales Managers <salesmanagers@warmlyyours.com>, AR <ar@warmlyyours.com>',
       subject: "Quote #{@quote.reference_number} requires profit margin review")
end

#release_authorization_required(order) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'app/mailers/orders_mailer.rb', line 68

def release_authorization_required(order)
  @order = order
  @customer = @order.customer
  @rep = @order.customer.primary_sales_rep

  mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>',
       to: 'ordernotifications@warmlyyours.com',
       cc: @rep&.email_with_name,
       subject: "Order #{@order.reference_number} needs release authorization")
end