Class: SolidusFriendlyPromotions::Benefits::AdjustLineItemQuantityGroups::Item

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb

Overview

Used specifically for PercentOnLineItem calculator. That calculator uses ‘line_item.amount`, however we might not necessarily want to discount the entire amount. This class allows us to determine the discount per quantity and then calculate the adjustment amount the way we normally do for flat rate adjustments.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_item) ⇒ Item

Returns a new instance of Item.



89
90
91
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 89

def initialize(line_item)
  @line_item = line_item
end

Instance Attribute Details

#line_itemObject (readonly)

Returns the value of attribute line_item.



88
89
90
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 88

def line_item
  @line_item
end

Instance Method Details

#currencyObject



102
103
104
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 102

def currency
  @line_item.currency
end

#discountable_amountObject Also known as: amount



93
94
95
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 93

def discountable_amount
  @line_item.discountable_amount / @line_item.quantity.to_d
end

#orderObject



98
99
100
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 98

def order
  @line_item.order
end