Avatax_TaxService 1.0.11 → 1.0.12
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 +7 -4
- data/lib/avatax_taxservice.rb +127 -225
- data/lib/template_gettax.erb +2 -2
- data/samples/CancelTax.rb +27 -0
- data/samples/GetTax.rb +118 -0
- data/samples/GetTaxHistory.rb +39 -0
- data/samples/Ping.rb +24 -0
- data/samples/PostTax.rb +34 -0
- data/samples/Validate.rb +37 -0
- data/samples/credentials.yml +5 -0
- data/spec/adjusttax_spec.rb +235 -0
- data/spec/canceltax_spec.rb +148 -0
- data/spec/committax_spec.rb +145 -0
- data/spec/gettax_spec.rb +281 -0
- data/spec/gettaxhistory_spec.rb +120 -0
- data/spec/isauthorized_spec.rb +75 -0
- data/spec/ping_spec.rb +75 -0
- data/spec/posttax_spec.rb +169 -0
- data/spec/reconciletaxhistory_spec.rb +125 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/taxservice_spec.rb +42 -0
- metadata +20 -6
- data/test/test_adjtax.rb +0 -127
- data/test/test_gettax.rb +0 -150
- data/test/test_gettaxhistory.rb +0 -55
- data/test/test_reconciletaxhistory.rb +0 -63
data/lib/template_gettax.erb
CHANGED
@@ -57,7 +57,7 @@
|
|
57
57
|
<ser:RevAcct><%= lin[:revacct] %></ser:RevAcct>
|
58
58
|
<ser:Ref1><%= lin[:ref1] %></ser:Ref1>
|
59
59
|
<ser:Ref2><%= lin[:ref2] %></ser:Ref2>
|
60
|
-
<ser:ExemptionNo><%= lin[:
|
60
|
+
<ser:ExemptionNo><%= lin[:exemptionno] %></ser:ExemptionNo>
|
61
61
|
<ser:CustomerUsageType><%= lin[:customerusagetype] %></ser:CustomerUsageType>
|
62
62
|
<ser:Description><%= lin[:description] %></ser:Description>
|
63
63
|
<ser:TaxOverride>
|
@@ -67,7 +67,7 @@
|
|
67
67
|
<ser:Reason><%= lin[:reasonline] %></ser:Reason>
|
68
68
|
</ser:TaxOverride>
|
69
69
|
<ser:TaxIncluded><%= lin[:taxincluded] %></ser:TaxIncluded>
|
70
|
-
<ser:BusinessIdentificationNo><%= lin[:
|
70
|
+
<ser:BusinessIdentificationNo><%= lin[:businessidentificationno] %></ser:BusinessIdentificationNo>
|
71
71
|
</ser:Line><% end %>
|
72
72
|
</ser:Lines>
|
73
73
|
<ser:DetailLevel><%= @detaillevel %></ser:DetailLevel>
|
@@ -0,0 +1,27 @@
|
|
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
ADDED
@@ -0,0 +1,118 @@
|
|
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
|
@@ -0,0 +1,39 @@
|
|
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 => false #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
ADDED
@@ -0,0 +1,24 @@
|
|
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
ADDED
@@ -0,0 +1,34 @@
|
|
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
ADDED
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "AdjustTax" do
|
4
|
+
before :each do
|
5
|
+
credentials = YAML::load(File.open('credentials.yml'))
|
6
|
+
@creds = {:username => credentials['username'],
|
7
|
+
:password => credentials['password'],
|
8
|
+
:clientname => credentials['clientname'],
|
9
|
+
:use_production_url => credentials['production']}
|
10
|
+
@svc = AvaTax::TaxService.new(@creds)
|
11
|
+
@get_tax_request = {
|
12
|
+
:doctype => "SalesInvoice",
|
13
|
+
:commit => false,
|
14
|
+
:detaillevel => "Tax",
|
15
|
+
:docdate=>DateTime.now.strftime("%Y-%m-%d"),
|
16
|
+
:customercode => "CUST123",
|
17
|
+
:origincode => "456",
|
18
|
+
:destinationcode => "456",
|
19
|
+
:addresses=>[{
|
20
|
+
:addresscode=>"456",
|
21
|
+
:line1=>"7070 West Arlington Drive",
|
22
|
+
:postalcode=>"80123",
|
23
|
+
:country=>"US",
|
24
|
+
}],
|
25
|
+
:lines=>[{
|
26
|
+
:no=>"1",
|
27
|
+
:itemcode=>"Canoe",
|
28
|
+
:qty=>"1",
|
29
|
+
:amount=>"300.43",
|
30
|
+
:description=>"Blue canoe",
|
31
|
+
}]}
|
32
|
+
@get_tax_result = @svc.gettax(@get_tax_request)
|
33
|
+
@request_required = {
|
34
|
+
:adjustmentreason => "5",
|
35
|
+
:adjustmentdescription => "Testing Adjustments",
|
36
|
+
:doccode => @get_tax_result[:doc_code],
|
37
|
+
:doctype => "SalesInvoice",
|
38
|
+
:detaillevel => "Tax",
|
39
|
+
:docdate=>DateTime.now.strftime("%Y-%m-%d"),
|
40
|
+
:customercode => "CUST123",
|
41
|
+
:origincode => "456",
|
42
|
+
:destinationcode => "456",
|
43
|
+
:addresses=>[{
|
44
|
+
:addresscode=>"456",
|
45
|
+
:line1=>"7070 West Arlington Drive",
|
46
|
+
:postalcode=>"80123",
|
47
|
+
:country=>"US",
|
48
|
+
}],
|
49
|
+
:lines=>[{
|
50
|
+
:no=>"1",
|
51
|
+
:itemcode=>"Canoe",
|
52
|
+
:qty=>"1",
|
53
|
+
:amount=>"300.43",
|
54
|
+
:description=>"Blue canoe",
|
55
|
+
}]
|
56
|
+
|
57
|
+
}
|
58
|
+
@request_optional = {
|
59
|
+
:companycode => @get_tax_result[:company_code],
|
60
|
+
:salespersoncode => "Bill Sales",
|
61
|
+
:customerusagetype => "L",
|
62
|
+
:discount => "10",
|
63
|
+
:purchaseorderno => "PO9823",
|
64
|
+
:exemptionno => "23423",
|
65
|
+
:referencecode => "ref1",
|
66
|
+
:locationcode => "001",
|
67
|
+
:commit => "false",
|
68
|
+
:batchcode => "",
|
69
|
+
:taxoverridetype => "TaxDate",
|
70
|
+
:taxamount => "0",
|
71
|
+
:taxdate => "1999-01-01",
|
72
|
+
:reason => "Override",
|
73
|
+
:currencycode => "USD",
|
74
|
+
:servicemode => "Remote",
|
75
|
+
:paymentdate => DateTime.now.strftime("%Y-%m-%d"),
|
76
|
+
:exchangerate => "0",
|
77
|
+
:exchangerateeffdate => "1900-01-01",
|
78
|
+
:poslanecode => "1",
|
79
|
+
:businessidentificationno => "2342",
|
80
|
+
:debug => false,
|
81
|
+
:hashcode => "0",
|
82
|
+
:taxoverridetype=>"None",
|
83
|
+
:taxamount=>".0000",
|
84
|
+
:taxdate=>"1900-01-01",
|
85
|
+
:reason=>"",
|
86
|
+
:addresses=>[{
|
87
|
+
:addresscode=>"123",
|
88
|
+
:line1=>"100 ravine lane",
|
89
|
+
:line2=>"Suite 21",
|
90
|
+
:city=>"Bainbridge Island",
|
91
|
+
:region=>"WA",
|
92
|
+
:postalcode=>"98110",
|
93
|
+
:country=>"US",
|
94
|
+
:taxregionid=>"0",
|
95
|
+
:latitude=>"",
|
96
|
+
:longitude=>""
|
97
|
+
}, {
|
98
|
+
:addresscode=>"456",
|
99
|
+
:line1=> "Attn. Accounting",
|
100
|
+
:line3=>"7070 West Arlington Drive",
|
101
|
+
:postalcode=>"80123",
|
102
|
+
:country=>"US",
|
103
|
+
:taxregionid=>"0"
|
104
|
+
}],
|
105
|
+
:lines=>[{
|
106
|
+
:no=>"1",
|
107
|
+
:itemcode=>"Canoe",
|
108
|
+
:qty=>"1",
|
109
|
+
:amount=>"300.43",
|
110
|
+
:discounted=>"false",
|
111
|
+
:ref1=>"ref1",
|
112
|
+
:ref2=>"ref2",
|
113
|
+
:description=>"Blue canoe",
|
114
|
+
:taxoverridetypeline=>"TaxAmount",
|
115
|
+
:taxamountline=>"10",
|
116
|
+
:taxdateline=>"1900-01-01",
|
117
|
+
:reasonline=>"Tax credit",
|
118
|
+
:taxincluded=>"false"
|
119
|
+
}, {
|
120
|
+
:no=>"2",
|
121
|
+
:itemcode=>"Rowing boat",
|
122
|
+
:qty=>"1",
|
123
|
+
:destinationcodeline=>"123",
|
124
|
+
:amount=>"800.12",
|
125
|
+
:discounted=>"false",
|
126
|
+
:ref1=>"ref3",
|
127
|
+
:ref2=>"ref4",
|
128
|
+
:description=>"Red rowing boat",
|
129
|
+
:taxoverridetype=>"None",
|
130
|
+
:taxamount=>"0",
|
131
|
+
:taxdate=>"1900-01-01",
|
132
|
+
:taxincluded=>"true"
|
133
|
+
}]
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "returns a meaningful" do
|
138
|
+
it "error when URL is missing" do
|
139
|
+
@creds[:use_production_url] = nil
|
140
|
+
@service = AvaTax::TaxService.new(@creds)
|
141
|
+
@service.adjusttax(@request_required)[:result_code].should eql "Success"
|
142
|
+
end
|
143
|
+
it "success when URL is specified" do
|
144
|
+
@creds[:use_production_url] = false
|
145
|
+
@service = AvaTax::TaxService.new(@creds)
|
146
|
+
@service.adjusttax(@request_required)[:result_code].should eql "Success"
|
147
|
+
end
|
148
|
+
it "error when username is missing" do
|
149
|
+
@creds[:username] = nil
|
150
|
+
@service = AvaTax::TaxService.new(@creds)
|
151
|
+
@service.adjusttax(@request_required)[:result_code].should eql "Error"
|
152
|
+
end
|
153
|
+
it "error when password is omitted" do
|
154
|
+
@creds[:password] = nil
|
155
|
+
@service = AvaTax::TaxService.new(@creds)
|
156
|
+
@service.adjusttax(@request_required)[:result_code].should eql "Error"
|
157
|
+
end
|
158
|
+
it "success when clientname is omitted" do
|
159
|
+
@creds[:clientname] = nil
|
160
|
+
@service = AvaTax::TaxService.new(@creds)
|
161
|
+
@service.adjusttax(@request_required)[:result_code].should eql "Success"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "has consistent formatting for" do
|
166
|
+
it "server-side errors" do
|
167
|
+
@creds[:password] = nil
|
168
|
+
@service = AvaTax::TaxService.new(@creds)
|
169
|
+
@result = @service.adjusttax(@request_required)
|
170
|
+
@result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
|
171
|
+
end
|
172
|
+
it "successful results" do
|
173
|
+
@service = AvaTax::TaxService.new(@creds)
|
174
|
+
@result = @service.adjusttax(@request_required)
|
175
|
+
@result[:result_code].should eql "Success" and @result[:transaction_id].should_not be_nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
describe "requests with" do
|
179
|
+
it "missing required parameters fail" do
|
180
|
+
@service = AvaTax::TaxService.new(@creds)
|
181
|
+
@result = @service.adjusttax(@request_optional)
|
182
|
+
@result[:result_code].should eql "Error"
|
183
|
+
end
|
184
|
+
it "invalid parameters ignore them" do
|
185
|
+
@service = AvaTax::TaxService.new(@creds)
|
186
|
+
@request_required[:bogus] = "data"
|
187
|
+
@result = @service.adjusttax(@request_required)
|
188
|
+
@result[:result_code].should eql "Success"
|
189
|
+
end
|
190
|
+
it "missing optional parameters succeed" do
|
191
|
+
@service = AvaTax::TaxService.new(@creds)
|
192
|
+
@result = @service.adjusttax(@request_required)
|
193
|
+
@result[:result_code].should eql "Success"
|
194
|
+
end
|
195
|
+
it "all parameters succeed" do
|
196
|
+
@service = AvaTax::TaxService.new(@creds)
|
197
|
+
@result = @service.adjusttax(@request_required.merge(@request_optional))
|
198
|
+
@result[:result_code].should eql "Success"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
describe "workflow" do
|
202
|
+
it "should adjust committed documents" do
|
203
|
+
@request_required[:customercode] = "NewCust"
|
204
|
+
@generic_request = {
|
205
|
+
:doccode => @request_required[:doccode],
|
206
|
+
:companycode => @request_required[:companycode],
|
207
|
+
:doctype => @request_required[:doctype],
|
208
|
+
:commit => true
|
209
|
+
}
|
210
|
+
@post_result = @svc.posttax(@generic_request)
|
211
|
+
@result = @svc.adjusttax(@request_required)
|
212
|
+
@history_result = @svc.gettaxhistory(@generic_request)
|
213
|
+
@result[:result_code].should eql "Success" and
|
214
|
+
@history_result[:get_tax_request][:customer_code].should eql @request_required[:customercode] and
|
215
|
+
@history_result[:get_tax_result][:doc_status].should eql "Committed"
|
216
|
+
end
|
217
|
+
it "should adjust uncommitted documents" do
|
218
|
+
@request_required[:customercode] = "NewCust"
|
219
|
+
@generic_request = {
|
220
|
+
:doccode => @request_required[:doccode],
|
221
|
+
:companycode => @request_required[:companycode],
|
222
|
+
:doctype => @request_required[:doctype],
|
223
|
+
:commit => false
|
224
|
+
}
|
225
|
+
@post_result = @svc.posttax(@generic_request)
|
226
|
+
@result = @svc.adjusttax(@request_required)
|
227
|
+
@history_result = @svc.gettaxhistory(@generic_request)
|
228
|
+
@result[:result_code].should eql "Success" and
|
229
|
+
@history_result[:get_tax_request][:customer_code].should eql @request_required[:customercode] and
|
230
|
+
@history_result[:get_tax_result][:doc_status].should eql "Saved"
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|