Class: EdiMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- EdiMailer
- Defined in:
- app/mailers/edi_mailer.rb
Overview
EDI partner / Mirakl notifications (admin + AR alerts, order pushes).
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
-
#amazon_seller_central_orders_notification(orders) ⇒ Mail::Message, ActionMailer::MessageDelivery
Amazon Seller Central variant of #edi_orders_notification.
-
#edi_orders_notification(orders, partner_name: nil) ⇒ Mail::Message, ActionMailer::MessageDelivery
Sends the "orders imported into Heatwave" digest for an EDI partner to the orders inbox (cc EDI admin).
-
#notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) ⇒ Mail::Message
Alerts accounts receivable that an EDI order hit the customer's credit limit.
-
#notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) ⇒ Mail::Message
Alerts accounts receivable that a receipt created from an EDI log needs manual attention.
-
#notify_edi_admin_of_edi_cancel(order, msg = nil) ⇒ Mail::Message
Alerts the EDI admin of an EDI order cancellation.
-
#notify_edi_admin_of_error(edi_communication_log, msg: nil) ⇒ Mail::Message
Alerts the EDI admin of a processing error tied to a communication log.
-
#notify_edi_admin_of_menard_inventory_error(error_message, item_count: 0) ⇒ Mail::Message
Alerts the EDI admin that a Menard inventory upload failed.
-
#notify_edi_admin_of_mirakl_error(partner, category, msg) ⇒ Mail::Message
Alerts the EDI admin of a Mirakl processing error.
-
#notify_edi_admin_of_order_status_mismatches(result) ⇒ Mail::Message
Alerts the EDI admin when Amazon order statuses diverge from Heatwave's.
-
#notify_edi_admin_of_warning(subj, msg) ⇒ Mail::Message
Sends a free-form processing warning to the EDI admin.
-
#notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) ⇒ Mail::Message
Sends Menard a pending-discontinue notice for a catalog item.
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#amazon_seller_central_orders_notification(orders) ⇒ Mail::Message, ActionMailer::MessageDelivery
Amazon Seller Central variant of #edi_orders_notification.
Amazon Seller Central is an EDI partner; this delegates to
+edi_orders_notification+ (same instance) and renders its template.
43 44 45 |
# File 'app/mailers/edi_mailer.rb', line 43 def amazon_seller_central_orders_notification(orders) edi_orders_notification(orders, partner_name: 'Amazon') end |
#edi_orders_notification(orders, partner_name: nil) ⇒ Mail::Message, ActionMailer::MessageDelivery
Sends the "orders imported into Heatwave" digest for an EDI partner to the
orders inbox (cc EDI admin).
Returns a no-op null delivery when +orders+ is blank so callers can fire
unconditionally after each order-flow run.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/mailers/edi_mailer.rb', line 20 def edi_orders_notification(orders, partner_name: nil) return null_mail if orders.blank? @orders = orders @partner_name = partner_name || Edi::PartnerNames.display_for(@orders.first&.edi_orchestrator_partner) subject = "#{@partner_name} Orders Imported into Heatwave: #{@orders.map(&:reference_number).join(', ')}" mail(from: 'Order Notifications <orders@warmlyyours.com>', to: 'orders@warmlyyours.com', cc: 'ediadmin@warmlyyours.com', subject: subject, template_name: 'edi_orders_notification') end |
#notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) ⇒ Mail::Message
Alerts accounts receivable that an EDI order hit the customer's credit limit.
105 106 107 108 109 110 111 |
# File 'app/mailers/edi_mailer.rb', line 105 def notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ar@warmlyyours.com' @edi_communication_log = edi_communication_log @msg = msg mail(from: sender, to: recipient, subject: "EDI Order Could Not Be Processed Due To Credit Limit #{@edi_communication_log.partner} #{@edi_communication_log.category}") end |
#notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) ⇒ Mail::Message
Alerts accounts receivable that a receipt created from an EDI log needs
manual attention.
161 162 163 164 165 166 167 168 |
# File 'app/mailers/edi_mailer.rb', line 161 def notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ar@warmlyyours.com' @receipt = receipt @customer = Customer.find(@receipt.customer_id) @msg = msg mail(from: sender, to: recipient, subject: "Manual attention required to Receipt #{@receipt.id}") end |
#notify_edi_admin_of_edi_cancel(order, msg = nil) ⇒ Mail::Message
Alerts the EDI admin of an EDI order cancellation.
118 119 120 121 122 123 124 |
# File 'app/mailers/edi_mailer.rb', line 118 def notify_edi_admin_of_edi_cancel(order, msg = nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @order = order @msg = msg mail(from: sender, to: recipient, subject: "EDI Order Cancellation #{order.reference_number}") end |
#notify_edi_admin_of_error(edi_communication_log, msg: nil) ⇒ Mail::Message
Alerts the EDI admin of a processing error tied to a communication log.
67 68 69 70 71 72 73 |
# File 'app/mailers/edi_mailer.rb', line 67 def notify_edi_admin_of_error(edi_communication_log, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @edi_communication_log = edi_communication_log @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Error #{@edi_communication_log.partner} #{@edi_communication_log.category}") end |
#notify_edi_admin_of_menard_inventory_error(error_message, item_count: 0) ⇒ Mail::Message
Alerts the EDI admin that a Menard inventory upload failed.
131 132 133 134 135 136 137 |
# File 'app/mailers/edi_mailer.rb', line 131 def notify_edi_admin_of_menard_inventory_error(, item_count: 0) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @error_message = @item_count = item_count mail(from: sender, to: recipient, subject: 'Menard Inventory Upload Failed') end |
#notify_edi_admin_of_mirakl_error(partner, category, msg) ⇒ Mail::Message
Alerts the EDI admin of a Mirakl processing error.
53 54 55 56 57 58 59 60 |
# File 'app/mailers/edi_mailer.rb', line 53 def notify_edi_admin_of_mirakl_error(partner, category, msg) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @partner = partner @category = category @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Error #{partner} #{category}") end |
#notify_edi_admin_of_order_status_mismatches(result) ⇒ Mail::Message
Alerts the EDI admin when Amazon order statuses diverge from Heatwave's.
80 81 82 83 84 85 86 |
# File 'app/mailers/edi_mailer.rb', line 80 def notify_edi_admin_of_order_status_mismatches(result) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @result = result mail(from: sender, to: recipient, subject: "Amazon Order Status Mismatch: #{result.partner} — #{result.mismatches.size} order(s)") end |
#notify_edi_admin_of_warning(subj, msg) ⇒ Mail::Message
Sends a free-form processing warning to the EDI admin.
93 94 95 96 97 98 |
# File 'app/mailers/edi_mailer.rb', line 93 def notify_edi_admin_of_warning(subj, msg) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Warning: #{subj}") end |
#notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) ⇒ Mail::Message
Sends Menard a pending-discontinue notice for a catalog item.
145 146 147 148 149 150 151 152 153 |
# File 'app/mailers/edi_mailer.rb', line 145 def notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) sender = 'ediadmin@warmlyyours.com' @catalog_item = catalog_item @item = catalog_item.store_item.item @discontinue_date = discontinue_date @parent_sku = catalog_item.parent_sku @model_number = catalog_item.third_party_sku.presence || @item.sku mail(from: sender, to: recipients, subject: "WarmlyYours — Pending Discontinue Notice for #{@model_number}") end |