tax_cloud 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +8 -25
- data/.rubocop_todo.yml +47 -0
- data/.travis.yml +5 -5
- data/CHANGELOG.rdoc +11 -0
- data/CONTRIBUTORS.txt +3 -0
- data/Gemfile +16 -5
- data/LICENSE.rdoc +1 -1
- data/README.rdoc +12 -8
- data/Rakefile +7 -11
- data/lib/config/locales/en.yml +2 -2
- data/lib/hash.rb +3 -4
- data/lib/tasks/tax_cloud.rake +4 -4
- data/lib/tasks/tax_code_groups.rake +11 -11
- data/lib/tasks/tax_codes.rake +12 -12
- data/lib/tax_cloud.rb +8 -3
- data/lib/tax_cloud/address.rb +10 -5
- data/lib/tax_cloud/cart_item.rb +2 -0
- data/lib/tax_cloud/client.rb +13 -3
- data/lib/tax_cloud/configuration.rb +13 -2
- data/lib/tax_cloud/errors.rb +2 -0
- data/lib/tax_cloud/errors/api_error.rb +3 -3
- data/lib/tax_cloud/errors/missing_config_error.rb +2 -1
- data/lib/tax_cloud/errors/missing_config_option_error.rb +2 -1
- data/lib/tax_cloud/errors/soap_error.rb +6 -6
- data/lib/tax_cloud/errors/tax_cloud_error.rb +4 -3
- data/lib/tax_cloud/errors/unexpected_soap_response_error.rb +3 -3
- data/lib/tax_cloud/record.rb +2 -0
- data/lib/tax_cloud/responses.rb +2 -0
- data/lib/tax_cloud/responses/authorized.rb +3 -1
- data/lib/tax_cloud/responses/authorized_with_capture.rb +3 -1
- data/lib/tax_cloud/responses/base.rb +5 -4
- data/lib/tax_cloud/responses/captured.rb +3 -1
- data/lib/tax_cloud/responses/cart_item.rb +6 -2
- data/lib/tax_cloud/responses/generic.rb +2 -0
- data/lib/tax_cloud/responses/lookup.rb +10 -8
- data/lib/tax_cloud/responses/ping.rb +3 -1
- data/lib/tax_cloud/responses/returned.rb +3 -1
- data/lib/tax_cloud/responses/tax_code_groups.rb +3 -1
- data/lib/tax_cloud/responses/tax_codes.rb +3 -1
- data/lib/tax_cloud/responses/tax_codes_by_group.rb +3 -1
- data/lib/tax_cloud/responses/verify_address.rb +3 -1
- data/lib/tax_cloud/tax_code.rb +2 -0
- data/lib/tax_cloud/tax_code_constants.rb +262 -260
- data/lib/tax_cloud/tax_code_group.rb +3 -1
- data/lib/tax_cloud/tax_code_group_constants.rb +2 -0
- data/lib/tax_cloud/tax_code_groups.rb +3 -1
- data/lib/tax_cloud/tax_codes.rb +3 -1
- data/lib/tax_cloud/transaction.rb +2 -0
- data/lib/tax_cloud/version.rb +3 -1
- data/tax_cloud.gemspec +16 -18
- data/test/cassettes/authorized.yml +6 -6
- data/test/cassettes/authorized_with_capture.yml +6 -6
- data/test/cassettes/authorized_with_localized_time.yml +6 -6
- data/test/cassettes/captured.yml +7 -7
- data/test/cassettes/get_tic_groups.yml +5 -5
- data/test/cassettes/get_tics.yml +5 -5
- data/test/cassettes/get_tics_by_group.yml +5 -5
- data/test/cassettes/invalid_soap_call.yml +5 -5
- data/test/cassettes/lookup.yml +5 -5
- data/test/cassettes/lookup_ny.yml +5 -5
- data/test/cassettes/ping.yml +5 -5
- data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
- data/test/cassettes/ping_with_invalid_response.yml +5 -5
- data/test/cassettes/returned.yml +7 -7
- data/test/cassettes/verify_bad_address.yml +5 -5
- data/test/cassettes/verify_good_address.yml +5 -5
- data/test/helper.rb +3 -1
- data/test/test_address.rb +3 -1
- data/test/test_cart_item.rb +3 -1
- data/test/test_client.rb +4 -2
- data/test/test_configuration_optional_keys.rb +44 -0
- data/test/{test_configuration.rb → test_configuration_required_keys.rb} +6 -4
- data/test/test_lookup_response.rb +22 -0
- data/test/test_setup.rb +3 -1
- data/test/test_soap.rb +3 -1
- data/test/test_tax_code_groups.rb +4 -2
- data/test/test_tax_codes.rb +3 -1
- data/test/test_transaction.rb +3 -1
- data/test/test_transaction_ny.rb +3 -1
- data/test/vcr_setup.rb +2 -0
- metadata +28 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2460bb8644d05b7169cd48c66cf45044c83d85b3bd9a4294f8a89b4313890774
|
4
|
+
data.tar.gz: f2e119009a8f5e45f379ed3a0b39d7417897504e502b21bf8e32b03dc02d5843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab1f5b780aa0a1e6bc8b8f3345c15d9ea93bb9ce822805fb1a842d2c7fb42a4fc1cb17eb84206dc818af9131e498315abf17f360fb9e1a777e48083bae6607f6
|
7
|
+
data.tar.gz: 3eeb12ff2d77868a321fafbc81d52f7cd2abcd7ae8dd24f1ca8800b72db8a47b58e1ceb5f33bd5f0535e87b98f20954dd169e7cf58bc8e19ff00b8ebf141c84c
|
data/.rubocop.yml
CHANGED
@@ -1,29 +1,12 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
|
4
|
+
TargetRubyVersion: 2.6
|
5
|
+
NewCops: enable
|
6
|
+
Exclude:
|
3
7
|
- vendor/**
|
4
8
|
- bin/**
|
5
9
|
|
6
|
-
|
7
|
-
Enabled:
|
8
|
-
|
9
|
-
MethodLength:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
ClassLength:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
Documentation:
|
16
|
-
# don't require classes to be documented
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
NumericLiterals:
|
20
|
-
# don't separate numeric literals with _
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
RaiseArgs:
|
24
|
-
# don't need to provide an exception class and message, SoapError takes care of that
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Encoding:
|
28
|
-
# missing UTF-8 comment
|
29
|
-
Enabled: false
|
10
|
+
Style/NumericLiteralPrefix:
|
11
|
+
Enabled: true
|
12
|
+
EnforcedOctalStyle: zero_only
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-10-14 20:47:01 UTC using RuboCop version 0.93.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Lint/MissingSuper:
|
11
|
+
Exclude:
|
12
|
+
- 'test/test_lookup_response.rb'
|
13
|
+
|
14
|
+
# Offense count: 3
|
15
|
+
# Configuration parameters: IgnoredMethods.
|
16
|
+
Metrics/AbcSize:
|
17
|
+
Max: 23
|
18
|
+
|
19
|
+
# Offense count: 5
|
20
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
21
|
+
# ExcludedMethods: refine
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Max: 39
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Configuration parameters: CountComments, CountAsOne.
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Max: 261
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
32
|
+
Metrics/MethodLength:
|
33
|
+
Max: 14
|
34
|
+
|
35
|
+
# Offense count: 1
|
36
|
+
Style/Documentation:
|
37
|
+
Exclude:
|
38
|
+
- 'spec/**/*'
|
39
|
+
- 'test/**/*'
|
40
|
+
- 'lib/tax_cloud/tax_codes.rb'
|
41
|
+
|
42
|
+
# Offense count: 61
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
45
|
+
# URISchemes: http, https
|
46
|
+
Layout/LineLength:
|
47
|
+
Max: 235
|
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.4.0 (12/7/2020)
|
2
|
+
|
3
|
+
* Add <tt>open_timeout</tt> and <tt>read_timeout</tt> options into configuration - @ka8725.
|
4
|
+
* Switch to using BigDecimal for <tt>tax_amount</tt> to avoid floating point arithmetic errors - @paulhenrich.
|
5
|
+
* Require ruby 2.6.0+
|
6
|
+
* Upgrade to rubocop latest
|
7
|
+
* Add `TargetRubyVersion: 2.6` to rubocop config (based on https://www.ruby-lang.org/en/downloads/branches/ oldest "normal maintenance" version)
|
8
|
+
* Add `required_ruby_version` to gemspec
|
9
|
+
* addresses rubocop violations
|
10
|
+
* Update WSDL endpoint URL as recommended by TaxCloud to https://asmx.taxcloud.com/1.0/?wsdl - @brchristian.
|
11
|
+
|
1
12
|
=== 0.3.0 (1/9/2014)
|
2
13
|
|
3
14
|
* #19: Support Savon 2 - @drewtempelmeyer.
|
data/CONTRIBUTORS.txt
CHANGED
data/Gemfile
CHANGED
@@ -1,9 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
|
-
|
6
|
-
gem '
|
7
|
-
|
8
|
-
|
7
|
+
group :development do
|
8
|
+
gem 'rubocop', '~> 0.93.1'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'minitest'
|
13
|
+
gem 'vcr'
|
14
|
+
gem 'webmock'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :development, :test do
|
18
|
+
gem 'rake', '~>12.2.1'
|
19
|
+
gem 'rdoc'
|
9
20
|
end
|
data/LICENSE.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2011-
|
3
|
+
Copyright (c) 2011-2020 Drew Tempelmeyer & Contributors
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.rdoc
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
= TaxCloud
|
2
2
|
|
3
|
-
{<img src="https://travis-ci.org/
|
3
|
+
{<img src="https://travis-ci.org/txcrb/tax_cloud.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/txcrb/tax_cloud]
|
4
4
|
|
5
5
|
TaxCloud[http://www.taxcloud.com] is a free service to calculate sales tax and generate tax reports. The <tt>tax_cloud</tt> gem allows you to easily integrate with TaxCloud's API.
|
6
6
|
|
7
7
|
=== Getting Started
|
8
8
|
Create a TaxCloud[http://www.taxcloud.com] merchant account at http://www.taxcloud.net. Add a website to your account under Locations[https://taxcloud.net/account/locations]. This will generate an API ID and API Key that you will need to use the service.
|
9
9
|
|
10
|
-
TaxCloud[http://www.taxcloud.com] also offers an optional address verification API. To use it, you need a USPS (United States Postal Service) Address API
|
11
|
-
1.
|
12
|
-
2.
|
13
|
-
3.
|
10
|
+
TaxCloud[http://www.taxcloud.com] also offers an optional address verification API. To use it, you need a USPS (United States Postal Service) Address API Username. To obtain your USPS Username:
|
11
|
+
1. Go through the Web Tools API Portal registration process at https://registration.shippingapis.com/
|
12
|
+
2. Once you have registered for your account, you will receive an email with your USPS username and password.
|
13
|
+
3. Enter your USPS username in your TaxCloud initializer (see below).
|
14
14
|
|
15
15
|
=== Setup
|
16
16
|
Add the gem to your Gemfile.
|
@@ -22,9 +22,13 @@ Configure your environment. For example, create an initializer in Rails in <tt>c
|
|
22
22
|
TaxCloud.configure do |config|
|
23
23
|
config.api_login_id = 'your_tax_cloud_api_login_id'
|
24
24
|
config.api_key = 'your_tax_cloud_api_key'
|
25
|
-
config.usps_username = 'your_usps_username'
|
25
|
+
config.usps_username = 'your_usps_username' # optional
|
26
|
+
config.open_timeout = 1 # optional
|
27
|
+
config.read_timeout = 1 # optional
|
26
28
|
end
|
27
29
|
|
30
|
+
The <tt>open_timeout</tt> and <tt>read_timeout</tt> options are used to specify waiting time for the TaxCloud web service response in seconds. Default values: <tt>open_timeout = 2</tt> and <tt>read_timeout = 2</tt>.
|
31
|
+
|
28
32
|
=== Using TaxCloud
|
29
33
|
Define the destination and origin addresses using <tt>TaxCloud::Address</tt>.
|
30
34
|
|
@@ -116,7 +120,7 @@ Tax code constants are defined in <tt>tax_code_constants.rb</tt> and tax code gr
|
|
116
120
|
TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_code_groups
|
117
121
|
|
118
122
|
=== Tax States
|
119
|
-
TaxCloud manages a list of states in which you can calculate sales tax. The default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement) states enabled. All other states will return $0 for tax values. To enable other states, go to https://taxcloud.
|
123
|
+
TaxCloud manages a list of states in which you can calculate sales tax. The default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement) states enabled. All other states will return $0 for tax values. To enable other states, go to https://taxcloud.com/go/states-management/. You can find more information about SSUTA here[http://www.streamlinedsalestax.org/index.php?page=About-Us].
|
120
124
|
|
121
125
|
=== Running Tests
|
122
126
|
* VCR and WebMock are used to replay requests and avoid hitting the API each time. To refresh the mocks, simply delete the <tt>test/cassettes</tt> directory.
|
@@ -135,6 +139,6 @@ TaxCloud manages a list of states in which you can calculate sales tax. The defa
|
|
135
139
|
|
136
140
|
=== License
|
137
141
|
|
138
|
-
Copyright Drew Tempelmeyer and contributors, 2011-
|
142
|
+
Copyright Drew Tempelmeyer and contributors, 2011-2020.
|
139
143
|
|
140
144
|
This gem is licensed under the MIT license.
|
data/Rakefile
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'rdoc/task'
|
6
|
+
require 'vcr'
|
4
7
|
|
5
|
-
|
8
|
+
README = 'README.rdoc'
|
6
9
|
|
7
10
|
Rake::TestTask.new(:test) do |test|
|
8
11
|
test.libs << 'lib' << 'test'
|
@@ -11,25 +14,18 @@ Rake::TestTask.new(:test) do |test|
|
|
11
14
|
end
|
12
15
|
|
13
16
|
RDoc::Task.new do |rd|
|
14
|
-
README = 'README.rdoc'
|
15
17
|
rd.main = README
|
16
|
-
rd.rdoc_files.include(README, 'CHANGELOG.rdoc', 'LICENSE.rdoc',
|
18
|
+
rd.rdoc_files.include(README, 'CHANGELOG.rdoc', 'LICENSE.rdoc', 'lib/**/*.rb')
|
17
19
|
rd.rdoc_dir = 'doc'
|
18
20
|
rd.title = 'tax_cloud'
|
19
21
|
end
|
20
22
|
|
21
|
-
desc "Validate the gemspec."
|
22
|
-
task :gemspec do
|
23
|
-
puts gemspec.validate
|
24
|
-
end
|
25
|
-
|
26
23
|
load 'lib/tasks/tax_cloud.rake'
|
27
24
|
load 'lib/tasks/tax_codes.rake'
|
28
25
|
load 'lib/tasks/tax_code_groups.rake'
|
29
|
-
|
30
26
|
load 'vcr/tasks/vcr.rake'
|
31
27
|
|
32
28
|
require 'rubocop/rake_task'
|
33
|
-
|
29
|
+
RuboCop::RakeTask.new(:rubocop)
|
34
30
|
|
35
|
-
task default: [
|
31
|
+
task default: %i[rubocop test]
|
data/lib/config/locales/en.yml
CHANGED
@@ -16,7 +16,7 @@ en:
|
|
16
16
|
\_\_end\n"
|
17
17
|
missing_config_option:
|
18
18
|
message: "Missing configuration option: %{name}."
|
19
|
-
summary: "A configuration option was not provided when
|
19
|
+
summary: "A configuration option was not provided when configuring TaxCloud."
|
20
20
|
resolution: "Review your `TaxCloud.configure` code. Are you using an environment
|
21
21
|
variable that has not been set?"
|
22
22
|
soap_error:
|
@@ -31,4 +31,4 @@ en:
|
|
31
31
|
api_error:
|
32
32
|
message: "%{message}"
|
33
33
|
summary: "The TaxCloud server returned an error in the response: `%{raw}`"
|
34
|
-
resolution: "Check the request parameters."
|
34
|
+
resolution: "Check the request parameters."
|
data/lib/hash.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Hash #:nodoc: all
|
2
4
|
# Downcase the keys. Use this because <tt>TaxCloud::Address.verify</tt> requires downcased keys
|
3
5
|
def downcase_keys
|
4
|
-
|
5
|
-
h[k.downcase] = v
|
6
|
-
h
|
7
|
-
end
|
6
|
+
transform_keys(&:downcase)
|
8
7
|
end
|
9
8
|
end
|
data/lib/tasks/tax_cloud.rake
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'tax_cloud'
|
2
4
|
|
3
5
|
namespace :tax_cloud do
|
4
|
-
|
5
|
-
desc "Configure TaxCloud."
|
6
|
+
desc 'Configure TaxCloud.'
|
6
7
|
task :configure do
|
7
8
|
unless TaxCloud.configured?
|
8
9
|
TaxCloud.configure do |config|
|
9
10
|
config.api_login_id = ENV['TAXCLOUD_API_LOGIN_ID']
|
10
11
|
config.api_key = ENV['TAXCLOUD_API_KEY']
|
11
12
|
config.usps_username = ENV['TAXCLOUD_USPS_USERNAME']
|
12
|
-
end
|
13
|
+
end
|
13
14
|
Savon.configure do |config|
|
14
15
|
config.log = false
|
15
16
|
end
|
16
17
|
HTTPI.log = false
|
17
18
|
end
|
18
19
|
end
|
19
|
-
|
20
20
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
namespace :tax_cloud do
|
4
|
+
desc 'Generate tax code groups.'
|
5
|
+
task tax_code_groups: :configure do
|
6
|
+
filename = 'lib/tax_cloud/tax_code_group_constants.rb'
|
6
7
|
|
7
8
|
begin
|
8
9
|
groups = TaxCloud::TaxCode::Groups.all.values
|
9
10
|
|
10
|
-
File.open filename,
|
11
|
+
File.open filename, 'wt' do |f|
|
11
12
|
f.write "module TaxCloud\n"
|
12
13
|
f.write " class TaxCode\n"
|
13
14
|
f.write " # Tax Code Groups.\n"
|
@@ -16,9 +17,9 @@ namespace :tax_cloud do
|
|
16
17
|
groups.each do |group|
|
17
18
|
puts " #{group.description}"
|
18
19
|
code = group.description.upcase
|
19
|
-
code.gsub!
|
20
|
-
code.gsub!
|
21
|
-
code.gsub!
|
20
|
+
code.gsub!(/[^A-Z0-9]/, '_')
|
21
|
+
code.gsub!(/_$/, '')
|
22
|
+
code.gsub!(/_+/, '_')
|
22
23
|
f.write " \# #{group.description}\n"
|
23
24
|
f.write " #{code} = #{group.group_id}\n"
|
24
25
|
end
|
@@ -29,11 +30,10 @@ namespace :tax_cloud do
|
|
29
30
|
end
|
30
31
|
|
31
32
|
puts "Done, #{filename}."
|
32
|
-
rescue => e
|
33
|
-
puts
|
33
|
+
rescue StandardError => e
|
34
|
+
puts 'ERROR: Unable to generate a new list of tax codes.'
|
34
35
|
puts e.message
|
35
36
|
raise e
|
36
37
|
end
|
37
38
|
end
|
38
|
-
|
39
39
|
end
|
data/lib/tasks/tax_codes.rake
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
namespace :tax_cloud do
|
4
|
+
desc 'Generate tax codes.'
|
5
|
+
task tax_codes: :configure do
|
6
|
+
filename = 'lib/tax_cloud/tax_code_constants.rb'
|
6
7
|
|
7
8
|
begin
|
8
9
|
groups = TaxCloud::TaxCode::Groups.all.values
|
9
10
|
groups_and_tax_codes = Hash[groups.map do |group|
|
10
|
-
[
|
11
|
+
[group, group.tax_codes.values]
|
11
12
|
end]
|
12
|
-
File.open filename,
|
13
|
+
File.open filename, 'wt' do |f|
|
13
14
|
f.write "module TaxCloud\n"
|
14
15
|
f.write " # Tax Codes.\n"
|
15
16
|
f.write " class TaxCodes\n"
|
@@ -20,9 +21,9 @@ namespace :tax_cloud do
|
|
20
21
|
f.write " \# #{group.description}\n\n"
|
21
22
|
tax_codes.each do |tax_code|
|
22
23
|
code = tax_code.description.upcase
|
23
|
-
code.gsub!
|
24
|
-
code.gsub!
|
25
|
-
code.gsub!
|
24
|
+
code.gsub!(/[^A-Z0-9]/, '_')
|
25
|
+
code.gsub!(/_+$/, '')
|
26
|
+
code.gsub!(/_+/, '_')
|
26
27
|
# avoid duplicates
|
27
28
|
code_id = codes[code] ? "#{code}_#{codes[code]}" : code
|
28
29
|
codes[code] = (codes[code] || 0) + 1
|
@@ -35,11 +36,10 @@ namespace :tax_cloud do
|
|
35
36
|
f.write "end\n"
|
36
37
|
end
|
37
38
|
puts "Done, #{filename}."
|
38
|
-
rescue => e
|
39
|
-
puts
|
39
|
+
rescue StandardError => e
|
40
|
+
puts 'ERROR: Unable to generate a new list of tax codes.'
|
40
41
|
puts e.message
|
41
42
|
raise e
|
42
43
|
end
|
43
|
-
|
44
44
|
end
|
45
45
|
end
|
data/lib/tax_cloud.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'savon'
|
2
4
|
require 'i18n'
|
3
5
|
require 'hash'
|
6
|
+
|
7
|
+
require 'active_support'
|
4
8
|
require 'active_support/core_ext'
|
5
9
|
|
6
10
|
require 'tax_cloud/version'
|
@@ -25,7 +29,7 @@ I18n.load_path << File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml
|
|
25
29
|
# For information on configuring and using the TaxCloud API, look at the <tt>README</tt> file.
|
26
30
|
module TaxCloud
|
27
31
|
# WSDL location for TaxCloud API.
|
28
|
-
WSDL_URL = 'https://
|
32
|
+
WSDL_URL = 'https://asmx.taxcloud.com/1.0/?wsdl'
|
29
33
|
|
30
34
|
# TaxCloud API version.
|
31
35
|
API_VERSION = '1.0'
|
@@ -36,7 +40,7 @@ module TaxCloud
|
|
36
40
|
|
37
41
|
# Returns true if the gem has been configured.
|
38
42
|
def configured?
|
39
|
-
|
43
|
+
configuration.present?
|
40
44
|
end
|
41
45
|
|
42
46
|
# Configure the gem.
|
@@ -60,7 +64,8 @@ module TaxCloud
|
|
60
64
|
private
|
61
65
|
|
62
66
|
def check_configuration!
|
63
|
-
|
67
|
+
raise TaxCloud::Errors::MissingConfig unless self.configuration
|
68
|
+
|
64
69
|
self.configuration.check!
|
65
70
|
end
|
66
71
|
end
|