super_good-solidus_taxjar 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e315fd76cef9f6fddba1b3202cda57b2e04d39
4
- data.tar.gz: 64708cb635e934536fdb2dcb37cb0f60a23c8df1
3
+ metadata.gz: 76b48f5239948da1f17684991f5c22f66f2f4326
4
+ data.tar.gz: 3ea032a3d4659ed75142bf9eb338da2985309164
5
5
  SHA512:
6
- metadata.gz: 1ad10edb29f0a302a1f3e2f9d4100814bbb0573895b1ff4ca10217283f24f2c6fa835711bd691d3719861f24a3c21376870364bbf99334d661ba8af62ef15f93
7
- data.tar.gz: 6c925bf6f337c91c294a5846a7afb7b43a17cc0c25a661e51cbdee66275de1e08cb0f9bcec772699b19676e4325d2a282ad6927716a438388cfb834cc6cc3dbf
6
+ metadata.gz: 554d571ac1eaf53f17cbb903ae3fd25efa2942dc23d77e9f6d07cdf18f637249732d73e0d5c859d614408eefd820a1d2f6bbd7aaebc4c4e99772ce612ce9ef8b
7
+ data.tar.gz: 6b72b4a99f1c7f68955ff07c8c45f1061209dd11e0300e322bd8101162a5fa240074a0e0f292824c68ce665f51e39da664d43cdc2c9544ca60540bc6c34b1b43
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## v0.5.0
4
+
5
+ - Moved exception handler configuration to `SuperGood::SolidusTaxJar.exception_handler` from `SuperGood::SolidusTaxJar::TaxCalculator.exception_handler`. Now all the configuration options are in the same place.
6
+ - Added `SuperGood::SolidusTaxJar.taxable_address_check` option which can be set to a block that receives the address and will prevent actual tax calculator from occurring if it returns false. If your app has introduced a method like `Spree::Address#us?`, you could avoid trying to compute taxes on non-US orders by doing the following in an initializer:
7
+ ```ruby
8
+ SuperGood::SolidusTaxJar.taxable_address_check = ->(address) { address.us? }
9
+ ```
@@ -13,9 +13,15 @@ module SuperGood
13
13
  class << self
14
14
  attr_accessor :discount_calculator
15
15
  attr_accessor :test_mode
16
+ attr_accessor :exception_handler
17
+ attr_accessor :taxable_address_check
16
18
  end
17
19
 
18
20
  self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator
19
21
  self.test_mode = false
22
+ self.exception_handler = ->(e) {
23
+ Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
24
+ }
25
+ self.taxable_address_check = ->(address) { true }
20
26
  end
21
27
  end
@@ -1,11 +1,6 @@
1
1
  module SuperGood
2
2
  module SolidusTaxJar
3
3
  class TaxCalculator
4
- class_attribute :exception_handler
5
- self.exception_handler = ->(e) {
6
- Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
7
- }
8
-
9
4
  def self.default_api
10
5
  ::SuperGood::SolidusTaxJar::API.new
11
6
  end
@@ -18,6 +13,7 @@ module SuperGood
18
13
  def calculate
19
14
  return no_tax if SuperGood::SolidusTaxJar.test_mode
20
15
  return no_tax if order.tax_address.empty? || order.line_items.none?
16
+ return no_tax unless taxable_address? order.tax_address
21
17
 
22
18
  cache do
23
19
  next no_tax unless taxjar_breakdown
@@ -129,6 +125,14 @@ module SuperGood
129
125
  end
130
126
  end
131
127
  end
128
+
129
+ def exception_handler
130
+ SuperGood::SolidusTaxJar.exception_handler
131
+ end
132
+
133
+ def taxable_address?(address)
134
+ SuperGood::SolidusTaxJar.taxable_address_check.(address)
135
+ end
132
136
  end
133
137
  end
134
138
  end
@@ -1,5 +1,5 @@
1
1
  module SuperGood
2
2
  module SolidusTaxJar
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_good-solidus_taxjar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Norman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -160,6 +160,7 @@ files:
160
160
  - ".gitignore"
161
161
  - ".rspec"
162
162
  - ".travis.yml"
163
+ - CHANGELOG.md
163
164
  - CODE_OF_CONDUCT.md
164
165
  - Gemfile
165
166
  - LICENSE.txt