diff options
author | Jared Norman <jared@super.gd> | 2019-01-24 17:57:06 -0800 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-01-28 10:35:05 -0800 |
commit | c9633203f85fc690ec0213aca4da7198dcd43f16 (patch) | |
tree | cb974be0ec61c1da8969bdb443e1cc5c35ecbd55 /lib | |
parent | 0eb33f99cd2054230c5a3ba80ab8d3633f16c04b (diff) |
Introduce DiscountCalculator
This extracts the functionality of calculating the discount for a line
item in the interest of making this behaviour configurable for stores
that would like to factor in order level adjustments in some way.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/super_good/solidus_taxjar/discount_calculator.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar/discount_calculator.rb b/lib/super_good/solidus_taxjar/discount_calculator.rb new file mode 100644 index 0000000..747a9d0 --- /dev/null +++ b/lib/super_good/solidus_taxjar/discount_calculator.rb @@ -0,0 +1,17 @@ +module SuperGood + module SolidusTaxJar + class DiscountCalculator + def initialize(line_item) + @line_item = line_item + end + + def discount + -line_item.promo_total + end + + private + + attr_reader :line_item + end + end +end |