Class: SuperGood::SolidusTaxjar::DiscountCalculator
- Inherits:
-
Object
- Object
- SuperGood::SolidusTaxjar::DiscountCalculator
- Defined in:
- lib/super_good/solidus_taxjar/discount_calculator.rb
Instance Method Summary collapse
- #discount ⇒ Object
-
#initialize(line_item) ⇒ DiscountCalculator
constructor
A new instance of DiscountCalculator.
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
#discount ⇒ Object
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 |