Avatax_TaxService 1.0.4 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_adjtax.rb CHANGED
@@ -3,100 +3,108 @@ require 'avatax_taxservice'
3
3
  #Load the Avalara Address Service module
4
4
  require 'avatax_addressservice'
5
5
 
6
- #Create an tax service instance
7
- username = 'USERNAME' #Your user account number or name here
8
- password = 'PASSWORD' #The password that was e-mailed to you here
9
- name = 'Avalara Inc.'
10
- clientname = 'MyShoppingCart'
11
- adapter = 'Avatax SDK for Ruby 1.0.1'
12
- machine = 'Lenovo W520 Windows 7'
13
- TaxServ = AvaTax::TaxService.new(username,password,name,clientname,adapter,machine)
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
+
22
+ #Create a tax service instance
23
+ TaxServ = AvaTax::TaxService.new(credentials)
14
24
 
15
25
  #Create an address service instance
16
- AddrService = AvaTax::AddressService.new(username,password,name,clientname,adapter,machine)
17
-
18
- adjustmentreason = "5"
19
- adjustmentdescription = "Hey I adjusted the tax"
20
- companycode = 'APITrialCompany'
21
- doctype = "SalesInvoice"
22
- doccode = "MyTest01"
23
- docdate = "2013-10-11"
24
- salespersoncode = "Bob Sales"
25
- customercode = "CUS001"
26
- customerusagetype = ""
27
- discount = ".0000"
28
- purchaseorderno = "PO999999"
29
- exemptionno = ""
30
- origincode = "123"
31
- destinationcode = "456"
32
- addresses = []
33
- lines = []
34
- detaillevel = "Tax"
35
- referencecode = ""
36
- hashcode = "0"
37
- locationcode = ""
38
- commit = "true"
39
- batchcode = ""
40
- taxoverridetype = "None"
41
- taxamount = ".0000"
42
- taxdate = "1900-01-01"
43
- reason = ""
44
- currencycode = "USD"
45
- servicemode = "Remote"
46
- paymentdate = "2013-09-26"
47
- exchangerate = ".0000"
48
- exchangerateeffdate = "1900-01-01"
49
- poslanecode = ""
50
- businessidentificationno = ""
51
- debug = true
52
- validate = false
53
-
54
- addresses = [
26
+ AddrService = AvaTax::AddressService.new(credentials)
27
+
28
+ #Populate the fields required by the GetTax call
29
+ document[:adjustmentreason] = "5"
30
+ document[:adjustmentdescription] = "Hey I adjusted the tax"
31
+ document[:companycode] = 'APITrialCompany'
32
+ document[:doctype] = 'SalesInvoice'
33
+ document[:doccode] = "MyDocCode"
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
+ #Pass addresses as an array
44
+ # <AddressCode>123</AddressCode>
45
+ # <Line1>100 Ravine Lane</Line1>
46
+ # <Line2/>
47
+ # <Line3/>
48
+ # <City>Bainbridge Island</City>
49
+ # <Region>WA</Region>
50
+ # <PostalCode>98110</PostalCode>
51
+ # <Country>US</Country>
52
+ # <TaxRegionId>0</TaxRegionId>
53
+ # <Latitude/>
54
+ # <Longitude/>
55
+ document[:addresses] = [
55
56
  ["123", "100 ravine lane", "", "","Bainbridge Island","WA","98110","US","0","",""],
56
57
  ["456", "1S278 Wenmoth", "", "","Batavia","IL","60510","US","0","",""]
57
58
  ]
58
-
59
- lines = [["1","","","Canoe","","1","300","false","","ref1","ref2","","","Blue canoe","None",".0000","1900-01-01","","false",""],
59
+ #Pass order/invoice lines as an array
60
+ # <No>1</No>
61
+ # <OriginCode></OriginCode>
62
+ # <DestinationCode></DestinationCode>
63
+ # <ItemCode>Canoe</ItemCode>
64
+ # <TaxCode></TaxCode>
65
+ # <Qty>1</Qty>
66
+ # <Amount>300</Amount>
67
+ # <Discounted>false</Discounted>
68
+ # <RevAcct></RevAcct>
69
+ # <Ref1>ref1</Ref1>
70
+ # <Ref2>ref2</Ref2>
71
+ # <ExemptionNo></ExemptionNo>
72
+ # <CustomerUsageType></CustomerUsageType>
73
+ # <Description>Blue canoe</Description>
74
+ # <TaxOverrideType>TaxAmount</TaxOverrideType>
75
+ # <TaxAmount>10</TaxAmount>
76
+ # <TaxDate>1900-01-01</TaxDate>
77
+ # <Reason>Tax Credit</Reason>
78
+ # <TaxIncluded>false</TaxIncluded>
79
+ # <BusinessIdentificationNo></BusinessIdentificationNo>
80
+ document[:lines] = [["1","","","Canoe","","1","300","false","","ref1","ref2","","","Blue canoe","None",".0000","1900-01-01","","false",""],
60
81
  ["2","","","Rowing boat","","1","800","false","","ref3","ref4","","","Red rowing boat","None",".0000","1900-01-01","","false",""]
61
82
  ]
62
-
63
- tax_result = {}
64
- #Call the gettax service
65
- tax_result = TaxServ.adjusttax(adjustmentreason,
66
- adjustmentdescription,
67
- companycode,
68
- doctype,
69
- doccode,
70
- docdate,
71
- salespersoncode,
72
- customercode,
73
- customerusagetype,
74
- discount,
75
- purchaseorderno,
76
- exemptionno,
77
- origincode,
78
- destinationcode,
79
- addresses,
80
- lines,
81
- detaillevel,
82
- referencecode,
83
- hashcode,
84
- locationcode,
85
- commit,
86
- batchcode,
87
- taxoverridetype,
88
- taxamount,
89
- taxdate,
90
- reason,
91
- currencycode,
92
- servicemode,
93
- paymentdate,
94
- exchangerate,
95
- exchangerateeffdate,
96
- poslanecode,
97
- businessidentificationno,
98
- debug,
99
- validate)
83
+ document[:detaillevel] = "Tax" #The level of detail you want returned by the service
84
+ document[:referencecode] = "" #Reference code - used for returns
85
+ document[:hashcode] = "0" #Set to 0
86
+ document[:locationcode] = "" #Store Location, Outlet Id, or Outlet code.
87
+ document[:commit] = "false" #Invoice will be committed if this flag has been set to true.
88
+ document[:batchcode] = "" #Optional Batch Code
89
+ document[:taxoverridetype] = "None" #Type of TaxOverride
90
+ document[:taxamount]= ".0000" #The TaxAmount overrides the total tax for the document, if not 0
91
+ document[:taxdate] = "1900-01-01" #Tax Date is the date used to calculate tax
92
+ document[:reason] = "" #Reason for applying TaxOverride. = ""
93
+ document[:currencycode] = "USD" #3 character ISO 4217 currency code (for example, USD)
94
+ document[:servicemode] = "Remote" #All lines are calculated by AvaTax remote server
95
+ document[:paymentdate] = "2013-09-26" #Indicates the date payment was applied to this invoice
96
+ document[:exchangerate] = ".0000" #Indicates the currency exchange rate
97
+ document[:exchangerateeffdate] = "1900-01-01" #Indicates the effective date of the exchange rate.
98
+ document[:poslanecode] = "" #Optional POS Lane Code
99
+ document[:businessidentificationno] = "" #Optional Business Identification Number
100
+ document[:debug] = false #Run in debug move - writes data to tax_log.txt
101
+ document[:validate]= false #If true - addresses will be validated before the tax call
102
+
103
+ #Create empty hash for the tax result details
104
+ tax_result = Hash.new
105
+
106
+ #Call the tax service
107
+ tax_result = TaxServ.gettax(document)
100
108
 
101
109
  require 'pp'
102
110
  pp tax_result
data/test/test_gettax.rb CHANGED
@@ -3,31 +3,42 @@ require 'avatax_taxservice'
3
3
  #Load the Avalara Address Service module - optional
4
4
  require 'avatax_addressservice'
5
5
 
6
- #Create an tax service instance
7
- username = 'USERNAME' #Your user account number or name here
8
- password = 'PASSWORD' #The password that was e-mailed to you here
9
- name = 'Avalara Inc.'
10
- clientname = 'MyShoppingCart'
11
- adapter = 'Avatax SDK for Ruby 1.0.1'
12
- machine = 'Lenovo W520 Windows 7'
13
- TaxServ = AvaTax::TaxService.new(username,password,name,clientname,adapter,machine)
14
-
15
- #Create an address service instance - optional
16
- AddrService = AvaTax::AddressService.new(username,password,name,clientname,adapter,machine)
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] = 'grahamw'
16
+ credentials[:password] = 'Avalara1!'
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
+
22
+ #Create a tax service instance
23
+ TaxServ = AvaTax::TaxService.new(credentials)
24
+
25
+ #Create an address service instance
26
+ AddrService = AvaTax::AddressService.new(credentials)
17
27
 
18
28
  #Populate the fields required by the GetTax call
19
- companycode = 'API TrialCompany' #Same as the company code you set in the Admin console
20
- doctype = "SalesInvoice" #The type of document you want to process
21
- doccode = "MyDocCode" #Your doc code (e.g. invoice number)
22
- docdate = "2013-10-11" #The date on the document
23
- salespersoncode = "Bill Sales" #Optional sales person
24
- customercode = "CUS001" #Customer code
25
- customerusagetype = "" #Usage type
26
- discount = ".0000" #Discount amount
27
- purchaseorderno = "PO123456" #PO number
28
- exemptionno = "" #Exemption number
29
- origincode = "123" #Origin or ship from code - you make it up
30
- destinationcode = "456" #Destination or ship to code - you make it up
29
+ document[:companycode] = '1'
30
+ document[:doctype] = 'SalesInvoice'
31
+ document[:doccode] = "MyDocCode"
32
+ document[:docdate] = "2013-10-11"
33
+ document[:salespersoncode] = "Bill Sales"
34
+ document[:customercode] = "CUS001"
35
+ document[:customerusagetype] = ""
36
+ document[:discount] = ".0000"
37
+ document[:purchaseorderno]= "PO123456"
38
+ document[:exemptionno] = ""
39
+ document[:origincode] = "123"
40
+ document[:destinationcode] = "456"
41
+
31
42
  #Pass addresses as an array
32
43
  # <AddressCode>123</AddressCode>
33
44
  # <Line1>100 Ravine Lane</Line1>
@@ -40,10 +51,11 @@ destinationcode = "456" #Destination or ship to code - you make it u
40
51
  # <TaxRegionId>0</TaxRegionId>
41
52
  # <Latitude/>
42
53
  # <Longitude/>
43
- addresses = [
54
+ document[:addresses]= [
44
55
  ["123", "100 ravine lane", "", "","Bainbridge Island","WA","98110","US","0","",""],
45
56
  ["456", "7070 West Arlington Drive", "", "","Lakewood","CO","80123","US","0","",""]
46
57
  ]
58
+
47
59
  #Pass order/invoice lines as an array
48
60
  # <No>1</No>
49
61
  # <OriginCode></OriginCode>
@@ -64,66 +76,37 @@ addresses = [
64
76
  # <TaxDate>1900-01-01</TaxDate>
65
77
  # <Reason>Tax Credit</Reason>
66
78
  # <TaxIncluded>false</TaxIncluded>
67
- # <BusinessIdentificationNo></BusinessIdentificationNo>
68
- lines = [
79
+ # <BusinessIdentificationNo></BusinessIdentificationNo>
80
+ document[:lines] = [
69
81
  ["1","","","Canoe","","1","300.43","false","","ref1","ref2","","","Blue canoe","TaxAmount","10","1900-01-01","Tax credit","false",""],
70
82
  ["2","","","Rowing boat","","1","800.12","false","","ref3","ref4","","","Red rowing boat","None",".0000","1900-01-01","","false",""]
71
83
  ]
72
- detaillevel = "Tax" #The level of detail you want returned by the service
73
- referencecode = "" #Reference code - used for returns
74
- hashcode = "0" #Set to 0
75
- locationcode = "" #Store Location, Outlet Id, or Outlet code.
76
- commit = "false" #Invoice will be committed if this flag has been set to true.
77
- batchcode = "" #Optional Batch Code
78
- taxoverridetype = "None" #Type of TaxOverride
79
- taxamount = ".0000" #The TaxAmount overrides the total tax for the document, if not 0
80
- taxdate = "1900-01-01" #Tax Date is the date used to calculate tax
81
- reason = "" #Reason for applying TaxOverride.
82
- currencycode = "USD" #3 character ISO 4217 currency code (for example, USD)
83
- servicemode = "Remote" #All lines are calculated by AvaTax remote server
84
- paymentdate = "2013-09-26" #Indicates the date payment was applied to this invoice
85
- exchangerate = ".0000" #Indicates the currency exchange rate
86
- exchangerateeffdate = "1900-01-01" #Indicates the effective date of the exchange rate.
87
- poslanecode = "" #Optional POS Lane Code
88
- businessidentificationno = "" #Optional Business Identification Number
89
- debug = false #Run in debug move - writes data to tax_log.txt
90
- validate = false #Performs address validation before calculating tax - needs address service installed
84
+ document[:detaillevel] = "Tax" #The level of detail you want returned by the service
85
+ document[:referencecode] = "" #Reference code - used for returns
86
+ document[:hashcode] = "0" #Set to 0
87
+ document[:locationcode] = "" #Store Location, Outlet Id, or Outlet code.
88
+ document[:commit] = "false" #Invoice will be committed if this flag has been set to true.
89
+ document[:batchcode] = "" #Optional Batch Code
90
+ document[:taxoverridetype] = "None" #Type of TaxOverride
91
+ document[:taxamount]= ".0000" #The TaxAmount overrides the total tax for the document, if not 0
92
+ document[:taxdate] = "1900-01-01" #Tax Date is the date used to calculate tax
93
+ document[:reason] = "" #Reason for applying TaxOverride. = ""
94
+ document[:currencycode] = "USD" #3 character ISO 4217 currency code (for example, USD)
95
+ document[:servicemode] = "Remote" #All lines are calculated by AvaTax remote server
96
+ document[:paymentdate] = "2013-09-26" #Indicates the date payment was applied to this invoice
97
+ document[:exchangerate] = ".0000" #Indicates the currency exchange rate
98
+ document[:exchangerateeffdate] = "1900-01-01" #Indicates the effective date of the exchange rate.
99
+ document[:poslanecode] = "" #Optional POS Lane Code
100
+ document[:businessidentificationno] = "" #Optional Business Identification Number
101
+ document[:debug] = true #Run in debug move - writes data to tax_log.txt
102
+ document[:validate]= false #If true - addresses will be validated before the tax call
103
+
91
104
 
92
105
  #Create empty hash for the tax result details
93
- tax_result = {}
94
- tax_result = TaxServ.gettax(companycode,
95
- doctype,
96
- doccode,
97
- docdate,
98
- salespersoncode,
99
- customercode,
100
- customerusagetype,
101
- discount,
102
- purchaseorderno,
103
- exemptionno,
104
- origincode,
105
- destinationcode,
106
- addresses,
107
- lines,
108
- detaillevel,
109
- referencecode,
110
- hashcode,
111
- locationcode,
112
- commit,
113
- batchcode,
114
- taxoverridetype,
115
- taxamount,
116
- taxdate,
117
- reason,
118
- currencycode,
119
- servicemode,
120
- paymentdate,
121
- exchangerate,
122
- exchangerateeffdate,
123
- poslanecode,
124
- businessidentificationno,
125
- debug,
126
- validate)
106
+ tax_result = Hash.new
107
+
108
+ #Call the tax service
109
+ tax_result = TaxServ.gettax(document)
127
110
 
128
111
  #Print out the returned hash
129
112
  require 'pp'
@@ -131,7 +114,7 @@ pp tax_result
131
114
  puts
132
115
 
133
116
  #Always check the result code
134
- if tax_result[:ResultCode] = "Success" then
117
+ if tax_result[:ResultCode] == ["Success"]
135
118
  puts "The GetTax call was successful"
136
119
  else
137
120
  puts "The GetTax call failed"
@@ -1,32 +1,34 @@
1
1
  #Load the Avalara Address Service module
2
2
  require 'avatax_taxservice'
3
3
 
4
- #Create an tax service instance
5
- username = 'USERNAME' #Your user account number or name here
6
- password = 'PASSSWORD' #The password that was e-mailed to you here
7
- name = 'Avalara Inc.'
8
- clientname = 'MyShoppingCart'
9
- adapter = 'Avatax SDK for Ruby 1.0.1'
10
- machine = 'Lenovo W520 Windows 7'
11
- TaxServ = AvaTax::TaxService.new(username,password,name,clientname,adapter,machine)
12
-
13
-
14
- docid = "99999999"
15
- companycode = 'APITrialCompany'
16
- doctype = "SalesInvoice"
17
- doccode = ""
18
- detaillevel = "Line"
19
- debug = false
20
-
21
- tax_result = {}
22
- #Call the gettax service
23
- tax_result = TaxServ.gettaxhistory(docid,
24
- companycode,
25
- doctype,
26
- doccode,
27
- detaillevel,
28
- debug)
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
+
17
+ #Create a tax service instance
18
+ TaxServ = AvaTax::TaxService.new(credentials)
29
19
 
20
+ document[:docid] = "99999999"
21
+ document[:companycode] = 'APITrialCompany'
22
+ document[:doctype] = 'SalesInvoice'
23
+ document[:doccode] = ""
24
+ document[:detaillevel] = "Line"
25
+ document[:debug] = false
26
+
27
+ #Create empty hash for the tax result details
28
+ tax_result = Hash.new
29
+
30
+ #Call the gettax service
31
+ tax_result = TaxServ.gettaxhistory(document)
30
32
 
31
33
  require 'pp'
32
34
  pp tax_result
@@ -1,39 +1,38 @@
1
1
  #Load the Avalara Address Service module
2
2
  require 'avatax_taxservice'
3
3
 
4
- #Create an tax service instance
5
- username = 'USERNAME' #Your user account number or name here
6
- password = 'PASSWORD' #The password that was e-mailed to you here
7
- name = 'Avalara Inc.'
8
- clientname = 'MyShoppingCart'
9
- adapter = 'Avatax SDK for Ruby 1.0.1'
10
- machine = 'Lenovo W520 Windows 7'
11
- TaxServ = AvaTax::TaxService.new(username,password,name,clientname,adapter,machine)
12
-
13
- companycode = 'APITrialCompany'
14
- lastdocid = "99999999"
15
- reconciled = false
16
- startdate = '2013-01-01'
17
- enddate = "2013-10-15"
18
- docstatus = "Any"
19
- doctype = "SalesInvoice"
20
- lastdoccode =""
21
- pagesize ="1"
22
- debug = true
23
-
24
- tax_result = []
25
- #Call the gettax service
26
- tax_result = TaxServ.reconciletaxhistory(companycode,
27
- lastdocid,
28
- reconciled,
29
- startdate,
30
- enddate,
31
- docstatus,
32
- doctype,
33
- lastdoccode,
34
- pagesize,
35
- debug)
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
+
17
+ #Create a tax service instance
18
+ TaxServ = AvaTax::TaxService.new(credentials)
19
+
20
+ document[:companycode] = 'APITrialCompany'
21
+ document[:lastdocid] = '99999999'
22
+ document[:reconciled] = false
23
+ document[:startdate] = '2013-01-01'
24
+ document[:enddate] = '2013-10-15'
25
+ document[:docstatus] = "Any"
26
+ document[:doctype] = 'SalesInvoice'
27
+ document[:lastdoccode] = ''
28
+ document[:pagesize] = '1'
29
+ document[:debug] = true
30
+
31
+ #Create empty hash for the tax result details
32
+ tax_result = Hash.new
36
33
 
34
+ #Call the gettax service
35
+ tax_result = TaxServ.reconciletaxhistory(document)
37
36
 
38
37
  require 'pp'
39
38
  pp tax_result