suretax 0.2.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +4 -0
- data/.rubocop.yml +111 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +9 -9
- data/lib/suretax.rb +0 -1
- data/lib/suretax/api.rb +7 -7
- data/lib/suretax/api/cancel_request.rb +7 -7
- data/lib/suretax/api/group.rb +5 -6
- data/lib/suretax/api/item_message.rb +3 -3
- data/lib/suretax/api/request.rb +37 -37
- data/lib/suretax/api/request_item.rb +13 -17
- data/lib/suretax/api/response.rb +18 -19
- data/lib/suretax/api/tax.rb +11 -12
- data/lib/suretax/api/tax_amount.rb +3 -4
- data/lib/suretax/concerns.rb +1 -3
- data/lib/suretax/concerns/validatable.rb +21 -27
- data/lib/suretax/configuration.rb +17 -20
- data/lib/suretax/connection.rb +3 -5
- data/lib/suretax/constants/regulatory_codes.rb +8 -8
- data/lib/suretax/constants/response_groups.rb +6 -6
- data/lib/suretax/constants/sales_type_codes.rb +5 -5
- data/lib/suretax/constants/tax_situs_codes.rb +10 -10
- data/lib/suretax/constants/transaction_type_codes.rb +2 -2
- data/lib/suretax/response.rb +7 -10
- data/lib/suretax/version.rb +1 -1
- data/spec/lib/suretax/api/group_spec.rb +21 -22
- data/spec/lib/suretax/api/request_item_spec.rb +10 -12
- data/spec/lib/suretax/api/request_item_validations_spec.rb +73 -76
- data/spec/lib/suretax/api/request_spec.rb +62 -66
- data/spec/lib/suretax/api/request_validations_spec.rb +141 -143
- data/spec/lib/suretax/api/response_spec.rb +48 -52
- data/spec/lib/suretax/api/tax_amount_spec.rb +12 -12
- data/spec/lib/suretax/api/tax_spec.rb +26 -28
- data/spec/lib/suretax/configuration_spec.rb +21 -24
- data/spec/lib/suretax/connection_spec.rb +11 -15
- data/spec/lib/suretax/response_spec.rb +27 -31
- data/spec/spec_helper.rb +16 -17
- data/spec/support/cancellation_helper.rb +0 -1
- data/spec/support/connection_shared_examples.rb +8 -10
- data/spec/support/request_helper.rb +13 -14
- data/spec/support/suretax_helper.rb +2 -4
- data/spec/support/validations_shared_examples.rb +12 -12
- data/suretax.gemspec +10 -8
- metadata +7 -7
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eaeb9eb9a7c58e6f33b2d62dc8b5263dd04031d
|
4
|
+
data.tar.gz: b3999b6f2efa44afafca10ee867ec26ceb9fb3d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f1239082346ee9d24c8c636f83af1af1393aaa0172a99ecc4dbc35618e36e5d606110f03109df212da538bfe01629df6971fdf94ce008183a2b55cbe72bf1ce
|
7
|
+
data.tar.gz: 3256264cb0c9f55c5d4cc43e2248e29adbedef90efd3514ceab70d00fc3dc48e5028ed9e2a6f84fdd6b3e0196eb85f26aa187cbdc94909b7aed8d6c0c4766e05
|
data/.env.example
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# This is the default configuration file. Enabling and disabling is configured
|
2
|
+
# in separate files. This file adds all other parameters apart from Enabled.
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
Include:
|
6
|
+
- "**/*.gemspec"
|
7
|
+
- "**/Rakefile"
|
8
|
+
Exclude:
|
9
|
+
- vendor/**/*
|
10
|
+
- db/**/*
|
11
|
+
TargetRubyVersion: 2.3
|
12
|
+
|
13
|
+
Rails:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
Style/CaseIndentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/Lambda:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/ConditionalAssignment:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Performance/Casecmp:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/GuardClause:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/FrozenStringLiteralComment:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
LineLength:
|
35
|
+
Description: "Limit lines to 100 characters."
|
36
|
+
Max: 100
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
AlignHash:
|
40
|
+
Description: Align the elements of a hash literal if they span more than one line.
|
41
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
42
|
+
EnforcedHashRocketStyle: table
|
43
|
+
EnforcedColonStyle: table
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
AlignParameters:
|
47
|
+
EnforcedStyle: with_first_parameter
|
48
|
+
SupportedStyles:
|
49
|
+
- with_first_parameter
|
50
|
+
- with_fixed_indentation
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Documentation:
|
54
|
+
Description: "Document classes and non-namespace modules."
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
AndOr:
|
58
|
+
Description: "Use &&/|| instead of and/or."
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
EndAlignment:
|
62
|
+
Description: "Align ends correctly."
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
CollectionMethods:
|
66
|
+
Description: "Preferred collection methods."
|
67
|
+
Enabled: true
|
68
|
+
PreferredMethods:
|
69
|
+
collect: "map"
|
70
|
+
collect!: "map!"
|
71
|
+
reduce: "inject"
|
72
|
+
detect: "find"
|
73
|
+
find_all: "select"
|
74
|
+
|
75
|
+
AssignmentInCondition:
|
76
|
+
Description: "Don't use assignment in conditions."
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
DoubleNegation:
|
80
|
+
Description: "Checks for uses of double negation (!!)."
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Style/BlockDelimiters:
|
84
|
+
Description: >-
|
85
|
+
Avoid using {...} for multi-line blocks (multiline chaining is
|
86
|
+
always ugly).
|
87
|
+
Prefer {...} over do...end for single-line blocks.
|
88
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
SpaceBeforeFirstArg:
|
92
|
+
Description: "Checks that exactly one space is used between a method name and the first argument for method calls without parentheses."
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
DotPosition:
|
96
|
+
Description: "Checks the position of the dot in multi-line method calls."
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
ClassAndModuleChildren:
|
100
|
+
Description: "Checks style of children classes and modules."
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
RescueModifier:
|
104
|
+
Description: "Avoid using rescue in modifier form"
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
StringLiterals:
|
108
|
+
EnforcedStyle: double_quotes
|
109
|
+
|
110
|
+
StringLiteralsInInterpolation:
|
111
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
suretax (0.2.
|
4
|
+
suretax (0.2.3)
|
5
5
|
excon
|
6
6
|
monetize
|
7
|
-
money (~> 6.
|
7
|
+
money (~> 6.9.0)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -17,13 +17,13 @@ GEM
|
|
17
17
|
diff-lcs (1.2.5)
|
18
18
|
docile (1.1.5)
|
19
19
|
dotenv (1.0.2)
|
20
|
-
excon (0.
|
21
|
-
i18n (0.
|
20
|
+
excon (0.56.0)
|
21
|
+
i18n (0.8.4)
|
22
22
|
method_source (0.8.2)
|
23
|
-
monetize (1.
|
24
|
-
money (~> 6.
|
25
|
-
money (6.
|
26
|
-
i18n (>= 0.6.4,
|
23
|
+
monetize (1.7.0)
|
24
|
+
money (~> 6.9)
|
25
|
+
money (6.9.0)
|
26
|
+
i18n (>= 0.6.4, < 0.9)
|
27
27
|
multi_json (1.10.1)
|
28
28
|
pry (0.10.1)
|
29
29
|
coderay (~> 1.1.0)
|
@@ -72,4 +72,4 @@ DEPENDENCIES
|
|
72
72
|
webmock
|
73
73
|
|
74
74
|
BUNDLED WITH
|
75
|
-
1.
|
75
|
+
1.15.1
|
data/lib/suretax.rb
CHANGED
data/lib/suretax/api.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "suretax/api/response"
|
2
|
+
require "suretax/api/request"
|
3
|
+
require "suretax/api/request_item"
|
4
|
+
require "suretax/api/cancel_request"
|
5
|
+
require "suretax/api/group"
|
6
|
+
require "suretax/api/tax"
|
7
|
+
require "suretax/api/tax_amount"
|
@@ -17,7 +17,7 @@ module Suretax
|
|
17
17
|
configuration.validation_key)
|
18
18
|
|
19
19
|
options.each_pair do |key, value|
|
20
|
-
send("#{key
|
20
|
+
send("#{key}=", value.to_s)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -31,21 +31,21 @@ module Suretax
|
|
31
31
|
|
32
32
|
def params
|
33
33
|
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
"ClientNumber" => client_number,
|
35
|
+
"ClientTracking" => client_tracking,
|
36
|
+
"TransId" => transaction,
|
37
|
+
"ValidationKey" => validation_key
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def log_request
|
44
|
-
logger
|
44
|
+
logger&.info "\nSureTax Cancellation sent:\n#{params.inspect}"
|
45
45
|
end
|
46
46
|
|
47
47
|
def log_response(response)
|
48
|
-
logger
|
48
|
+
logger&.info("\nSureTax Cancellation resp:\n#{response.inspect}")
|
49
49
|
end
|
50
50
|
|
51
51
|
def logger
|
data/lib/suretax/api/group.rb
CHANGED
@@ -4,13 +4,12 @@ module Suretax
|
|
4
4
|
attr_reader :state, :customer, :invoice, :taxes, :line
|
5
5
|
|
6
6
|
def initialize(response_params)
|
7
|
-
@state = response_params.fetch(
|
8
|
-
@invoice = response_params.fetch(
|
9
|
-
@line = response_params[
|
10
|
-
@customer = response_params.fetch(
|
11
|
-
@taxes = response_params.fetch(
|
7
|
+
@state = response_params.fetch("StateCode")
|
8
|
+
@invoice = response_params.fetch("InvoiceNumber")
|
9
|
+
@line = response_params["LineNumber"]
|
10
|
+
@customer = response_params.fetch("CustomerNumber")
|
11
|
+
@taxes = response_params.fetch("TaxList").map { |tax| Tax.new(tax) }
|
12
12
|
end
|
13
|
-
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
@@ -4,9 +4,9 @@ module Suretax
|
|
4
4
|
attr_reader :line_number, :response_code, :message
|
5
5
|
|
6
6
|
def initialize(response_params)
|
7
|
-
@line_number = response_params.fetch(
|
8
|
-
@response_code = response_params.fetch(
|
9
|
-
@message = response_params.fetch(
|
7
|
+
@line_number = response_params.fetch("LineNumber")
|
8
|
+
@response_code = response_params.fetch("ResponseCode")
|
9
|
+
@message = response_params.fetch("Message")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/suretax/api/request.rb
CHANGED
@@ -34,14 +34,14 @@ module Suretax
|
|
34
34
|
:items
|
35
35
|
|
36
36
|
def initialize(options = {})
|
37
|
-
self.return_file_code =
|
37
|
+
self.return_file_code = "0"
|
38
38
|
self.client_number = options.delete(:client_number) || configuration.client_number
|
39
39
|
self.validation_key = options.delete(:validation_key) || configuration.validation_key
|
40
40
|
|
41
41
|
default_data_date(options)
|
42
42
|
|
43
|
-
options.each_pair do |key,value|
|
44
|
-
|
43
|
+
options.each_pair do |key, value|
|
44
|
+
send("#{key}=", value.to_s)
|
45
45
|
end
|
46
46
|
|
47
47
|
initialize_items(options)
|
@@ -60,12 +60,12 @@ module Suretax
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def valid?
|
63
|
-
|
63
|
+
errors.none?
|
64
64
|
end
|
65
65
|
|
66
66
|
def rollback
|
67
67
|
if response
|
68
|
-
CancelRequest.new(transaction: response.transaction,
|
68
|
+
CancelRequest.new(transaction: response.transaction,
|
69
69
|
client_number: client_number, validation_key: validation_key,
|
70
70
|
client_tracking: client_tracking).submit
|
71
71
|
end
|
@@ -74,62 +74,62 @@ module Suretax
|
|
74
74
|
def params
|
75
75
|
{
|
76
76
|
"ClientNumber" => client_number,
|
77
|
-
"BusinessUnit" => business_unit ||
|
77
|
+
"BusinessUnit" => business_unit || "",
|
78
78
|
"ValidationKey" => validation_key,
|
79
79
|
"DataYear" => data_year,
|
80
80
|
"DataMonth" => data_month,
|
81
81
|
"TotalRevenue" => total_revenue.to_f,
|
82
82
|
"ReturnFileCode" => return_file_code,
|
83
|
-
"ClientTracking" => client_tracking ||
|
83
|
+
"ClientTracking" => client_tracking || "",
|
84
84
|
"IndustryExemption" => industry_exemption,
|
85
85
|
"ResponseType" => response_type,
|
86
86
|
"ResponseGroup" => response_group,
|
87
87
|
"STAN" => stan || "",
|
88
|
-
"ItemList" => items.map
|
88
|
+
"ItemList" => items.map(&:params)
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
92
|
private
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
def default_data_date(options)
|
95
|
+
max_date = configuration.test? ? Date.today.prev_month : Date.today
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
requested_date = begin
|
98
|
+
Date.new(options.delete(:data_year).to_i, options.delete(:data_month).to_i, 1)
|
99
|
+
rescue
|
100
|
+
max_date
|
101
|
+
end
|
102
102
|
|
103
|
-
|
103
|
+
data_date = [requested_date, max_date].min
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
self.data_month = data_date.strftime("%m")
|
106
|
+
self.data_year = data_date.strftime("%Y")
|
107
|
+
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
109
|
+
def initialize_items(options)
|
110
|
+
self.items = []
|
111
|
+
if options[:items].respond_to?(:each)
|
112
|
+
options[:items].each do |item_args|
|
113
|
+
items << RequestItem.new(item_args)
|
115
114
|
end
|
116
115
|
end
|
116
|
+
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
def log_request
|
119
|
+
logger&.info "\nSureTax Request sent:\n#{params.inspect}"
|
120
|
+
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
def logger
|
123
|
+
configuration.logger
|
124
|
+
end
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
126
|
+
def configuration
|
127
|
+
Suretax.configuration
|
128
|
+
end
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
def connection
|
131
|
+
@connection ||= Connection.new
|
132
|
+
end
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Suretax
|
2
2
|
module Api
|
3
|
-
|
4
3
|
class RequestItem
|
5
|
-
|
6
4
|
include Suretax::Concerns::Validatable
|
7
5
|
|
8
6
|
attr_accessor :bill_to_number,
|
@@ -56,15 +54,13 @@ module Suretax
|
|
56
54
|
:tax_exemption_codes
|
57
55
|
|
58
56
|
def initialize(args = {})
|
59
|
-
args.each_pair do |key,value|
|
60
|
-
|
57
|
+
args.each_pair do |key, value|
|
58
|
+
send("#{key}=", value.to_s)
|
61
59
|
end
|
62
60
|
|
63
61
|
@tax_exemption_codes = []
|
64
|
-
|
65
|
-
|
66
|
-
@tax_exemption_codes << code.to_s
|
67
|
-
end
|
62
|
+
args[:tax_exemption_codes]&.each do |code|
|
63
|
+
@tax_exemption_codes << code.to_s
|
68
64
|
end
|
69
65
|
|
70
66
|
validate!
|
@@ -75,17 +71,17 @@ module Suretax
|
|
75
71
|
"LineNumber" => line_number,
|
76
72
|
"InvoiceNumber" => invoice_number,
|
77
73
|
"CustomerNumber" => customer_number,
|
78
|
-
"OrigNumber" => orig_number ||
|
79
|
-
"TermNumber" => term_number ||
|
80
|
-
"BillToNumber" => bill_to_number ||
|
74
|
+
"OrigNumber" => orig_number || "",
|
75
|
+
"TermNumber" => term_number || "",
|
76
|
+
"BillToNumber" => bill_to_number || "",
|
81
77
|
"Zipcode" => zipcode,
|
82
78
|
"Plus4" => plus_four,
|
83
|
-
"P2PZipcode" => p_to_p_zipcode ||
|
84
|
-
"P2PPlus4" => p_to_p_plus_four ||
|
85
|
-
"TransDate" => trans_date || Date.today.strftime(
|
79
|
+
"P2PZipcode" => p_to_p_zipcode || "",
|
80
|
+
"P2PPlus4" => p_to_p_plus_four || "",
|
81
|
+
"TransDate" => trans_date || Date.today.strftime("%m-%d-%Y"),
|
86
82
|
"Revenue" => revenue.to_f,
|
87
83
|
"Units" => units.to_i,
|
88
|
-
"UnitType" => presence(unit_type)
|
84
|
+
"UnitType" => presence(unit_type) || "00",
|
89
85
|
"Seconds" => seconds.to_i,
|
90
86
|
"TaxIncludedCode" => tax_included_code,
|
91
87
|
"TaxSitusRule" => tax_situs_rule,
|
@@ -93,7 +89,7 @@ module Suretax
|
|
93
89
|
"SalesTypeCode" => sales_type_code,
|
94
90
|
"RegulatoryCode" => regulatory_code,
|
95
91
|
"TaxExemptionCodeList" => tax_exemption_codes,
|
96
|
-
"UDF" => user_defined_field ||
|
92
|
+
"UDF" => user_defined_field || "",
|
97
93
|
"ShipFromZipCode" => ship_from_zipcode || "",
|
98
94
|
"ShipFromPlus4" => ship_from_plus_four || "",
|
99
95
|
"OrderPlacementZipcode" => order_placement_zipcode || "",
|
@@ -113,7 +109,7 @@ module Suretax
|
|
113
109
|
end
|
114
110
|
|
115
111
|
def presence(value)
|
116
|
-
value
|
112
|
+
value unless blank(value)
|
117
113
|
end
|
118
114
|
|
119
115
|
def blank(value)
|