From c9633203f85fc690ec0213aca4da7198dcd43f16 Mon Sep 17 00:00:00 2001 From: Jared Norman Date: Thu, 24 Jan 2019 17:57:06 -0800 Subject: 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. --- lib/super_good/solidus_taxjar/discount_calculator.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/super_good/solidus_taxjar/discount_calculator.rb (limited to 'lib/super_good/solidus_taxjar') 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 -- cgit v1.2.3