summaryrefslogtreecommitdiff
path: root/lib/super_good
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-24 17:57:06 -0800
committerJared Norman <jared@super.gd>2019-01-28 10:35:05 -0800
commitc9633203f85fc690ec0213aca4da7198dcd43f16 (patch)
treecb974be0ec61c1da8969bdb443e1cc5c35ecbd55 /lib/super_good
parent0eb33f99cd2054230c5a3ba80ab8d3633f16c04b (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/super_good')
-rw-r--r--lib/super_good/solidus_taxjar/discount_calculator.rb17
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