Class: Pricing::DiscountLevelChangedHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Pricing::DiscountLevelChangedHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/pricing/discount_level_changed_handler.rb
Overview
Pub/sub subscriber: discount level changed handler.
Constant Summary collapse
- OPEN_QUOTE_STATES_EXCLUDED =
Open quote states excluded.
%w[complete cancelled].freeze
- OPEN_ORDER_STATES =
Recognised open order states.
%w[cart pending pending_payment in_cr_hold].freeze
- REPRICEABLE_ORDER_TYPES =
Recognised repriceable order types.
[Order::SALES_ORDER, Order::MARKETING_ORDER, Order::TECH_ORDER].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call_for(customer) ⇒ Object
28 29 30 |
# File 'app/subscribers/pricing/discount_level_changed_handler.rb', line 28 def self.call_for(customer) new.process(customer) end |
Instance Method Details
#perform(event) ⇒ Object
32 33 34 35 36 37 |
# File 'app/subscribers/pricing/discount_level_changed_handler.rb', line 32 def perform(event) customer = Customer.find_by(id: event.data[:customer_id]) return unless customer process(customer) end |
#process(customer) ⇒ Object
39 40 41 42 43 44 |
# File 'app/subscribers/pricing/discount_level_changed_handler.rb', line 39 def process(customer) Rails.logger.info "Customer #{customer.id} -- Discount change detected, propagating" open_itemizables(customer).each do |itemizable| ItemizableDiscountResetWorker.perform_async(itemizable.class.name, itemizable.id) end end |