Class: FinancialsMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- FinancialsMailer
- Defined in:
- app/mailers/financials_mailer.rb
Overview
Credit, AR, checks, invoices, and tax-exemption notifications.
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
- #auto_credit_increase_notification(customer, requested_amount, order = nil) ⇒ Object
- #checks_approved_notification(payments) ⇒ Object
- #checks_pending_review_notification(payments) ⇒ Object
- #checks_ready_to_print_notification(payments) ⇒ Object
- #credit_increase_request(customer, requested_amount, reasons, order = nil) ⇒ Object
- #credit_limit_verification_denied_notification(customer, requested_amount, fail_reasons, quote = nil) ⇒ Object
- #credit_request_approved_notification(customer, requested_amount, order = nil) ⇒ Object
- #credit_request_denied_notification(customer, requested_amount, order = nil) ⇒ Object
- #daily_unprinted_checks_digest(payments) ⇒ Object
- #new_credit_application(credit_application) ⇒ Object
- #tax_exemption_expired(tax_exemption) ⇒ Object
- #tax_exemption_uploaded(tax_exemption) ⇒ Object
- #unpaid_invoices(invoices) ⇒ Object
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#auto_credit_increase_notification(customer, requested_amount, order = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/mailers/financials_mailer.rb', line 17 def auto_credit_increase_notification(customer, requested_amount, order = nil) @customer = customer @billing_entity = customer.billing_entity @rep = customer.primary_sales_rep @requested_amount = requested_amount @order = order mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>', to: 'ordernotifications@warmlyyours.com', subject: "Credit automatically increased for #{@customer.full_name}") end |
#checks_approved_notification(payments) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'app/mailers/financials_mailer.rb', line 110 def checks_approved_notification(payments) @payments = Array(payments) return null_mail if @payments.blank? subject = if @payments.size == 1 payment = @payments.first "Check Approved: #{payment.reference_number} - #{payment.supplier.full_name}" else "#{@payments.size} Checks Approved" end mail(from: "Accounts Payable <#{ACCOUNTS_PAYABLE_EMAIL}>", to: "#{ACCOUNTS_PAYABLE_EMAIL}, heidegw@warmlyyours.com", subject: subject) end |
#checks_pending_review_notification(payments) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'app/mailers/financials_mailer.rb', line 79 def checks_pending_review_notification(payments) return null_mail if payments.blank? @payments = payments mail(from: "Accounts Payable <#{ACCOUNTS_PAYABLE_EMAIL}>", to: 'Julia Billen <jbillen@warmlyyours.com>, Venu Adepu <vadepu@warmlyyours.com>', cc: ACCOUNTS_PAYABLE_EMAIL, subject: 'New Checks Need Approval') end |
#checks_ready_to_print_notification(payments) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'app/mailers/financials_mailer.rb', line 90 def checks_ready_to_print_notification(payments) return null_mail if payments.blank? @payments = payments mail(from: 'Accounts Payable <apchecks@warmlyyours.com>', to: 'apchecks@warmlyyours.com', subject: 'New Checks Are Ready To Print') end |
#credit_increase_request(customer, requested_amount, reasons, order = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/mailers/financials_mailer.rb', line 29 def credit_increase_request(customer, requested_amount, reasons, order = nil) @customer = customer @rep = customer.primary_sales_rep @requested_amount = requested_amount @order = order @reasons = reasons mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>', to: 'ordernotifications@warmlyyours.com', cc: @rep&.email_with_name, subject: "FAILED Credit increase request for #{@customer.full_name}") end |
#credit_limit_verification_denied_notification(customer, requested_amount, fail_reasons, quote = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/mailers/financials_mailer.rb', line 66 def credit_limit_verification_denied_notification(customer, requested_amount, fail_reasons, quote = nil) @customer = customer @rep = customer.primary_sales_rep @requested_amount = requested_amount @fail_reasons = fail_reasons @quote = quote mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>', to: @rep.present? ? @rep.email_with_name : @customer.customer_service_manager.email_with_name, cc: 'ordernotifications@warmlyyours.com', subject: "Credit limit check for #{@customer.full_name}") end |
#credit_request_approved_notification(customer, requested_amount, order = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/mailers/financials_mailer.rb', line 42 def credit_request_approved_notification(customer, requested_amount, order = nil) @customer = customer @rep = customer.primary_sales_rep @requested_amount = requested_amount @order = order mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>', to: @rep.present? ? @rep.email_with_name : @customer.customer_service_manager.email_with_name, cc: 'ordernotifications@warmlyyours.com', subject: "APPROVED Credit increase request for #{@customer.full_name}") end |
#credit_request_denied_notification(customer, requested_amount, order = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/mailers/financials_mailer.rb', line 54 def credit_request_denied_notification(customer, requested_amount, order = nil) @customer = customer @rep = customer.primary_sales_rep @requested_amount = requested_amount @order = order mail(from: 'Order Notifications <ordernotifications@warmlyyours.com>', to: @rep.present? ? @rep.email_with_name : @customer.customer_service_manager.email_with_name, cc: 'ordernotifications@warmlyyours.com', subject: "Credit request for #{@customer.full_name} has been denied") end |
#daily_unprinted_checks_digest(payments) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'app/mailers/financials_mailer.rb', line 100 def daily_unprinted_checks_digest(payments) return null_mail if payments.blank? @payments = payments mail(from: 'Accounts Payable <apchecks@warmlyyours.com>', to: %w[heidegw@warmlyyours.com ap@warmlyyours.com], subject: "Daily Unprinted Checks Digest – #{@payments.size} pending") end |
#new_credit_application(credit_application) ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/mailers/financials_mailer.rb', line 9 def new_credit_application(credit_application) @credit_application = credit_application mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'ar@warmlyyours.com', subject: "New Credit Application Received #{@credit_application.reference_number}") end |
#tax_exemption_expired(tax_exemption) ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'app/mailers/financials_mailer.rb', line 137 def tax_exemption_expired(tax_exemption) @tax_exemption = tax_exemption @customer = @tax_exemption.customer @email = @tax_exemption.notify_emails mail(from: ADMINISTRATOR_EMAIL, to: @email, subject: "Tax Exemption expiring soon #{tax_exemption.id}") end |
#tax_exemption_uploaded(tax_exemption) ⇒ Object
126 127 128 129 130 131 132 133 134 135 |
# File 'app/mailers/financials_mailer.rb', line 126 def tax_exemption_uploaded(tax_exemption) @tax_exemption = tax_exemption @customer = @tax_exemption.customer @email = @tax_exemption.notify_emails @sales_rep_email = @customer.primary_sales_rep.try(:email) mail(from: ADMINISTRATOR_EMAIL, to: @email, cc: [@sales_rep_email, 'ar@warmlyyours.com'].compact.uniq.join(', '), subject: "New Tax Exemption card #{tax_exemption.id}") end |
#unpaid_invoices(invoices) ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'app/mailers/financials_mailer.rb', line 146 def unpaid_invoices(invoices) @invoices = invoices return null_mail if @invoices.blank? mail(from: ADMINISTRATOR_EMAIL, to: ACCOUNTS_RECEIVABLE_EMAIL, cc: 'vadepu@warmlyyours.com, rmatejacabello@warmlyyours.com', subject: "UNPAID INVOICES #{Date.current}") end |