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.
@@ -0,0 +1,16 @@
1
+ # spec/awesome_gem/awesome.rb
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
3
+ $: << File.join(APP_ROOT, 'lib') # so rspec knows where your file could be
4
+ require 'avatax_taxservice.rb' # this loads the class you want to test
5
+ require 'yaml'
6
+
7
+ RSpec.configure do |config|
8
+ # Use color in STDOUT
9
+ config.color_enabled = true
10
+
11
+ # Use color not only in STDOUT but also in pagers and files
12
+ config.tty = true
13
+
14
+ # Use the specified formatter
15
+ config.formatter = :documentation # :progress, :html, :textmate
16
+ end
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ describe "TaxService" 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
+ end
11
+
12
+ describe "does not allow instantiation with" do
13
+ it "no values" do
14
+ lambda { AvaTax::TaxService.new }.should raise_exception
15
+ end
16
+ it "optional values only" do
17
+ lambda { AvaTax::TaxService.new(
18
+ :clientname => @creds[:clientname],
19
+ :adapter => "AvaTaxCalcRuby",
20
+ :machine => "MyComputer",
21
+ :use_production_account => @creds[:use_production_url] ) }.should raise_exception
22
+ end
23
+ end
24
+ describe "allows instantiation with" do
25
+ it "required values only" do
26
+ lambda { AvaTax::TaxService.new(
27
+ :username => @creds[:username],
28
+ :password => @creds[:password],
29
+ :clientname => @creds[:clientname]) }.should_not raise_exception
30
+ end
31
+ it "required and optional values" do
32
+ lambda { AvaTax::TaxService.new(
33
+ :username => @creds[:username],
34
+ :password => @creds[:password],
35
+ :clientname => @creds[:clientname],
36
+ :adapter => "AvaTaxCalcRuby",
37
+ :machine => "MyComputer",
38
+ :use_production_account => false ) }.should_not raise_exception
39
+ end
40
+ end
41
+
42
+ end
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.11
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham S Wilson
@@ -43,10 +43,24 @@ files:
43
43
  - lib/template_ping.erb
44
44
  - lib/template_posttax.erb
45
45
  - lib/template_reconciletaxhistory.erb
46
- - test/test_adjtax.rb
47
- - test/test_gettax.rb
48
- - test/test_gettaxhistory.rb
49
- - test/test_reconciletaxhistory.rb
46
+ - samples/CancelTax.rb
47
+ - samples/credentials.yml
48
+ - samples/GetTax.rb
49
+ - samples/GetTaxHistory.rb
50
+ - samples/Ping.rb
51
+ - samples/PostTax.rb
52
+ - samples/Validate.rb
53
+ - spec/adjusttax_spec.rb
54
+ - spec/canceltax_spec.rb
55
+ - spec/committax_spec.rb
56
+ - spec/gettax_spec.rb
57
+ - spec/gettaxhistory_spec.rb
58
+ - spec/isauthorized_spec.rb
59
+ - spec/ping_spec.rb
60
+ - spec/posttax_spec.rb
61
+ - spec/reconciletaxhistory_spec.rb
62
+ - spec/spec_helper.rb
63
+ - spec/taxservice_spec.rb
50
64
  - Avatax_TaxService.gemspec
51
65
  - Avatax Ruby SDK Guide.docx
52
66
  - LICENSE.txt
@@ -54,7 +68,7 @@ homepage: http://www.avalara.com/
54
68
  licenses:
55
69
  - MIT
56
70
  metadata: {}
57
- post_install_message: Thanks for installing the Avalara AddressService Ruby SDK. Refer
71
+ post_install_message: Thanks for installing the Avalara TaxService Ruby SDK. Refer
58
72
  to "Avatax Ruby SDK User Guide.docx" to get started.
59
73
  rdoc_options: []
60
74
  require_paths:
data/test/test_adjtax.rb DELETED
@@ -1,127 +0,0 @@
1
- #Load the Avalara Address Service module
2
- require 'avatax_taxservice'
3
- #Load the Avalara Address Service module
4
- require 'avatax_addressservice'
5
-
6
- #Create new credentials hash object
7
- credentials = Hash.new
8
-
9
- #Create new document hash object
10
- document = Hash.new
11
-
12
- #Create new address hash object
13
- address = Hash.new
14
-
15
- credentials[:username] = 'USERNAME'
16
- credentials[:password] = 'PASSWORD'
17
- credentials[:name] = 'Avalara Inc.'
18
- credentials[:clientname] = 'MyShoppingCart'
19
- credentials[:adapter] = 'Avatax SDK for Ruby 1.0.6'
20
- credentials[:machine] = 'Lenovo W520 Windows 7'
21
- # Determine whether the DEV or PROD service is used. false = DEV true = PROD
22
- credentials[:use_production_account] = false
23
-
24
- #Create a tax service instance
25
- TaxServ = AvaTax::TaxService.new(credentials)
26
-
27
- #Create an address service instance
28
- AddrService = AvaTax::AddressService.new(credentials)
29
-
30
- #Populate the fields required by the GetTax call
31
- document[:adjustmentreason] = "5"
32
- document[:adjustmentdescription] = "Hey I adjusted the tax"
33
- document[:companycode] = 'APITrialCompany'
34
- document[:doctype] = 'SalesInvoice'
35
- document[:doccode] = "MyDocCode"
36
- document[:docdate] = "2013-10-11"
37
- document[:salespersoncode] = "Bill Sales"
38
- document[:customercode] = "CUS001"
39
- document[:customerusagetype] = ""
40
- document[:discount] = ".0000"
41
- document[:purchaseorderno]= "PO123456"
42
- document[:exemptionno] = ""
43
- document[:origincode] = "123"
44
- document[:destinationcode] = "456"
45
- #Pass addresses as an array
46
- # <AddressCode>123</AddressCode>
47
- # <Line1>100 Ravine Lane</Line1>
48
- # <Line2/>
49
- # <Line3/>
50
- # <City>Bainbridge Island</City>
51
- # <Region>WA</Region>
52
- # <PostalCode>98110</PostalCode>
53
- # <Country>US</Country>
54
- # <TaxRegionId>0</TaxRegionId>
55
- # <Latitude/>
56
- # <Longitude/>
57
- document[:addresses]= [
58
- {:addresscode => "123",:line1 => "100 ravine lane",:city => "Bainbridge Island",:region => "WA",:postalcode => "98110",:country => "US",:taxregionid => "0",:latitude => "",:longitude => ""},
59
- {:addresscode => "456",:line1 => "7070 West Arlington Drive",:city => "Lakewood",:region => "CO",:postalcode => "80123",:country => "US",:taxregionid => "0"}
60
- ]
61
- #Pass order/invoice lines as an array
62
- # <No>1</No>
63
- # <OriginCode></OriginCode>
64
- # <DestinationCode></DestinationCode>
65
- # <ItemCode>Canoe</ItemCode>
66
- # <TaxCode></TaxCode>
67
- # <Qty>1</Qty>
68
- # <Amount>300</Amount>
69
- # <Discounted>false</Discounted>
70
- # <RevAcct></RevAcct>
71
- # <Ref1>ref1</Ref1>
72
- # <Ref2>ref2</Ref2>
73
- # <ExemptionNo></ExemptionNo>
74
- # <CustomerUsageType></CustomerUsageType>
75
- # <Description>Blue canoe</Description>
76
- # <TaxOverrideType>TaxAmount</TaxOverrideType>
77
- # <TaxAmount>10</TaxAmount>
78
- # <TaxDate>1900-01-01</TaxDate>
79
- # <Reason>Tax Credit</Reason>
80
- # <TaxIncluded>false</TaxIncluded>
81
- # <BusinessIdentificationNo></BusinessIdentificationNo>
82
- document[:lines] = [
83
- {:no => "1",:itemcode => "Canoe",:qty => "1",:amount => "300.43",:discounted => "false",:ref1 => "ref1",:ref2 => "ref2",:description => "Blue canoe",:taxoverridetypeline => "TaxAmount",:taxamountline => "10",:taxdateline => "1900-01-01",:reasonline => "Tax credit",:taxincluded => "false"},
84
- {:no => "2",:itemcode => "Rowing boat",:qty => "1",:amount => "800.12",:discounted => "false",:ref1 => "ref3",:ref2 => "ref4",:description => "Red rowing boat",:taxoverridetypeline => "None",:taxamountline => "0",:taxdateline => "1900-01-01",:taxincluded => "false"}
85
- ]
86
- document[:detaillevel] = "Tax" #The level of detail you want returned by the service
87
- document[:referencecode] = "" #Reference code - used for returns
88
- document[:hashcode] = "0" #Set to 0
89
- document[:locationcode] = "" #Store Location, Outlet Id, or Outlet code.
90
- document[:commit] = "false" #Invoice will be committed if this flag has been set to true.
91
- document[:batchcode] = "" #Optional Batch Code
92
- document[:taxoverridetype] = "None" #Type of TaxOverride
93
- document[:taxamount]= ".0000" #The TaxAmount overrides the total tax for the document, if not 0
94
- document[:taxdate] = "1900-01-01" #Tax Date is the date used to calculate tax
95
- document[:reason] = "" #Reason for applying TaxOverride. = ""
96
- document[:currencycode] = "USD" #3 character ISO 4217 currency code (for example, USD)
97
- document[:servicemode] = "Remote" #All lines are calculated by AvaTax remote server
98
- document[:paymentdate] = "2013-09-26" #Indicates the date payment was applied to this invoice
99
- document[:exchangerate] = ".0000" #Indicates the currency exchange rate
100
- document[:exchangerateeffdate] = "1900-01-01" #Indicates the effective date of the exchange rate.
101
- document[:poslanecode] = "" #Optional POS Lane Code
102
- document[:businessidentificationno] = "" #Optional Business Identification Number
103
- document[:debug] = false #Run in debug move - writes data to tax_log.txt
104
- document[:validate]= false #If true - addresses will be validated before the tax call
105
-
106
- #Create empty hash for the tax result details
107
- tax_result = Hash.new
108
-
109
- #Call the tax service
110
- tax_result = TaxServ.adjusttax(document)
111
-
112
- require 'pp'
113
- pp tax_result
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
data/test/test_gettax.rb DELETED
@@ -1,150 +0,0 @@
1
- #Load the Avalara Address Service module
2
- require 'avatax_taxservice'
3
- #Load the Avalara Address Service module - optional
4
- require 'avatax_addressservice'
5
-
6
- #Create new credentials hash object
7
- credentials = Hash.new
8
-
9
- #Create new document hash object
10
- document = Hash.new
11
-
12
- #Create new address hash object
13
- address = Hash.new
14
-
15
- credentials[:username] = 'USERNAME'
16
- credentials[:password] = 'PASSWORD'
17
- credentials[:name] = 'Avalara Inc.'
18
- credentials[:clientname] = ''
19
- credentials[:adapter] = ''
20
- credentials[:machine] = 'Lenovo W520 Windows 7'
21
- # Determine whether the DEV or PROD service is used. false = DEV true = PROD
22
- credentials[:use_production_account] = false
23
-
24
- #Create a tax service instance
25
- TaxServ = AvaTax::TaxService.new(credentials)
26
-
27
- #Create an address service instance
28
- AddrService = AvaTax::AddressService.new(credentials)
29
-
30
- #Populate the fields required by the GetTax call
31
- document[:companycode] = 'APITrialCompany'
32
- document[:doctype] = 'SalesOrder'
33
- document[:doccode] = "MyDocCode100"
34
- document[:docdate] = "2013-10-11"
35
- document[:salespersoncode] = "Bill Sales"
36
- document[:customercode] = "CUS001"
37
- document[:customerusagetype] = ""
38
- document[:discount] = ".0000"
39
- document[:purchaseorderno]= "PO123456"
40
- document[:exemptionno] = ""
41
- document[:origincode] = "123"
42
- document[:destinationcode] = "456"
43
-
44
- #Pass addresses as an array of hashes
45
- # <AddressCode>123</AddressCode>
46
- # <Line1>100 Ravine Lane</Line1>
47
- # <Line2/>
48
- # <Line3/>
49
- # <City>Bainbridge Island</City>
50
- # <Region>WA</Region>
51
- # <PostalCode>98110</PostalCode>
52
- # <Country>US</Country>
53
- # <TaxRegionId>0</TaxRegionId>
54
- # <Latitude/>
55
- # <Longitude/>
56
- document[:addresses]= [
57
- {:addresscode => "123",:line1 => "100 ravine lane", :line2 => "Suite 21",:city => "Bainbridge Island",:region => "WA",:postalcode => "98110",:country => "US",:taxregionid => "0",:latitude => "",:longitude => ""},
58
- {:addresscode => "456",:line1 => "9436 NE Blue Wave Ct",:city => "Bainbridge Island",:region => "WA",:postalcode => "98110",:country => "US",:taxregionid => "0"}
59
- ]
60
-
61
- #Pass order/invoice lines as an array of hashes
62
- # <No>1</No>
63
- # <OriginCode></OriginCode>
64
- # <DestinationCode></DestinationCode>
65
- # <ItemCode>Canoe</ItemCode>
66
- # <TaxCode></TaxCode>
67
- # <Qty>1</Qty>
68
- # <Amount>300</Amount>
69
- # <Discounted>false</Discounted>
70
- # <RevAcct></RevAcct>
71
- # <Ref1>ref1</Ref1>
72
- # <Ref2>ref2</Ref2>
73
- # <ExemptionNo></ExemptionNo>
74
- # <CustomerUsageType></CustomerUsageType>
75
- # <Description>Blue canoe</Description>
76
- # <TaxOverrideType>TaxAmount</TaxOverrideType>
77
- # <TaxAmount>10</TaxAmount>
78
- # <TaxDate>1900-01-01</TaxDate>
79
- # <Reason>Tax Credit</Reason>
80
- # <TaxIncluded>false</TaxIncluded>
81
- # <BusinessIdentificationNo></BusinessIdentificationNo>
82
- document[:lines] = [
83
- {:no => "1",:itemcode => "Canoe",:qty => "1",:amount => "300.43",:discounted => "false",:ref1 => "ref1",:ref2 => "ref2",:description => "Blue canoe",:taxoverridetypeline => "TaxAmount",:taxamountline => "10",:taxdateline => "1900-01-01",:reasonline => "Tax credit",:taxincluded => "false"},
84
- {:no => "2",:itemcode => "Rowing boat",:qty => "1",:amount => "800.12",:discounted => "false",:ref1 => "ref3",:ref2 => "ref4",:description => "Red rowing boat",:taxoverridetypeline => "None",:taxamountline => "0",:taxdateline => "1900-01-01",:taxincluded => "false"}
85
- ]
86
- document[:detaillevel] = "Tax" #The level of detail you want returned by the service
87
- document[:referencecode] = "" #Reference code - used for returns
88
- document[:hashcode] = "0" #Set to 0
89
- document[:locationcode] = "" #Store Location, Outlet Id, or Outlet code.
90
- document[:commit] = "false" #Invoice will be committed if this flag has been set to true.
91
- document[:batchcode] = "" #Optional Batch Code
92
- document[:taxoverridetype] = "None" #Type of TaxOverride
93
- document[:taxamount]= ".0000" #The TaxAmount overrides the total tax for the document, if not 0
94
- document[:taxdate] = "1900-01-01" #Tax Date is the date used to calculate tax
95
- document[:reason] = "" #Reason for applying TaxOverride. = ""
96
- document[:currencycode] = "USD" #3 character ISO 4217 currency code (for example, USD)
97
- document[:servicemode] = "Remote" #All lines are calculated by AvaTax remote server
98
- document[:paymentdate] = "2013-09-26" #Indicates the date payment was applied to this invoice
99
- document[:exchangerate] = ".0000" #Indicates the currency exchange rate
100
- document[:exchangerateeffdate] = "1900-01-01" #Indicates the effective date of the exchange rate.
101
- document[:poslanecode] = "" #Optional POS Lane Code
102
- document[:businessidentificationno] = "" #Optional Business Identification Number
103
- document[:debug] = false #Run in debug move - writes data to tax_log.txt
104
- document[:validate]= false #If true - addresses will be validated before the tax call
105
-
106
-
107
- #Create empty hash for the tax result details
108
- tax_result = Hash.new
109
-
110
- #Call the Avatax tax service
111
- tax_result = TaxServ.gettax(document)
112
-
113
- #Print out the returned hash
114
- require 'pp'
115
- pp tax_result
116
- puts
117
-
118
- puts "Result Code = #{tax_result[:get_tax_result][:result_code]}"
119
- puts "Total Taxable = #{tax_result[:get_tax_result][:total_taxable]}"
120
- puts "Total Tax = #{tax_result[:get_tax_result][:total_tax]}"
121
- puts
122
- #Get total taxable
123
- puts tax_result[:get_tax_result][:total_taxable]
124
- puts
125
-
126
- #Get first tax line
127
- pp tax_result[:get_tax_result][:tax_lines][:tax_line][0]
128
-
129
- puts
130
- #Get tax details for line 2
131
- pp tax_result[:get_tax_result][:tax_lines][:tax_line][1][:tax_details]
132
-
133
- puts
134
- #Get tax line 2 .. first level of tax detail
135
- pp tax_result[:get_tax_result][:tax_lines][:tax_line][1][:tax_details][:tax_detail][0]
136
-
137
- puts
138
- #Get tax line 2 - country
139
- pp tax_result[:get_tax_result][:tax_lines][:tax_line][1][:tax_details][:tax_detail][0][:country]
140
-
141
-
142
- if tax_result[:get_tax_result][:result_code] == "Success" then
143
- puts "The GetTax call was successful"
144
- else
145
- puts "The GetTax call failed"
146
- end
147
-
148
-
149
-
150
-
@@ -1,55 +0,0 @@
1
- #Load the Avalara Address Service module
2
- require 'avatax_taxservice'
3
-
4
- #Create new credentials hash object
5
- credentials = Hash.new
6
-
7
- #Create new document hash object
8
- document = Hash.new
9
-
10
- credentials[:username] = 'USERNAME'
11
- credentials[:password] = 'PASSWORD'
12
- credentials[:name] = 'Avalara Inc.'
13
- credentials[:clientname] = 'MyShoppingCart'
14
- credentials[:adapter] = 'Avatax SDK for Ruby 1.0.6'
15
- credentials[:machine] = 'Lenovo W520 Windows 7'
16
- # Determine whether the DEV or PROD service is used. false = DEV true = PROD
17
- credentials[:use_production_account] = false
18
-
19
- #Create a tax service instance
20
- TaxServ = AvaTax::TaxService.new(credentials)
21
-
22
- document[:docid] = ""
23
- document[:companycode] = 'APITrialCompany'
24
- document[:doctype] = 'SalesInvoice'
25
- document[:doccode] = "MyDocCode100"
26
- document[:detaillevel] = "Line"
27
- document[:debug] = true
28
-
29
- #Create empty hash for the tax result details
30
- tax_result = Hash.new
31
-
32
- #Call the gettax service
33
- tax_result = TaxServ.gettaxhistory(document)
34
-
35
- require 'pp'
36
- pp tax_result
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
@@ -1,63 +0,0 @@
1
- #Load the Avalara Address Service module
2
- require 'avatax_taxservice'
3
-
4
- #Create new credentials hash object
5
- credentials = Hash.new
6
-
7
- #Create new document hash object
8
- document = Hash.new
9
-
10
- credentials[:username] = 'USERNAME'
11
- credentials[:password] = 'PASSWORD'
12
- credentials[:name] = 'Avalara Inc.'
13
- credentials[:clientname] = 'MyShoppingCart'
14
- credentials[:adapter] = 'Avatax SDK for Ruby 1.0.6'
15
- credentials[:machine] = 'Lenovo W520 Windows 7'
16
- # Determine whether the DEV or PROD service is used. false = DEV true = PROD
17
- credentials[:use_production_account] = false
18
-
19
- #Create a tax service instance
20
- TaxServ = AvaTax::TaxService.new(credentials)
21
-
22
- document[:companycode] = 'APITrialCompany'
23
- document[:lastdocid] = '99999999'
24
- document[:reconciled] = false
25
- document[:startdate] = '2013-01-01'
26
- document[:enddate] = '2013-10-15'
27
- document[:docstatus] = "Any"
28
- document[:doctype] = 'SalesInvoice'
29
- document[:lastdoccode] = ''
30
- document[:pagesize] = '1'
31
- document[:debug] = true
32
-
33
- #Create empty hash for the tax result details
34
- tax_result = Hash.new
35
-
36
- #Call the gettax service
37
- tax_result = TaxServ.reconciletaxhistory(document)
38
-
39
- require 'pp'
40
- pp tax_result
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-