Class: Workarea::Pricing::Override

Inherits:
Object
  • Object
show all
Includes:
ApplicationDocument
Defined in:
app/models/workarea/pricing/override.rb

Instance Method Summary collapse

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list

Methods included from Mongoid::Document

#embedded_children

Instance Method Details

#adjusts_items?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'app/models/workarea/pricing/override.rb', line 25

def adjusts_items?
  item_prices.present? &&
    item_prices.values.reject(&:blank?).any?(&:present?)
end

#adjusts_shipping?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/workarea/pricing/override.rb', line 17

def adjusts_shipping?
  shipping_adjustment.present? && !shipping_adjustment.zero?
end

#adjusts_subtotal?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/workarea/pricing/override.rb', line 21

def adjusts_subtotal?
  subtotal_adjustment.present? && !subtotal_adjustment.zero?
end

#has_adjustments?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/workarea/pricing/override.rb', line 13

def has_adjustments?
  adjusts_shipping? || adjusts_subtotal? || adjusts_items?
end

#item_price_for_id(item_id) ⇒ Object



30
31
32
33
# File 'app/models/workarea/pricing/override.rb', line 30

def item_price_for_id(item_id)
  price = item_prices.fetch(item_id.to_s, nil)
  price.present? ? price.to_m : nil
end