Class: SuperGood::SolidusTaxjar::DiscountCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/super_good/solidus_taxjar/discount_calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(line_item) ⇒ DiscountCalculator

Returns a new instance of DiscountCalculator.



4
5
6
# File 'lib/super_good/solidus_taxjar/discount_calculator.rb', line 4

def initialize(line_item)
  @line_item = line_item
end

Instance Method Details

#discountObject



8
9
10
# File 'lib/super_good/solidus_taxjar/discount_calculator.rb', line 8

def discount
  -1 * line_item.adjustments.select { |value| !value.tax? && value.eligible? }.sum(&:amount)
end