summaryrefslogtreecommitdiff
path: root/lib/super_good
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-24 17:58:39 -0800
committerJared Norman <jared@super.gd>2019-01-28 10:35:05 -0800
commit462aa5b334c44e7cef9536ebf0db2e98875031da (patch)
tree0dbf3f321f95936ad928edfeb3133588d29d56df /lib/super_good
parentc9633203f85fc690ec0213aca4da7198dcd43f16 (diff)
Add configuration for discount calculator
This allows stores to specify their own discount calculator in an initializer, by doing something like the following: SuperGood::SolidusTaxJar.discount_calculator = MyStore::CustomDiscountCalculator The class's constructor should take in a line item and have a #discount method that returns the discount amount (which should be a negative number.)
Diffstat (limited to 'lib/super_good')
-rw-r--r--lib/super_good/solidus_taxjar.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb
index 40df3ec..f525ee7 100644
--- a/lib/super_good/solidus_taxjar.rb
+++ b/lib/super_good/solidus_taxjar.rb
@@ -2,11 +2,17 @@ require 'solidus_core'
require 'solidus_support'
require 'taxjar'
+require "super_good/solidus_taxjar/version"
+require "super_good/solidus_taxjar/api"
+require "super_good/solidus_taxjar/tax_calculator"
+require "super_good/solidus_taxjar/discount_calculator"
+
module SuperGood
module SolidusTaxJar
+ class << self
+ attr_accessor :discount_calculator
+ end
+
+ self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator
end
end
-
-require "super_good/solidus_taxjar/version"
-require "super_good/solidus_taxjar/api"
-require "super_good/solidus_taxjar/tax_calculator"