Class: InventoryMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- InventoryMailer
- Defined in:
- app/mailers/inventory_mailer.rb
Overview
Inventory / catalog: stock, reorder, cycle-count, price-change alerts.
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
-
#catalog_price_changes_alert(main_catalogs, other_catalogs) ⇒ Mail::Message
Daily digest of catalog price changes (WarmlyYours catalogs only).
-
#cycle_counts_due(store) ⇒ Mail::Message
Draft warehouse cycle counts that are due for the given store.
-
#empty_promised_date_reminder(po_items) ⇒ Mail::Message
Reminds AP of PO lines missing a promised date.
-
#inventory_adjustment_notification(item_ledger_entries) ⇒ Mail::Message
Alerts AP of inventory adjustments.
-
#inventory_commit_expiration_notification(resource) ⇒ Mail::Message
Notifies the sales rep that an inventory reservation has expired.
-
#inventory_reorder_reminder(records) ⇒ Mail::Message
Reminds AP of items that need replenishment.
-
#items_need_packaging_review_notification(item_ids) ⇒ Mail::Message
Asks the warehouses to review item weights/packaging.
-
#marketing_cycle_counts_due(store) ⇒ Mail::Message
Draft marketing-only cycle counts that are due for the given store.
-
#past_promised_date_reminder(store, po_items) ⇒ Mail::Message
Reminds AP and the warehouse of PO lines past their promised date.
-
#price_changed_alert(changes) ⇒ Mail::Message
Reports scheduled catalog-item price changes.
-
#promo_item_sync_notification(results) ⇒ Mail::Message
Reports coupon promo-item sync results.
-
#store_item_availability_timed_update(results, destination) ⇒ Mail::Message?
Availability-date changes for publications or other store items.
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#catalog_price_changes_alert(main_catalogs, other_catalogs) ⇒ Mail::Message
Daily digest of catalog price changes (WarmlyYours catalogs only).
154 155 156 157 158 159 160 161 |
# File 'app/mailers/inventory_mailer.rb', line 154 def catalog_price_changes_alert(main_catalogs, other_catalogs) @main_catalogs = main_catalogs @other_catalogs = other_catalogs mail(from: ADMINISTRATOR_EMAIL, to: 'pricechangealerts@warmlyyours.com', cc: 'heatwaveteam@warmlyyours.com', subject: 'Catalog Price Changes') end |
#cycle_counts_due(store) ⇒ Mail::Message
Draft warehouse cycle counts that are due for the given store.
36 37 38 39 40 41 42 |
# File 'app/mailers/inventory_mailer.rb', line 36 def cycle_counts_due(store) @cycle_counts = store.cycle_counts.where(state: 'draft', marketing_only: false) mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: store.id == 2 ? 'warehousecanada@warmlyyours.com' : 'warehouseusa@warmlyyours.com', subject: 'You Have Inventory Cycle Counts Due') end |
#empty_promised_date_reminder(po_items) ⇒ Mail::Message
Reminds AP of PO lines missing a promised date.
103 104 105 106 107 108 109 110 |
# File 'app/mailers/inventory_mailer.rb', line 103 def empty_promised_date_reminder(po_items) return null_mail if po_items.blank? @po_items = po_items.group_by(&:purchase_order) mail(from: "Accounts Payable <#{ACCOUNTS_PAYABLE_EMAIL}>", to: ACCOUNTS_PAYABLE_EMAIL, subject: 'POs With Empty Promised Date Found') end |
#inventory_adjustment_notification(item_ledger_entries) ⇒ Mail::Message
Alerts AP of inventory adjustments.
75 76 77 78 79 80 81 82 83 84 |
# File 'app/mailers/inventory_mailer.rb', line 75 def inventory_adjustment_notification(item_ledger_entries) item_ledger_entries = [item_ledger_entries].flatten.compact.uniq return null_mail if item_ledger_entries.blank? @item_ledger_entries = item_ledger_entries mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'ap@warmlyyours.com', subject: 'Inventory adjustment alert') end |
#inventory_commit_expiration_notification(resource) ⇒ Mail::Message
Notifies the sales rep that an inventory reservation has expired.
60 61 62 63 64 65 66 67 68 69 |
# File 'app/mailers/inventory_mailer.rb', line 60 def inventory_commit_expiration_notification(resource) @resource = resource @resource_class = resource.class.to_s @customer = @resource.customer @rep = @customer.primary_sales_rep mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @rep.present? ? @rep.email_with_name : 'orders@warmlyyours.com', subject: "#{@resource_class} #{@resource.reference_number} inventory reservation has expired") end |
#inventory_reorder_reminder(records) ⇒ Mail::Message
Reminds AP of items that need replenishment.
90 91 92 93 94 95 96 97 |
# File 'app/mailers/inventory_mailer.rb', line 90 def inventory_reorder_reminder(records) return null_mail if records.blank? @records = records mail(from: "Accounts Payable <#{ACCOUNTS_PAYABLE_EMAIL}>", to: ACCOUNTS_PAYABLE_EMAIL, subject: 'Stock Replenishment Reminder') end |
#items_need_packaging_review_notification(item_ids) ⇒ Mail::Message
Asks the warehouses to review item weights/packaging.
167 168 169 170 171 172 173 174 |
# File 'app/mailers/inventory_mailer.rb', line 167 def items_need_packaging_review_notification(item_ids) @items = Item.where(id: item_ids) return null_mail if @items.blank? mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'warehouseusa@warmlyyours.com, warehousecanada@warmlyyours.com', subject: 'Items that need weight review') end |
#marketing_cycle_counts_due(store) ⇒ Mail::Message
Draft marketing-only cycle counts that are due for the given store.
48 49 50 51 52 53 54 |
# File 'app/mailers/inventory_mailer.rb', line 48 def marketing_cycle_counts_due(store) @cycle_counts = store.cycle_counts.where(state: 'draft', marketing_only: true) mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: store.id == 2 ? 'warehousecanada@warmlyyours.com' : 'marketingcyclecounts@warmlyyours.com', subject: "You Have Marketing Inventory Cycle Counts Due For #{store.name}") end |
#past_promised_date_reminder(store, po_items) ⇒ Mail::Message
Reminds AP and the warehouse of PO lines past their promised date.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/mailers/inventory_mailer.rb', line 117 def past_promised_date_reminder(store, po_items) return null_mail if po_items.blank? @store = store @po_items = po_items.group_by(&:purchase_order) warehouse_email = if store.id == 1 'warehouseusa@warmlyyours.com' elsif store.id == 2 'warehousecanada@warmlyyours.com' end mail(from: "Accounts Payable <#{ACCOUNTS_PAYABLE_EMAIL}>", to: "#{ACCOUNTS_PAYABLE_EMAIL},#{warehouse_email}", subject: "POs Past Promised Date Found (#{store.name})") end |
#price_changed_alert(changes) ⇒ Mail::Message
Reports scheduled catalog-item price changes.
Called by CatalogItem::ScheduledPriceChanger.
139 140 141 142 143 144 145 146 147 |
# File 'app/mailers/inventory_mailer.rb', line 139 def price_changed_alert(changes) @changes = changes return null_mail if @changes.blank? mail(from: ADMINISTRATOR_EMAIL, to: 'price_alerts@warmlyyours.com', cc: 'heatwaveteam@warmlyyours.com', subject: 'Price Change Alert') end |
#promo_item_sync_notification(results) ⇒ Mail::Message
Reports coupon promo-item sync results.
180 181 182 183 184 185 186 187 |
# File 'app/mailers/inventory_mailer.rb', line 180 def promo_item_sync_notification(results) return null_mail if results.blank? @results = results mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'Heatwave Team <heatwaveteam@warmlyyours.com>', subject: "Promo Item Sync Results #{I18n.l(Date.current, format: :long)}") end |
#store_item_availability_timed_update(results, destination) ⇒ Mail::Message?
Availability-date changes for publications or other store items.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/mailers/inventory_mailer.rb', line 14 def store_item_availability_timed_update(results, destination) @results = results if destination == :publications @title = 'Publication Status Changes' mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'cwitbeck@warmlyyours.com,pgammeri@warmlyyours.com', cc: 'cbillen@warmlyyours.com', subject: 'Publication Availability Updates') elsif destination == :non_publications @title = 'Store Item Status Changes' mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'vadepu@warmlyyours.com', cc: 'cbillen@warmlyyours.com', subject: 'Store Item Availability Updates') end end |