Class: SuperGood::SolidusTaxjar::TaxRateCalculator
- Inherits:
-
Object
- Object
- SuperGood::SolidusTaxjar::TaxRateCalculator
- Includes:
- CalculatorHelper
- Defined in:
- lib/super_good/solidus_taxjar/tax_rate_calculator.rb
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(address, api: SuperGood::SolidusTaxjar.api) ⇒ TaxRateCalculator
constructor
A new instance of TaxRateCalculator.
Methods included from CalculatorHelper
#cache, #exception_handler, #incomplete_address?, #state_required?, #taxable_address?
Constructor Details
#initialize(address, api: SuperGood::SolidusTaxjar.api) ⇒ TaxRateCalculator
Returns a new instance of TaxRateCalculator.
5 6 7 8 |
# File 'lib/super_good/solidus_taxjar/tax_rate_calculator.rb', line 5 def initialize(address, api: SuperGood::SolidusTaxjar.api) @address = address @api = api end |
Instance Method Details
#calculate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/super_good/solidus_taxjar/tax_rate_calculator.rb', line 10 def calculate return no_rate if SuperGood::SolidusTaxjar.test_mode return no_rate if incomplete_address?(address) return no_rate unless taxable_address?(address) cache do api.tax_rate_for(address).to_d end rescue => e exception_handler.call(e) no_rate end |