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) ⇒ Object
- #cycle_counts_due(store) ⇒ Object
- #empty_promised_date_reminder(po_items) ⇒ Object
- #inventory_adjustment_notification(item_ledger_entries) ⇒ Object
- #inventory_commit_expiration_notification(resource) ⇒ Object
- #inventory_reorder_reminder(records) ⇒ Object
- #items_need_packaging_review_notification(item_ids) ⇒ Object
-
#low_stock_warning_advertised_products ⇒ Object
Sends a warning to digital marketing whenever stock is low on any product feed products to google.
- #marketing_cycle_counts_due(store) ⇒ Object
- #past_promised_date_reminder(store, po_items) ⇒ Object
-
#price_changed_alert(changes) ⇒ Object
CatalogItem::ScheduledPriceChanger will call this and report if any price changes occurred.
- #promo_item_sync_notification(results) ⇒ Object
- #store_item_availability_timed_update(results, destination) ⇒ Object
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#catalog_price_changes_alert(main_catalogs, other_catalogs) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'app/mailers/inventory_mailer.rb', line 122 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) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/mailers/inventory_mailer.rb', line 27 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) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/mailers/inventory_mailer.rb', line 74 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) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'app/mailers/inventory_mailer.rb', line 54 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) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'app/mailers/inventory_mailer.rb', line 43 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) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/mailers/inventory_mailer.rb', line 65 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) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'app/mailers/inventory_mailer.rb', line 131 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 |
#low_stock_warning_advertised_products ⇒ Object
Sends a warning to digital marketing whenever stock is low on any
product feed products to google
101 102 103 104 105 106 107 108 109 |
# File 'app/mailers/inventory_mailer.rb', line 101 def low_stock_warning_advertised_products @low_stock_items = Query::CatalogItemQuery.new.low_stock_for_google_feed return null_mail if @low_stock_items.blank? mail(from: 'Digital Marketing <digitalmarketing@warmlyyours.com>', to: 'Digital Marketing <digitalmarketing@warmlyyours.com>', subject: "Low stock alert for google merchant feed (#{@low_stock_items.size})") end |
#marketing_cycle_counts_due(store) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/mailers/inventory_mailer.rb', line 35 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) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/mailers/inventory_mailer.rb', line 83 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) ⇒ Object
CatalogItem::ScheduledPriceChanger will call this and report if any price changes occurred
112 113 114 115 116 117 118 119 120 |
# File 'app/mailers/inventory_mailer.rb', line 112 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) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'app/mailers/inventory_mailer.rb', line 140 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) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/mailers/inventory_mailer.rb', line 9 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 |