blob: dbde950c4975e0245d1191afae4978daa296bbdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
module SuperGood
module SolidusTaxJar
module CalculatorHelper
extend ActiveSupport::Concern
class_methods do
def default_api
::SuperGood::SolidusTaxJar::API.new
end
end
def incomplete_address?(address)
return true if address.is_a?(Spree::Tax::TaxLocation)
[
address.address1,
address.city,
address.state&.abbr || address.state_name,
address.zipcode,
address.country&.iso
].any?(&:blank?)
end
def taxable_address?(address)
SuperGood::SolidusTaxJar.taxable_address_check.(address)
end
def cache
if !Rails.env.test?
Rails.cache.fetch(
cache_key,
expires_in: SuperGood::SolidusTaxJar.cache_duration
) { yield }
else
yield
end
end
def exception_handler
SuperGood::SolidusTaxJar.exception_handler
end
end
end
end
|