Avatax_TaxService 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Avatax_TaxService.gemspec +2 -2
- data/samples/CancelTaxTest.rb +34 -0
- data/samples/GetTaxHistoryTest.rb +45 -0
- data/samples/GetTaxTest.rb +149 -0
- data/samples/PingTest.rb +26 -0
- data/samples/PostTaxTest.rb +40 -0
- data/samples/ValidateAddressTest.rb +50 -0
- data/spec/gettax_spec.rb +1 -4
- metadata +7 -8
- data/samples/CancelTax.rb +0 -27
- data/samples/GetTax.rb +0 -118
- data/samples/GetTaxHistory.rb +0 -39
- data/samples/Ping.rb +0 -24
- data/samples/PostTax.rb +0 -34
- data/samples/Validate.rb +0 -37
- data/samples/credentials.yml +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjAwNjNhNDYxNmY2NDk4MTIwNDNjOWU5NzNiZDk0OGY3ZTRmOWIzYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmIyODBhY2JiNGI4MDY1OTVkZjY2MGE3ZjJlZWU0OWYyZDVjZjE5Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmVhOGFjNWI2NWU0NWJkOWYxOGZkYTUzZDMxMmY0N2IyOGMyZjk1ODRhN2U1
|
10
|
+
Y2YxZTI0NDE2NTJkMmVhZTI1ZGExYjY1ZjNlMDlhNDA1MTAxYTJlM2M2ODBm
|
11
|
+
YmEzMzhiMTQwMjFmMDExNTFkMWRhMDI5YzNkNTM3NWIwNjkxZGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzA5ZmIxMjVmMzY3ODNiZTVlNDI0MTJjMGUxOTkwMjEzMGMxMzA5ZWY5ODI2
|
14
|
+
MTdjMDMyMWY4NjU5NTRkYWRiOGM4M2RlMmVkNzc3ZGExODM1MGRmYjUwMzNl
|
15
|
+
M2ZkZGI5NWRiZGIxZmMzNmI3MDBmMjNmOTEwNGRlOGNmYzk4YjY=
|
data/Avatax_TaxService.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "Avatax_TaxService"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.14"
|
4
4
|
s.date = "2012-10-28"
|
5
5
|
s.author = "Graham S Wilson"
|
6
6
|
s.email = "support@Avalara.com"
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
"lib/template_adjusttax.erb", "lib/template_canceltax.erb", "lib/template_committax.erb","lib/template_gettax.erb",
|
13
13
|
"lib/template_gettaxhistory.erb","lib/template_isauthorized.erb","lib/template_ping.erb","lib/template_posttax.erb",
|
14
14
|
"lib/template_reconciletaxhistory.erb",
|
15
|
-
"samples/
|
15
|
+
"samples/CancelTaxTest.rb","samples/GetTaxTest.rb","samples/GetTaxHistoryTest.rb","samples/PingTest.rb","samples/PostTaxTest.rb","samples/ValidateAddressTest.rb",
|
16
16
|
"spec/adjusttax_spec.rb","spec/canceltax_spec.rb","spec/committax_spec.rb","spec/gettax_spec.rb",
|
17
17
|
"spec/gettaxhistory_spec.rb","spec/isauthorized_spec.rb","spec/ping_spec.rb","spec/posttax_spec.rb","spec/reconciletaxhistory_spec.rb",
|
18
18
|
"spec/spec_helper.rb","spec/taxservice_spec.rb","Avatax_TaxService.gemspec","Avatax Ruby SDK Guide.docx", "LICENSE.txt"]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../Avatax_TaxService/lib/avatax_taxservice.rb'
|
2
|
+
#require 'Avatax_TaxService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
taxSvc = AvaTax::TaxService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
cancelTaxRequest = {
|
21
|
+
# Required Request Parameters
|
22
|
+
:companycode => "APITrialCompany",
|
23
|
+
:doctype => "SalesInvoice",
|
24
|
+
:doccode => "INV001",
|
25
|
+
:cancelcode => "DocVoided"
|
26
|
+
}
|
27
|
+
|
28
|
+
cancelTaxResult = taxSvc.canceltax(cancelTaxRequest)
|
29
|
+
|
30
|
+
# Print Results
|
31
|
+
puts "CancelTaxTest ResultCode: "+cancelTaxResult[:result_code]
|
32
|
+
if cancelTaxResult[:result_code] != "Success"
|
33
|
+
cancelTaxResult[:messages].each { |message| puts message[:details] }
|
34
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../Avatax_TaxService/lib/avatax_taxservice.rb'
|
2
|
+
#require 'Avatax_TaxService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
taxSvc = AvaTax::TaxService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
getTaxHistoryRequest = {
|
21
|
+
# Required Request Parameters
|
22
|
+
:companycode => "APITrialCompany",
|
23
|
+
:doctype => "SalesInvoice",
|
24
|
+
:doccode => "INV001",
|
25
|
+
|
26
|
+
# Optional Request Parameters
|
27
|
+
:detaillevel=>"Tax"
|
28
|
+
}
|
29
|
+
|
30
|
+
getTaxHistoryResult = taxSvc.gettaxhistory(getTaxHistoryRequest)
|
31
|
+
|
32
|
+
# Print Results
|
33
|
+
puts "GetTaxHistoryTest ResultCode: " + getTaxHistoryResult[:result_code]
|
34
|
+
if getTaxHistoryResult[:result_code] != "Success"
|
35
|
+
getTaxHistoryResult[:messages].each { |message| puts message[:details] }
|
36
|
+
else
|
37
|
+
puts "Document Code: " + getTaxHistoryResult[:get_tax_result][:doc_code] +
|
38
|
+
" Total Tax: " + getTaxHistoryResult[:get_tax_result][:total_tax].to_s
|
39
|
+
getTaxHistoryResult[:get_tax_result][:tax_lines][:tax_line].each do |taxLine|
|
40
|
+
puts " " + "Line Number: " + taxLine[:no] + " Line Tax: " + taxLine[:tax].to_s
|
41
|
+
taxLine[:tax_details][:tax_detail].each do |taxDetail|
|
42
|
+
puts " " + "Jurisdiction: " + taxDetail[:juris_name] + " Tax: " + taxDetail[:tax].to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require_relative '../Avatax_TaxService/lib/avatax_taxservice.rb'
|
2
|
+
#require 'Avatax_TaxService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
taxSvc = AvaTax::TaxService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
getTaxRequest = {
|
21
|
+
# Document Level Parameters
|
22
|
+
# Required Request Parameters
|
23
|
+
:customercode => "ABC4335",
|
24
|
+
:docdate => "2014-01-01",
|
25
|
+
|
26
|
+
# Best Practice Request Parameters
|
27
|
+
:companycode => "APITrialCompany",
|
28
|
+
:doccode => "INV001",
|
29
|
+
:detaillevel => "Tax",
|
30
|
+
:commit => false,
|
31
|
+
:doctype => "SalesInvoice",
|
32
|
+
|
33
|
+
# Situational Request Parameters
|
34
|
+
# :businessidentificationno => "234243",
|
35
|
+
# :customerusagetype => "G",
|
36
|
+
# :exemptionno => "12345",
|
37
|
+
# :discount => 50,
|
38
|
+
# :locationcode => "01",
|
39
|
+
# :taxoverridetype => "TaxDate",
|
40
|
+
# :reason => "Adjustment for return",
|
41
|
+
# :taxdate => "2013-07-01",
|
42
|
+
# :taxamount => "0",
|
43
|
+
# :servicemode => "Automatic",
|
44
|
+
|
45
|
+
# Optional Request Parameters
|
46
|
+
:purchaseorderno => "PO123456",
|
47
|
+
:referencecode => "ref123456",
|
48
|
+
:poslanecode => "09",
|
49
|
+
:currencycode => "USD",
|
50
|
+
:exchangerate => "1.0",
|
51
|
+
:exchangerateeffdate => "2013-01-01",
|
52
|
+
:salespersoncode => "Bill Sales",
|
53
|
+
|
54
|
+
# Address Data
|
55
|
+
:addresses =>
|
56
|
+
[
|
57
|
+
{
|
58
|
+
:addresscode => "01",
|
59
|
+
:line1 => "45 Fremont Street",
|
60
|
+
:city => "San Francisco",
|
61
|
+
:region => "CA",
|
62
|
+
},
|
63
|
+
{
|
64
|
+
:addresscode => "02",
|
65
|
+
:line1 => "118 N Clark St",
|
66
|
+
:line2 => "Suite 100",
|
67
|
+
:line3 => "ATTN Accounts Payable",
|
68
|
+
:city => "Chicago",
|
69
|
+
:region => "IL",
|
70
|
+
:country => "US",
|
71
|
+
:postalcode => "60602",
|
72
|
+
},
|
73
|
+
{
|
74
|
+
:addresscode => "03",
|
75
|
+
:latitude => "47.627935",
|
76
|
+
:longitude => "-122.51702",
|
77
|
+
}
|
78
|
+
],
|
79
|
+
|
80
|
+
# Line Data
|
81
|
+
:lines =>
|
82
|
+
[
|
83
|
+
{
|
84
|
+
|
85
|
+
# Required Parameters
|
86
|
+
:no => "01",
|
87
|
+
:itemcode => "N543",
|
88
|
+
:qty => 1,
|
89
|
+
:amount => 10,
|
90
|
+
:origincode => "01",
|
91
|
+
:destinationcode => "02",
|
92
|
+
|
93
|
+
# Best Practice Request Parameters
|
94
|
+
:description => "Red Size 7 Widget",
|
95
|
+
:taxcode => "NT",
|
96
|
+
|
97
|
+
# Situational Request Parameters
|
98
|
+
# :customerusagetype => "L",
|
99
|
+
# :exemptionno => "12345",
|
100
|
+
# :discounted => true,
|
101
|
+
# :taxincluded => true,
|
102
|
+
# :taxoverridetypeline => "TaxDate",
|
103
|
+
# :reasonline => "Adjustment for return",
|
104
|
+
# :taxdateline => "2013-07-01",
|
105
|
+
# :taxamountline => "0",
|
106
|
+
|
107
|
+
# Optional Request Parameters
|
108
|
+
:ref1 => "ref123",
|
109
|
+
:ref2 => "ref456",
|
110
|
+
},
|
111
|
+
{
|
112
|
+
:no => "02",
|
113
|
+
:itemcode => "T345",
|
114
|
+
:qty => 3,
|
115
|
+
:amount => 150,
|
116
|
+
:origincode => "01",
|
117
|
+
:destinationcode => "03",
|
118
|
+
:description => "Size 10 Green Running Shoe",
|
119
|
+
:taxcode => "PC030147",
|
120
|
+
},
|
121
|
+
{
|
122
|
+
:no => "02-FR",
|
123
|
+
:itemcode => "FREIGHT",
|
124
|
+
:qty => 1,
|
125
|
+
:amount => 15,
|
126
|
+
:origincode => "01",
|
127
|
+
:destinationcode => "03",
|
128
|
+
:description => "Shipping Charge",
|
129
|
+
:taxcode => "FR",
|
130
|
+
}
|
131
|
+
]
|
132
|
+
}
|
133
|
+
|
134
|
+
getTaxResult = taxSvc.gettax(getTaxRequest)
|
135
|
+
|
136
|
+
# Print Results
|
137
|
+
puts "GetTaxTest ResultCode: " + getTaxResult[:result_code]
|
138
|
+
if getTaxResult[:result_code] != "Success"
|
139
|
+
getTaxResult[:messages].each { |message| puts message[:details] }
|
140
|
+
else
|
141
|
+
puts "Document Code: " + getTaxResult[:doc_code] +
|
142
|
+
" Total Tax: " + getTaxResult[:total_tax].to_s
|
143
|
+
getTaxResult[:tax_lines][:tax_line].each do |taxLine|
|
144
|
+
puts " " + "Line Number: " + taxLine[:no] + " Line Tax: " + taxLine[:tax].to_s
|
145
|
+
taxLine[:tax_details][:tax_detail].each do |taxDetail|
|
146
|
+
puts " " + "Jurisdiction: " + taxDetail[:juris_name] + " Tax: " + taxDetail[:tax].to_s
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/samples/PingTest.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../Avatax_TaxService/lib/avatax_taxservice.rb'
|
2
|
+
#require 'Avatax_TaxService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
taxSvc = AvaTax::TaxService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
pingResult = taxSvc.ping
|
21
|
+
|
22
|
+
#Display the result
|
23
|
+
puts "PingTest ResultCode: " + pingResult[:result_code]
|
24
|
+
if pingResult[:result_code] != "Success"
|
25
|
+
pingResult[:messages].each { |message| puts message[:details] }
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../Avatax_TaxService/lib/avatax_taxservice.rb'
|
2
|
+
#require 'Avatax_TaxService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
taxSvc = AvaTax::TaxService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
postTaxRequest = {
|
21
|
+
# Required Request Parameters
|
22
|
+
:companycode => "APITrialCompany",
|
23
|
+
:doctype => "SalesInvoice",
|
24
|
+
:doccode => "INV001",
|
25
|
+
:commit => "false",
|
26
|
+
:docdate => "2014-01-01",
|
27
|
+
:totaltax => "34.07",
|
28
|
+
:totalamount => "170",
|
29
|
+
|
30
|
+
# Optional Request Parameters
|
31
|
+
:newdoccode => "INV001-1"
|
32
|
+
}
|
33
|
+
|
34
|
+
postTaxResult = taxSvc.posttax(postTaxRequest)
|
35
|
+
|
36
|
+
# Print Results
|
37
|
+
puts "PostTaxTest ResultCode: " + postTaxResult[:result_code]
|
38
|
+
if postTaxResult[:result_code] != "Success"
|
39
|
+
postTaxResult[:messages].each { |message| puts message[:details] }
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../Avatax_AddressService/lib/avatax_addressservice.rb'
|
2
|
+
#require 'Avatax_AddressService'
|
3
|
+
|
4
|
+
accountNumber = "1234567890"
|
5
|
+
licenseKey = "A1B2C3D4E5F6G7H8"
|
6
|
+
useProductionURL = false
|
7
|
+
|
8
|
+
# Header Level Parameters
|
9
|
+
addressSvc = AvaTax::AddressService.new(
|
10
|
+
|
11
|
+
# Required Header Parameters
|
12
|
+
:username => accountNumber,
|
13
|
+
:password => licenseKey,
|
14
|
+
:use_production_url => useProductionURL,
|
15
|
+
:clientname => "AvaTaxSample",
|
16
|
+
|
17
|
+
# Optional Header Parameters
|
18
|
+
:name => "Development")
|
19
|
+
|
20
|
+
validateRequest = {
|
21
|
+
# Required Request Parameters
|
22
|
+
:line1 => "118 N Clark St",
|
23
|
+
:city => "Chicago",
|
24
|
+
:region => "IL",
|
25
|
+
# Optional Request Parameters
|
26
|
+
:line2 => "Suite 100",
|
27
|
+
:line3 => "ATTN Accounts Payable",
|
28
|
+
:country => "US",
|
29
|
+
:postalcode => "60602",
|
30
|
+
:coordinates => true,
|
31
|
+
:taxability => true,
|
32
|
+
:textcase => "Upper"
|
33
|
+
}
|
34
|
+
|
35
|
+
# Call the service
|
36
|
+
validateResult = addressSvc.validate(validateRequest)
|
37
|
+
|
38
|
+
# Print Results
|
39
|
+
puts "ValidateAddressTest Result: "+validateResult[:result_code]
|
40
|
+
if validateResult[:result_code] != "Success"
|
41
|
+
validateResult[:messages].each { |message| puts message[:details] }
|
42
|
+
else
|
43
|
+
puts validateResult[:valid_addresses][:valid_address][:line1] +
|
44
|
+
" " +
|
45
|
+
validateResult[:valid_addresses][:valid_address][:city] +
|
46
|
+
", " +
|
47
|
+
validateResult[:valid_addresses][:valid_address][:region] +
|
48
|
+
" " +
|
49
|
+
validateResult[:valid_addresses][:valid_address][:postal_code]
|
50
|
+
end
|
data/spec/gettax_spec.rb
CHANGED
@@ -58,9 +58,6 @@ describe "GetTax" do
|
|
58
58
|
:debug => false,
|
59
59
|
:validate => false,
|
60
60
|
:hashcode => "0",
|
61
|
-
:taxoverridetype=>"None",
|
62
|
-
:taxamount=>".0000",
|
63
|
-
:taxdate=>"1900-01-01",
|
64
61
|
:reason=>"",
|
65
62
|
:addresses=>[{
|
66
63
|
:addresscode=>"123",
|
@@ -182,7 +179,7 @@ describe "GetTax" do
|
|
182
179
|
it "all parameters succeed" do
|
183
180
|
@service = AvaTax::TaxService.new(@creds)
|
184
181
|
@result = @service.gettax(@request_required.merge(@request_optional))
|
185
|
-
@result
|
182
|
+
@result.should eql "Success"
|
186
183
|
end
|
187
184
|
end
|
188
185
|
describe "workflow" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Avatax_TaxService
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Graham S Wilson
|
@@ -43,13 +43,12 @@ files:
|
|
43
43
|
- lib/template_ping.erb
|
44
44
|
- lib/template_posttax.erb
|
45
45
|
- lib/template_reconciletaxhistory.erb
|
46
|
-
- samples/
|
47
|
-
- samples/
|
48
|
-
- samples/
|
49
|
-
- samples/
|
50
|
-
- samples/
|
51
|
-
- samples/
|
52
|
-
- samples/Validate.rb
|
46
|
+
- samples/CancelTaxTest.rb
|
47
|
+
- samples/GetTaxTest.rb
|
48
|
+
- samples/GetTaxHistoryTest.rb
|
49
|
+
- samples/PingTest.rb
|
50
|
+
- samples/PostTaxTest.rb
|
51
|
+
- samples/ValidateAddressTest.rb
|
53
52
|
- spec/adjusttax_spec.rb
|
54
53
|
- spec/canceltax_spec.rb
|
55
54
|
- spec/committax_spec.rb
|
data/samples/CancelTax.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'Avatax_TaxService'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
#Create an instance of the service class
|
5
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
6
|
-
svc = AvaTax::TaxService.new(:username => credentials['username'],
|
7
|
-
:password => credentials['password'],
|
8
|
-
:clientname => credentials['clientname'],
|
9
|
-
:use_production_url => credentials['production'])
|
10
|
-
|
11
|
-
#Create the request
|
12
|
-
request = {
|
13
|
-
:doccode=>"MyDocCode", #Required
|
14
|
-
:companycode=>credentials['companycode'], #Required
|
15
|
-
:doctype=>"SalesInvoice", #Required
|
16
|
-
:cancelcode=>"DocVoided" #Required
|
17
|
-
}
|
18
|
-
#Call the service
|
19
|
-
result = svc.canceltax(request)
|
20
|
-
#Display the result
|
21
|
-
puts "CancelTax ResultCode: "+result[:result_code]
|
22
|
-
|
23
|
-
#If we encountered an error
|
24
|
-
if result[:result_code] != "Success"
|
25
|
-
#Print the first error message returned
|
26
|
-
puts result[:details]
|
27
|
-
end
|
data/samples/GetTax.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'Avatax_TaxService'
|
2
|
-
require 'date'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
#Create an instance of the service class
|
6
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
7
|
-
svc = AvaTax::TaxService.new(:username => credentials['username'],
|
8
|
-
:password => credentials['password'],
|
9
|
-
:clientname => credentials['clientname'],
|
10
|
-
:use_production_url => credentials['production'])
|
11
|
-
#Create the request
|
12
|
-
#Document Level Setup
|
13
|
-
# R: indicates Required Element
|
14
|
-
# O: Indicates Optional Element
|
15
|
-
#
|
16
|
-
get_tax_request = {
|
17
|
-
# Set the tax document properties - values are Required unless noted as Optional, but all properties must be defined.
|
18
|
-
|
19
|
-
:companycode=>credentials['companycode'], # R: Company Code from the accounts Admin Console
|
20
|
-
:doctype=>"SalesInvoice", # R: Typically SalesOrder,SalesInvoice, ReturnInvoice
|
21
|
-
:doccode=>"SampleDoc: " + DateTime.now.to_s, # R: Invoice or document tracking number - Must be unique
|
22
|
-
:docdate=>DateTime.now.strftime("%Y-%m-%d"), # R: Sets reporting date and default tax date
|
23
|
-
:salespersoncode=>"Bill Sales", # O: This is a reportable value that does not affect tax calculation.
|
24
|
-
:customercode=>"TaxSvcTestCust", # R: String - Customer Tracking number or Exemption Customer Code
|
25
|
-
:customerusagetype=>"", # O: Send for tax exempt transactions only.
|
26
|
-
:discount=>".0000", # O: Send for document-level discounts only.
|
27
|
-
:purchaseorderno=>"PO123456", # O: Specifies the purchase order number associated with the transaction. This value can be used to track single-use exemption certficates.
|
28
|
-
:exemptionno=>"", # O: Send for tax exempt transactions only.
|
29
|
-
:origincode=>"123", # R: Value representing the Origin Address
|
30
|
-
:destinationcode=>"456", # R: Value representing the Destination Address
|
31
|
-
:detaillevel=>"Tax", # R: Chose Summary, Document, Line or Tax - varying levels of results detail
|
32
|
-
:referencecode=>"", # O: This is a reportable value that does not affect tax calculation.
|
33
|
-
:locationcode=>"", # O: This is a reportable value that does not affect tax calculation.
|
34
|
-
:commit=>"false", # O: Default is "false" - Set to "true" to commit the Document
|
35
|
-
# TaxOverride O: Allows the TaxDate (or other values) to be overridden for tax calculation. Situational only. can be added at the document OR line level.
|
36
|
-
#:taxoverridetype=>"TaxDate",
|
37
|
-
#:taxdate=>"1900-01-01",
|
38
|
-
# :reason=>"",
|
39
|
-
:currencycode=>"USD", # O: This is a reportable value that does not affect tax calculation.
|
40
|
-
:servicemode=>"Remote", # O: This is a reportable value that does not affect tax calculation.
|
41
|
-
:paymentdate=>"2013-09-26", # O: This is a reportable value that does not affect tax calculation.
|
42
|
-
:exchangerate=>".0000", # O: This is a reportable value that does not affect tax calculation.
|
43
|
-
:exchangerateeffdate=>"1900-01-01", # O: This is a reportable value that does not affect tax calculation.
|
44
|
-
:poslanecode=>"", # O: This is a reportable value that does not affect tax calculation.
|
45
|
-
:businessidentificationno=>"", # O: Specified VAT ID of customer for international/VAT calculations and reporting.
|
46
|
-
:debug=>true, # O: If true, transaction logs will be written in the gem root directory.
|
47
|
-
# Address Section
|
48
|
-
# Add the origin and destination addresses referred to by the
|
49
|
-
# "OriginCode" and "DestinationCode" properties above.
|
50
|
-
:addresses=>[{
|
51
|
-
:addresscode=>"123",
|
52
|
-
:line1=>"100 ravine lane",
|
53
|
-
:line2=>"Suite 21",
|
54
|
-
:city=>"Bainbridge Island",
|
55
|
-
:region=>"WA",
|
56
|
-
:postalcode=>"98110",
|
57
|
-
:country=>"US",
|
58
|
-
:latitude=>"",
|
59
|
-
:longitude=>""
|
60
|
-
}, {
|
61
|
-
:addresscode=>"456",
|
62
|
-
:line1=>"7070 West Arlington Drive",
|
63
|
-
:city=>"Lakewood",
|
64
|
-
:region=>"CO",
|
65
|
-
:postalcode=>"80123",
|
66
|
-
:country=>"US",
|
67
|
-
}],
|
68
|
-
|
69
|
-
# Add invoice lines
|
70
|
-
:lines=>[{
|
71
|
-
:no=>"1", # R: string - line Number of invoice - must be unique within the document.
|
72
|
-
:itemcode=>"Canoe", #R: string - SKU or short name of Item
|
73
|
-
:qty=>"1", # R: decimal - The number of items -- Qty of product sold.
|
74
|
-
:amount=>"300.43", # R: decimal - the "NET" amount -- Amount should be the 'extended' or 'net' amount
|
75
|
-
:discounted=>"false", # R: determines if the document-level discount should be applied to this line item.
|
76
|
-
:ref1=>"ref1", # O: This is a reportable value that does not affect tax calculation.
|
77
|
-
:ref2=>"ref2", # O: This is a reportable value that does not affect tax calculation.
|
78
|
-
:description=>"Blue canoe", # O: string - Description or category of item sold.
|
79
|
-
# TaxOverride O: Allows the TaxDate (or other values) to be overridden for tax calculation. Situational only.
|
80
|
-
:taxoverridetypeline=>"TaxAmount",
|
81
|
-
:taxamountline=>"10",
|
82
|
-
:taxdateline=>"1900-01-01",
|
83
|
-
:reasonline=>"Tax credit",
|
84
|
-
:taxincluded=>"false" # O: Determines if the line amount on the request includes the tax amount
|
85
|
-
}, {
|
86
|
-
:no=>"2",
|
87
|
-
:itemcode=>"Rowing boat",
|
88
|
-
:qty=>"1",
|
89
|
-
:amount=>"800.12",
|
90
|
-
:discounted=>"false",
|
91
|
-
:ref1=>"ref3",
|
92
|
-
:ref2=>"ref4",
|
93
|
-
:description=>"Red rowing boat",
|
94
|
-
:taxincluded=>"false"
|
95
|
-
}]}
|
96
|
-
|
97
|
-
#Call the service
|
98
|
-
result = svc.gettax(get_tax_request)
|
99
|
-
#Display the result
|
100
|
-
#puts result
|
101
|
-
puts "CalcTax ResultCode: "+result[:result_code]
|
102
|
-
#If we encountered an error
|
103
|
-
if result[:result_code] != "Success"
|
104
|
-
result[:messages][:message].each do |message|
|
105
|
-
puts message[:summary]+ ": " + message[:details]
|
106
|
-
end
|
107
|
-
else
|
108
|
-
puts "DocCode: " + result[:doc_code]+ " Total Tax Calculated: " + result[:total_tax]
|
109
|
-
puts "Jurisdiction Breakdown:"
|
110
|
-
#Show the tax amount calculated at each jurisdictional level
|
111
|
-
result[:tax_lines][:tax_line].each do |line|
|
112
|
-
puts " "+ "Line Number " + line[:no] + ": Tax: " + line[:tax]
|
113
|
-
#This will display the jurisdiction name and tax at each jurisdiction for the line.
|
114
|
-
line[:tax_details][:tax_detail].each do |key,value|
|
115
|
-
puts " " + key.to_s+ ": " + value.to_s
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
data/samples/GetTaxHistory.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'Avatax_TaxService'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
#Create an instance of the service class
|
5
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
6
|
-
svc = AvaTax::TaxService.new(:username => credentials['username'],
|
7
|
-
:password => credentials['password'],
|
8
|
-
:clientname => credentials['clientname'],
|
9
|
-
:use_production_url => credentials['production'])
|
10
|
-
|
11
|
-
#Create the request
|
12
|
-
request = {
|
13
|
-
:doccode=>"MyDocCode", #Required
|
14
|
-
:companycode=> credentials['companycode'], #Required
|
15
|
-
:doctype=>"SalesInvoice", #Required
|
16
|
-
:docid=> "", #Optional
|
17
|
-
:detaillevel=>"Tax", #Optional
|
18
|
-
:debug => true #Optional
|
19
|
-
}
|
20
|
-
#Call the service
|
21
|
-
result = svc.gettaxhistory(request)
|
22
|
-
#print result
|
23
|
-
#Display the result
|
24
|
-
puts "GetTaxHistory ResultCode: "+result[:result_code]
|
25
|
-
#If we encountered an error
|
26
|
-
if result[:result_code] != "Success"
|
27
|
-
puts result[:details]
|
28
|
-
else
|
29
|
-
puts "DocCode: " + result[:get_tax_result][:doc_code]+ " Total Tax Calculated: " + result[:get_tax_result][:total_tax].to_s
|
30
|
-
puts "Jurisdiction Breakdown:"
|
31
|
-
#Show the tax amount calculated at each jurisdictional level
|
32
|
-
result[:get_tax_result][:tax_lines][:tax_line].each do |line|
|
33
|
-
puts " "+ "Line Number " + line[:no] + ": Tax: " + line[:tax]
|
34
|
-
#This will display the jurisdiction name and tax at each jurisdiction for the line.
|
35
|
-
line[:tax_details][:tax_detail].each do |key,value|
|
36
|
-
puts " " + key.to_s+ ": " + value.to_s
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/samples/Ping.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'Avatax_TaxService'
|
2
|
-
require 'Avatax_AddressService'
|
3
|
-
require 'yaml'
|
4
|
-
#Note that the ping function exists in both the AddressSvc and TaxSvc classes - it works the same way in both.
|
5
|
-
|
6
|
-
#Create an instance of the service class
|
7
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
8
|
-
svc = AvaTax::TaxService.new(:username => credentials['username'],
|
9
|
-
:password => credentials['password'],
|
10
|
-
:clientname => credentials['clientname'],
|
11
|
-
:use_production_url => credentials['production'])
|
12
|
-
|
13
|
-
#Call the service
|
14
|
-
result = svc.ping
|
15
|
-
#print result
|
16
|
-
|
17
|
-
#Display the result
|
18
|
-
puts "Ping ResultCode: "+result[:result_code]
|
19
|
-
|
20
|
-
#If we encountered an error
|
21
|
-
if result[:result_code] != "Success"
|
22
|
-
#Print the first error message returned
|
23
|
-
puts result[:details]
|
24
|
-
end
|
data/samples/PostTax.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'Avatax_TaxService'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
#Create an instance of the service class
|
5
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
6
|
-
svc = AvaTax::TaxService.new(:username => credentials['username'],
|
7
|
-
:password => credentials['password'],
|
8
|
-
:clientname => credentials['clientname'],
|
9
|
-
:use_production_url => credentials['production'])
|
10
|
-
|
11
|
-
#Create the request
|
12
|
-
request = {
|
13
|
-
:docid=>"", #optional
|
14
|
-
:companycode=> credentials['companycode'], #Required
|
15
|
-
:doctype=>"SalesInvoice", #Required
|
16
|
-
:doccode => "MyDocCode",
|
17
|
-
:docdate => DateTime.now.strftime("%Y-%m-%d"),
|
18
|
-
:totalamount => "1100.5500",
|
19
|
-
:totaltax => "7",
|
20
|
-
:hashcode => "0",
|
21
|
-
:commit => "false",
|
22
|
-
:newdoccode => "MyDocCode"
|
23
|
-
}
|
24
|
-
#Call the service
|
25
|
-
result = svc.posttax(request)
|
26
|
-
|
27
|
-
#Display the result
|
28
|
-
puts "PostTax ResultCode: "+result[:result_code]
|
29
|
-
|
30
|
-
#If we encountered an error
|
31
|
-
if result[:result_code] != "Success"
|
32
|
-
#Print the first error message returned
|
33
|
-
puts result[:messages][:message][0][:summary]
|
34
|
-
end
|
data/samples/Validate.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'Avatax_AddressService'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
#Create an instance of the service class
|
5
|
-
credentials = YAML::load(File.open('credentials.yml'))
|
6
|
-
svc = AvaTax::AddressService.new(:username => credentials['username'],
|
7
|
-
:password => credentials['password'],
|
8
|
-
:clientname => credentials['clientname'],
|
9
|
-
:use_production_url => credentials['production'])
|
10
|
-
|
11
|
-
# Create the request
|
12
|
-
input = {
|
13
|
-
:line1 => "General Delivery", #Required
|
14
|
-
:line2 => "Suite 100", #Optional
|
15
|
-
:line3 => "Attn: Accounts Payable", #Optional
|
16
|
-
:city =>"Seattle", #Required, if PostalCode is not specified
|
17
|
-
:region=>"WA", #Required, if PostalCode is not specified
|
18
|
-
:postalcode =>"98101", #Required, if City and Region are not specified
|
19
|
-
:country => "US" #Optional
|
20
|
-
}
|
21
|
-
#Call the service
|
22
|
-
result = svc.validate(input)
|
23
|
-
#Display the result
|
24
|
-
#print result
|
25
|
-
|
26
|
-
#If we encountered an error
|
27
|
-
if result[:result_code] != "Success"
|
28
|
-
#puts the first error message returned
|
29
|
-
puts "Address Validation ResultCode: "+result[:result_code]
|
30
|
-
puts result[:details]
|
31
|
-
else
|
32
|
-
puts "Validated Address: "
|
33
|
-
result[:valid_addresses][:valid_address].each do |key, value|
|
34
|
-
puts key.to_s + ": " + value.to_s if not value.nil?
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|