-
Notifications
You must be signed in to change notification settings - Fork 5
/
GetTaxTest.html
123 lines (111 loc) · 3.39 KB
/
GetTaxTest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<html>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="AvaTax.js"></script>
<script type="text/javascript">
var getTaxRequest = {
customerCode: "ABC4335",
docDate: "2014-01-01",
companyCode: "APITrialCompany",
client: "AvaTaxSample",
docCode: "INV001",
detailLevel: "Tax",
commit: "false",
docType: "SalesInvoice",
// Situational Request Document Parameters
// customerUsageType: "G",
// exemptionNo: "12345",
// discount: "50",
// taxOverride: {
// taxOverrideType: "TaxDate",
// reason: "Adjustment for return",
// taxDate: "2013-07-01",
// taxAmount: "0",
// },
//Optional Request Parameters
purchaseOrderNo: "PO123456",
referenceCode: "ref123456",
posLaneCode: "09",
currencyCode: "USD",
addresses: [
{
addressCode: "01",
line1: "45 Fremont Street",
city: "San Francisco",
region: "CA" },
{
addressCode: "02",
line1: "118 N Clark St",
line2: "Suite 100",
line3: "ATTN Accounts Payable",
city: "Chicago",
region: "IL",
country: "US",
postalCode: "60602" },
{
addressCode: "03",
latitude: "47.627935",
longitude: "-122.51702" }
],
lines: [
{
lineNo: "01",
itemCode: "N543",
qty: "1",
amount: "10",
originCode: "01",
destinationCode: "02",
description: "Red Size 7 Widget",
taxCode: "NT",
// Situational Request Parameters
// customerUsageType: "L",
// discounted: "true",
// taxIncluded: "true",
// taxOverride:
// {
// taxOverrideType: "TaxDate",
// reason: "Adjustment for return",
// taxDate: "2013-07-01",
// taxAmount: "0" },
ref1: "ref123",
ref2: "ref456" },
{
lineNo: "02",
itemCode: "T345",
qty: "3",
amount: "150",
originCode: "01",
destinationCode: "03",
description: "Size 10 Green Running Shoe",
taxCode: "PC030147" },
{
lineNo: "02-FR",
itemCode: "FREIGHT",
qty: "1",
amount: "15",
originCode: "01",
destinationCode: "03",
description: "Shipping Charge",
taxCode: "FR" },
],
};
GetTax(getTaxRequest, function(getTaxResult) {
//Print Results
document.write('GetTaxTest Result: ' + getTaxResult.ResultCode + "<br/>");
if(getTaxResult.ResultCode != 'Success') {
for (var i = 0; i < getTaxResult.Messages.length ; i++) {
document.write(getTaxResult.Messages[i].Summary+ "<br/>");
}
} else {
document.write("Document Code: " + getTaxResult.DocCode + " Total Tax: " + getTaxResult.TotalTax + "<br/>");
for (var i = 0; i < getTaxResult.TaxLines.length; i++) {
document.write( " " + "Line Number: " + getTaxResult.TaxLines[i].LineNo + " Line Tax: " + getTaxResult.TaxLines[i].Tax + "<br/>");
for (var j = 0; j< getTaxResult.TaxLines[i].TaxDetails.length; j++) {
document.write(" " + "Jurisdiction: " + getTaxResult.TaxLines[i].TaxDetails[j].JurisName + " Tax: " + getTaxResult.TaxLines[i].TaxDetails[j].Tax + "<br/>");
}
}
}
});
</script>
</body>
</html>