Class: SpreeCmCommissioner::PricingActions::CreateRouteAdjustments

Inherits:
SpreeCmCommissioner::PricingAction show all
Defined in:
app/models/spree_cm_commissioner/pricing_actions/create_route_adjustments.rb

Instance Method Summary collapse

Methods inherited from SpreeCmCommissioner::PricingAction

available_calculator_types, #compute_amount

Instance Method Details

#perform(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/spree_cm_commissioner/pricing_actions/create_route_adjustments.rb', line 4

def perform(options = {})
  order = options[:order]
  line_items = options[:line_items] || []

  return if pricing_rules.blank?
  return if line_items.blank?

  eligible_guests = collect_unique_eligible_guests(line_items)
  return if eligible_guests.empty?

  total_amount = compute_total_amount(order, eligible_guests)
  return if total_amount.zero?

  create_route_adjustment(order, total_amount)
end