Class: Workarea::Pricing::Discount::InternationalItemProxy

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/pricing/discount/international_item_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order_item) ⇒ InternationalItemProxy

Returns a new instance of InternationalItemProxy.



8
9
10
# File 'app/models/workarea/pricing/discount/international_item_proxy.rb', line 8

def initialize(order_item)
  @order_item = order_item
end

Instance Attribute Details

#order_itemObject (readonly)

Returns the value of attribute order_item.



5
6
7
# File 'app/models/workarea/pricing/discount/international_item_proxy.rb', line 5

def order_item
  @order_item
end

Instance Method Details

#adjust_pricing(options = {}) ⇒ self

Adds an international price adjustment to the item. Does not persist.

Returns:

  • (self)


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

def adjust_pricing(options = {})
  international_price_adjustments.build(options)
end

#current_unit_priceObject



12
13
14
15
# File 'app/models/workarea/pricing/discount/international_item_proxy.rb', line 12

def current_unit_price
  return 0.to_m(order.currency) if international_price_adjustments.blank?
  international_price_adjustments.adjusting('item').map(&:unit).sum.to_m
end