Avatax_TaxService 1.0.1
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/Avatax Ruby SDK Guide.docx +0 -0
- data/Avatax_TaxService.gemspec +22 -0
- data/LICENSE.txt +21 -0
- data/lib/avatax_taxservice.rb +965 -0
- data/lib/tax_log.txt +0 -0
- data/lib/taxservice_dev.wsdl +1091 -0
- data/lib/taxservice_prd.wsdl +1091 -0
- data/lib/template_adjusttax.erb +101 -0
- data/lib/template_canceltax.erb +30 -0
- data/lib/template_committax.erb +31 -0
- data/lib/template_gettax.erb +97 -0
- data/lib/template_gettaxhistory.erb +29 -0
- data/lib/template_isauthorized.erb +22 -0
- data/lib/template_ping.erb +22 -0
- data/lib/template_posttax.erb +26 -0
- data/lib/template_reconciletaxhistory.erb +32 -0
- data/lib/xpath_adjtax.txt +74 -0
- data/lib/xpath_cancel.txt +10 -0
- data/lib/xpath_commit.txt +10 -0
- data/lib/xpath_gettax.txt +74 -0
- data/lib/xpath_gettaxhistory.txt +128 -0
- data/lib/xpath_isauthorized.txt +4 -0
- data/lib/xpath_ping.txt +9 -0
- data/lib/xpath_post.txt +9 -0
- data/lib/xpath_reconciletaxhistory.txt +31 -0
- data/test/test_adjtax.rb +116 -0
- data/test/test_gettax.rb +191 -0
- data/test/test_gettaxhistory.rb +50 -0
- data/test/test_reconciletaxhistory.rb +77 -0
- metadata +112 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
//TransactionId
|
2
|
+
//ResultCode
|
3
|
+
//Summary
|
4
|
+
//Details
|
5
|
+
//HelpLink
|
6
|
+
//RefersTo
|
7
|
+
//Severity
|
8
|
+
//Source
|
9
|
+
//GetTaxResult/DocId
|
10
|
+
//GetTaxResult/DocType
|
11
|
+
//GetTaxResult/DocCode
|
12
|
+
//GetTaxResult/DocDate
|
13
|
+
//GetTaxResult/DocStatus
|
14
|
+
//GetTaxResult/Reconciled
|
15
|
+
//GetTaxResult/Timestamp
|
16
|
+
//GetTaxResult/TotalAmount
|
17
|
+
//GetTaxResult/TotalDiscount
|
18
|
+
//GetTaxResult/TotalExemption
|
19
|
+
//GetTaxResult/TotalTaxable
|
20
|
+
//GetTaxResult/TotalTax
|
21
|
+
//GetTaxResult/TotalTaxCalculated
|
22
|
+
//GetTaxResult/HashCode
|
23
|
+
//TaxLine/No
|
24
|
+
//TaxLine/TaxCode
|
25
|
+
//TaxLine/Taxability
|
26
|
+
//TaxLine/BoundaryLevel
|
27
|
+
//TaxLine/Exemption
|
28
|
+
//TaxLine/Discount
|
29
|
+
//TaxLine/Taxable
|
30
|
+
//TaxLine/Rate
|
31
|
+
//TaxLine/Tax
|
32
|
+
//TaxLine/TaxCalculated
|
33
|
+
//TaxLine/TaxIncluded
|
34
|
+
//TaxDetail/Country
|
35
|
+
//TaxDetail/Region
|
36
|
+
//TaxDetail/JurisType
|
37
|
+
//TaxDetail/TaxType
|
38
|
+
//TaxDetail/Base
|
39
|
+
//TaxLine/Taxable
|
40
|
+
//TaxDetail/Rate
|
41
|
+
//TaxDetail/Tax
|
42
|
+
//TaxDetail/TaxCalculated
|
43
|
+
//TaxDetail/NonTaxable
|
44
|
+
//TaxDetail/Exemption
|
45
|
+
//TaxDetail/JurisName
|
46
|
+
//TaxDetail/TaxName
|
47
|
+
//TaxDetail/TaxAuthorityType
|
48
|
+
//TaxDetail/TaxGroup
|
49
|
+
//TaxDetail/RateType
|
50
|
+
//TaxDetail/StateAssignedNo
|
51
|
+
//TaxLine/ExemptCertId
|
52
|
+
//TaxLine/TaxDate
|
53
|
+
//TaxLine/ReportingDate
|
54
|
+
//TaxLine/AccountingMethod
|
55
|
+
//TaxAddress/Address
|
56
|
+
//TaxAddress/AddressCode
|
57
|
+
//TaxAddress/City
|
58
|
+
//TaxAddress/Country
|
59
|
+
//TaxAddress/PostalCode
|
60
|
+
//TaxAddress/Region
|
61
|
+
//TaxAddress/TaxRegionId
|
62
|
+
//TaxAddress/JurisCode
|
63
|
+
//TaxAddress/Latitude
|
64
|
+
//TaxAddress/Longitude
|
65
|
+
//TaxAddress/GeocodeType
|
66
|
+
//TaxAddress/ValidateStatus
|
67
|
+
//TaxAddress/DistanceToBoundary
|
68
|
+
//GetTaxResult/Locked
|
69
|
+
//GetTaxResult/AdjustmentReason
|
70
|
+
//GetTaxResult/AdjustmentDescription
|
71
|
+
//GetTaxResult/Version
|
72
|
+
//GetTaxResult/TaxDate
|
73
|
+
//GetTaxResult/TaxSummary
|
74
|
+
//GetTaxResult/VolatileTaxRates
|
@@ -0,0 +1,128 @@
|
|
1
|
+
//TransactionId
|
2
|
+
//ResultCode
|
3
|
+
//Summary
|
4
|
+
//Details
|
5
|
+
//HelpLink
|
6
|
+
//RefersTo
|
7
|
+
//Severity
|
8
|
+
//Source
|
9
|
+
|
10
|
+
//GetTaxRequest/CompanyCode
|
11
|
+
//GetTaxRequest/DocType
|
12
|
+
//GetTaxRequest/DocType
|
13
|
+
//GetTaxRequest/DocCode
|
14
|
+
//GetTaxRequest/DocDate
|
15
|
+
//GetTaxRequest/SalesPerson
|
16
|
+
//GetTaxRequest/CustomerCode
|
17
|
+
//GetTaxRequest/CustomerUsageType
|
18
|
+
//GetTaxRequest/Discount
|
19
|
+
//GetTaxRequest/PurchaseOrderNo
|
20
|
+
//GetTaxRequest/ExemptionNo
|
21
|
+
//GetTaxRequest/OriginCode
|
22
|
+
//GetTaxRequest/DestinationCode
|
23
|
+
|
24
|
+
//GetTaxRequest//AddressCode
|
25
|
+
//GetTaxRequest//Line1
|
26
|
+
//GetTaxRequest//Line2
|
27
|
+
//GetTaxRequest//Line3
|
28
|
+
//GetTaxRequest//City
|
29
|
+
//GetTaxRequest//Region
|
30
|
+
//GetTaxRequest//PostalCode
|
31
|
+
//GetTaxRequest//Country
|
32
|
+
//GetTaxRequest//TaxRegionId
|
33
|
+
//GetTaxRequest//Latitude
|
34
|
+
//GetTaxRequest//Longitude
|
35
|
+
|
36
|
+
//GetTaxRequest//No
|
37
|
+
//GetTaxRequest//OriginCode
|
38
|
+
//GetTaxRequest//DestinationCode
|
39
|
+
//GetTaxRequest//ItemCode
|
40
|
+
//GetTaxRequest//TaxCode
|
41
|
+
//GetTaxRequest//Qty
|
42
|
+
//GetTaxRequest//Amount
|
43
|
+
//GetTaxRequest//Discounted
|
44
|
+
//GetTaxRequest//RevAcct
|
45
|
+
//GetTaxRequest//Ref1
|
46
|
+
//GetTaxRequest//Ref2
|
47
|
+
//GetTaxRequest//ExemptionNo
|
48
|
+
//GetTaxRequest//CustomerUsageType
|
49
|
+
//GetTaxRequest//Description
|
50
|
+
//GetTaxRequest//TaxIncluded
|
51
|
+
//GetTaxRequest//BusinessIdentificationNo
|
52
|
+
|
53
|
+
//GetTaxRequest/DetailLevel
|
54
|
+
//GetTaxRequest/ReferenceCode
|
55
|
+
//GetTaxRequest/HashCode
|
56
|
+
//GetTaxRequest/LocationCode
|
57
|
+
//GetTaxRequest/Commit
|
58
|
+
//GetTaxRequest/BatchCode
|
59
|
+
//GetTaxRequest/CurrencyCode
|
60
|
+
//GetTaxRequest/ServiceMode
|
61
|
+
//GetTaxRequest/PaymentDate
|
62
|
+
//GetTaxRequest/ExchangeRate
|
63
|
+
//GetTaxRequest/ExchangeRateEffDate
|
64
|
+
//GetTaxRequest/PosLaneCode
|
65
|
+
//GetTaxRequest/BusinessIdentificationNo
|
66
|
+
|
67
|
+
//GetTaxResult/TransactionId
|
68
|
+
//GetTaxResult/ResultCode
|
69
|
+
//GetTaxResult/Summary
|
70
|
+
//GetTaxResult/Details
|
71
|
+
//GetTaxResult/HelpLink
|
72
|
+
//GetTaxResult/RefersTo
|
73
|
+
//GetTaxResult/Severity
|
74
|
+
//GetTaxResult/Source
|
75
|
+
//GetTaxResult/DocId
|
76
|
+
//GetTaxResult/DocType
|
77
|
+
//GetTaxResult/DocCode
|
78
|
+
//GetTaxResult/DocDate
|
79
|
+
//GetTaxResult/DocStatus
|
80
|
+
//GetTaxResult/Reconciled
|
81
|
+
//GetTaxResult/Timestamp
|
82
|
+
//GetTaxResult/TotalAmount
|
83
|
+
//GetTaxResult/TotalDiscount
|
84
|
+
//GetTaxResult/TotalExemption
|
85
|
+
//GetTaxResult/TotalTaxable
|
86
|
+
//GetTaxResult/TotalTax
|
87
|
+
//GetTaxResult/TotalTaxCalculated
|
88
|
+
//GetTaxResult/HashCode
|
89
|
+
|
90
|
+
//GetTaxResult//No
|
91
|
+
//GetTaxResult//TaxCode
|
92
|
+
//GetTaxResult//Taxability
|
93
|
+
//GetTaxResult//Exemption
|
94
|
+
//GetTaxResult//Discount
|
95
|
+
//GetTaxResult//Taxable
|
96
|
+
//GetTaxResult//Rate
|
97
|
+
//GetTaxResult//Tax
|
98
|
+
//GetTaxResult//TaxCalculated
|
99
|
+
//GetTaxResult//TaxIncluded
|
100
|
+
//GetTaxResult//ExemptCertId
|
101
|
+
//GetTaxResult//TaxDate
|
102
|
+
//GetTaxResult//ReportingDate
|
103
|
+
//GetTaxResult//AccountingMethod
|
104
|
+
|
105
|
+
//GetTaxResult//TaxDetail/Country
|
106
|
+
//GetTaxResult//TaxDetail/Region
|
107
|
+
//GetTaxResult//TaxDetail/JurisType
|
108
|
+
//GetTaxResult//TaxDetail/TaxType
|
109
|
+
//GetTaxResult//TaxDetail/Base
|
110
|
+
//GetTaxResult//TaxDetail/Taxable
|
111
|
+
//GetTaxResult//TaxDetail/Rate
|
112
|
+
//GetTaxResult//TaxDetail/Tax
|
113
|
+
//GetTaxResult//TaxDetail/TaxCalculated
|
114
|
+
//GetTaxResult//TaxDetail/NonTaxable
|
115
|
+
//GetTaxResult//TaxDetail/Exemption
|
116
|
+
//GetTaxResult//TaxDetail/JurisName
|
117
|
+
//GetTaxResult//TaxDetail/TaxName
|
118
|
+
//GetTaxResult//TaxDetail/TaxAuthorityType
|
119
|
+
//GetTaxResult//TaxDetail/TaxGroup
|
120
|
+
//GetTaxResult//TaxDetail/RateType
|
121
|
+
//GetTaxResult//TaxDetail/StateAssignedNo
|
122
|
+
|
123
|
+
//GetTaxResult/Locked
|
124
|
+
//GetTaxResult/AdjustmentReason
|
125
|
+
//GetTaxResult/AdjustmentDescription
|
126
|
+
//GetTaxResult/Version
|
127
|
+
//GetTaxResult/TaxDate
|
128
|
+
//GetTaxResult/VolatileTaxRates
|
data/lib/xpath_ping.txt
ADDED
data/lib/xpath_post.txt
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
//TransactionId
|
2
|
+
//ResultCode
|
3
|
+
//Summary
|
4
|
+
//Details
|
5
|
+
//HelpLink
|
6
|
+
//RefersTo
|
7
|
+
//Severity
|
8
|
+
//Source
|
9
|
+
//GetTaxResult//DocId
|
10
|
+
//GetTaxResult//DocType
|
11
|
+
//GetTaxResult//DocCode
|
12
|
+
//GetTaxResult//DocDate
|
13
|
+
//GetTaxResult//DocStatus
|
14
|
+
//GetTaxResult//Reconciled
|
15
|
+
//GetTaxResult//Timestamp
|
16
|
+
//GetTaxResult//TotalAmount
|
17
|
+
//GetTaxResult//TotalDiscount
|
18
|
+
//GetTaxResult//TotalExemption
|
19
|
+
//GetTaxResult//TotalTaxable
|
20
|
+
//GetTaxResult//TotalTax
|
21
|
+
//GetTaxResult//TotalTaxCalculated
|
22
|
+
//GetTaxResult//HashCode
|
23
|
+
//GetTaxResult//Locked
|
24
|
+
//GetTaxResult//AdjustmentReason
|
25
|
+
//GetTaxResult//AdjustmentDescription
|
26
|
+
//GetTaxResult//Version
|
27
|
+
//GetTaxResult//TaxDate
|
28
|
+
//GetTaxResult//TaxSummary
|
29
|
+
//GetTaxResult//VolatileTaxRates
|
30
|
+
//LastDocId
|
31
|
+
//RecordCount
|
data/test/test_adjtax.rb
ADDED
@@ -0,0 +1,116 @@
|
|
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 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
|
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 = [
|
55
|
+
["123", "100 ravine lane", "", "","Bainbridge Island","WA","98110","US","0","",""],
|
56
|
+
["456", "1S278 Wenmoth", "", "","Batavia","IL","60510","US","0","",""]
|
57
|
+
]
|
58
|
+
|
59
|
+
lines = [["1","","","Canoe","","1","300","false","","ref1","ref2","","","Blue canoe","None",".0000","1900-01-01","","false",""],
|
60
|
+
["2","","","Rowing boat","","1","800","false","","ref3","ref4","","","Red rowing boat","None",".0000","1900-01-01","","false",""]
|
61
|
+
]
|
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)
|
100
|
+
|
101
|
+
require 'pp'
|
102
|
+
pp tax_result
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
data/test/test_gettax.rb
ADDED
@@ -0,0 +1,191 @@
|
|
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 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)
|
17
|
+
|
18
|
+
#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
|
31
|
+
#Pass addresses as an array
|
32
|
+
# <AddressCode>123</AddressCode>
|
33
|
+
# <Line1>100 Ravine Lane</Line1>
|
34
|
+
# <Line2/>
|
35
|
+
# <Line3/>
|
36
|
+
# <City>Bainbridge Island</City>
|
37
|
+
# <Region>WA</Region>
|
38
|
+
# <PostalCode>98110</PostalCode>
|
39
|
+
# <Country>US</Country>
|
40
|
+
# <TaxRegionId>0</TaxRegionId>
|
41
|
+
# <Latitude/>
|
42
|
+
# <Longitude/>
|
43
|
+
addresses = [
|
44
|
+
["123", "100 ravine lane", "", "","Bainbridge Island","WA","98110","US","0","",""],
|
45
|
+
["456", "7070 West Arlington Drive", "", "","Lakewood","CO","80123","US","0","",""]
|
46
|
+
]
|
47
|
+
#Pass order/invoice lines as an array
|
48
|
+
# <No>1</No>
|
49
|
+
# <OriginCode></OriginCode>
|
50
|
+
# <DestinationCode></DestinationCode>
|
51
|
+
# <ItemCode>Canoe</ItemCode>
|
52
|
+
# <TaxCode></TaxCode>
|
53
|
+
# <Qty>1</Qty>
|
54
|
+
# <Amount>300</Amount>
|
55
|
+
# <Discounted>false</Discounted>
|
56
|
+
# <RevAcct></RevAcct>
|
57
|
+
# <Ref1>ref1</Ref1>
|
58
|
+
# <Ref2>ref2</Ref2>
|
59
|
+
# <ExemptionNo></ExemptionNo>
|
60
|
+
# <CustomerUsageType></CustomerUsageType>
|
61
|
+
# <Description>Blue canoe</Description>
|
62
|
+
# <TaxOverrideType>TaxAmount</TaxOverrideType>
|
63
|
+
# <TaxAmount>10</TaxAmount>
|
64
|
+
# <TaxDate>1900-01-01</TaxDate>
|
65
|
+
# <Reason>Tax Credit</Reason>
|
66
|
+
# <TaxIncluded>false</TaxIncluded>
|
67
|
+
# <BusinessIdentificationNo></BusinessIdentificationNo>
|
68
|
+
lines = [
|
69
|
+
["1","","","Canoe","","1","300.43","false","","ref1","ref2","","","Blue canoe","TaxAmount","10","1900-01-01","Tax credit","false",""],
|
70
|
+
["2","","","Rowing boat","","1","800.12","false","","ref3","ref4","","","Red rowing boat","None",".0000","1900-01-01","","false",""]
|
71
|
+
]
|
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
|
91
|
+
|
92
|
+
#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)
|
127
|
+
|
128
|
+
#Print out the returned hash
|
129
|
+
require 'pp'
|
130
|
+
pp tax_result
|
131
|
+
puts
|
132
|
+
|
133
|
+
#Always check the result code
|
134
|
+
if tax_result[:ResultCode] = "Success" then
|
135
|
+
puts "The GetTax call was successful"
|
136
|
+
else
|
137
|
+
puts "The GetTax call failed"
|
138
|
+
end
|
139
|
+
|
140
|
+
puts
|
141
|
+
#Convert a hash value to Floating point
|
142
|
+
tt = tax_result[:GetTaxResultTotalTax].at(0).to_f
|
143
|
+
puts "Total tax = #{tt}"
|
144
|
+
|
145
|
+
#Use the size method to determine the no of entries associated with a symbol
|
146
|
+
puts tax_result[:TaxDetailTaxName].size
|
147
|
+
|
148
|
+
#Data elements begin at 0
|
149
|
+
puts tax_result[:TaxDetailTaxName][0]
|
150
|
+
puts tax_result[:TaxDetailTaxName][1]
|
151
|
+
|
152
|
+
tax_result[:TaxDetailJurisType].each do |type|
|
153
|
+
puts type
|
154
|
+
end
|
155
|
+
|
156
|
+
#Example of extracting the tax breakdown per line
|
157
|
+
no_of_lines = tax_result[:TaxLineNo].size
|
158
|
+
no_of_jurisdictions = tax_result[:TaxDetailCountry].size / no_of_lines
|
159
|
+
i = 0
|
160
|
+
while i < no_of_lines
|
161
|
+
puts
|
162
|
+
puts "Line = #{tax_result[:TaxLineNo][i]}"
|
163
|
+
j = 0
|
164
|
+
while j < no_of_jurisdictions
|
165
|
+
puts "Jurisdiction #{j+1} = #{tax_result[:TaxDetailJurisName][j]}"
|
166
|
+
puts "Tax name = #{tax_result[:TaxDetailTaxName][j]}"
|
167
|
+
puts "Taxable amount = #{tax_result[:TaxDetailBase][j]}"
|
168
|
+
puts "Tax rate = #{tax_result[:TaxDetailRate][j]}"
|
169
|
+
puts "Tax calculated = #{tax_result[:TaxDetailTaxCalculated][j]}"
|
170
|
+
puts
|
171
|
+
j += 1
|
172
|
+
end
|
173
|
+
i += 1
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|