diff options
author | Jared Norman <jared@super.gd> | 2019-01-24 17:58:39 -0800 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-01-28 10:35:05 -0800 |
commit | 462aa5b334c44e7cef9536ebf0db2e98875031da (patch) | |
tree | 0dbf3f321f95936ad928edfeb3133588d29d56df /lib/super_good/solidus_taxjar.rb | |
parent | c9633203f85fc690ec0213aca4da7198dcd43f16 (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/solidus_taxjar.rb')
-rw-r--r-- | lib/super_good/solidus_taxjar.rb | 14 |
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" |