This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinvoice_test.go
271 lines (259 loc) · 7.19 KB
/
invoice_test.go
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
package opendsd_test
import (
"bytes"
"fmt"
"log"
"net/http"
"net/http/httptest"
"testing"
"github.com/scoutred/opendsd"
)
var invoiceTestData = `
{
"InvoiceId": 483626,
"Status": "Paid",
"IssueDate": "2013-04-10T15:02:18",
"IssuedBy": "Huff, Sandra",
"CustomerName": "Cobian, Neva ",
"CustomerFirmName": "RBF Consulting",
"TotalAmount": 19207.0,
"PaidDate": "2013-04-10T15:58:57",
"ReverseDate": null,
"InvoiceTotalAmount": null,
"Header": [{
"Jurisdiction": "City of San Diego",
"Agency": "Development Services Department",
"AgencyAddress": "1222 First Ave, San Diego, CA 92101",
"AgencyWebsite": "www.sandiego.gov",
"ExtractSystem": "Extract System",
"ExtractDate": "11/7/2016 7:40:25 PM",
"ExtractQuery": "Invoice XML"
}],
"InvoiceNotes": [{
"InvoiceId": 483626,
"NoteId": 1,
"Note": "Upon payment of any Development Impact Fees (DIF), Regional Transportation Congestion Improvement Program (RTCIP), or Facilities Benefit Assessment (FBA) fees, the 90-day protest period in which you may protest these fees under Government Code section 66020 will begin. A written protest must be filed with the City Clerk pursuant to Government Code section 66020. The protest procedures under section 66020 are additional to other procedures authorized or required under the San Diego Municipal Code. Please contact Facilities Financing at 619-533-3670 to request additional information."
}],
"ProjectDetails": [{
"Jobs": [],
"ProjectFees": [{
"InvoiceDetialId": 3694253,
"InvoiceId": 483626,
"ProjectId": 319781,
"JobId": null,
"ApprovalId": null,
"FeeTypeId": 4440,
"FeeDescription": "Close Out -Engineering/Mapping",
"FeeQuantityRequired": "1",
"FeeTypeUnit": "Each",
"FeeAmount": 262.0,
"PreviousCreditInv": "",
"FeeAuthority": "Municipal Code",
"InvoiceCalcRules": [{
"InvoiceDetailId": 3694253,
"FeeThresholdId": 30076,
"BaseQuantity": "0",
"BaseIncrement": "1",
"RuleRate": "262",
"RuleRateAmt": 0.0,
"FeeRule": "$262 each = $262.00",
"PreSurchargeAmt": 262.0,
"PreviousCreditAmt": "",
"FeeSurchargeRules": []
}]
}, {
"InvoiceDetialId": 3694254,
"InvoiceId": 483626,
"ProjectId": 319781,
"JobId": null,
"ApprovalId": null,
"FeeTypeId": 1656,
"FeeDescription": "Deposit Account",
"FeeQuantityRequired": "18600",
"FeeTypeUnit": "Dollars",
"FeeAmount": 18600.0,
"PreviousCreditInv": "",
"FeeAuthority": "Municipal Code",
"InvoiceCalcRules": [{
"InvoiceDetailId": 3694254,
"FeeThresholdId": 11213,
"BaseQuantity": "0",
"BaseIncrement": "0.01",
"RuleRate": "0.01",
"RuleRateAmt": 0.0,
"FeeRule": "$.01 for each .01 \"Dollars\" over 0 or portion thereof = $18,600.00",
"PreSurchargeAmt": 18600.0,
"PreviousCreditAmt": "",
"FeeSurchargeRules": []
}]
}, {
"InvoiceDetialId": 3694255,
"InvoiceId": 483626,
"ProjectId": 319781,
"JobId": null,
"ApprovalId": null,
"FeeTypeId": 2347,
"FeeDescription": "General Plan Maintenance",
"FeeQuantityRequired": "1",
"FeeTypeUnit": "Each",
"FeeAmount": 275.0,
"PreviousCreditInv": "",
"FeeAuthority": "Municipal Code",
"InvoiceCalcRules": [{
"InvoiceDetailId": 3694255,
"FeeThresholdId": 29736,
"BaseQuantity": "0",
"BaseIncrement": "1",
"RuleRate": "275",
"RuleRateAmt": 0.0,
"FeeRule": "$275 each = $275.00",
"PreSurchargeAmt": 275.0,
"PreviousCreditAmt": "",
"FeeSurchargeRules": []
}]
}, {
"InvoiceDetialId": 3694256,
"InvoiceId": 483626,
"ProjectId": 319781,
"JobId": null,
"ApprovalId": null,
"FeeTypeId": 2385,
"FeeDescription": "Mapping",
"FeeQuantityRequired": "1",
"FeeTypeUnit": "Each",
"FeeAmount": 10.0,
"PreviousCreditInv": "",
"FeeAuthority": "Municipal Code",
"InvoiceCalcRules": [{
"InvoiceDetailId": 3694256,
"FeeThresholdId": 1925,
"BaseQuantity": "0",
"BaseIncrement": "1",
"RuleRate": "10",
"RuleRateAmt": 0.0,
"FeeRule": "$10 each = $10.00",
"PreSurchargeAmt": 10.0,
"PreviousCreditAmt": "",
"FeeSurchargeRules": []
}]
}, {
"InvoiceDetialId": 3694257,
"InvoiceId": 483626,
"ProjectId": 319781,
"JobId": null,
"ApprovalId": null,
"FeeTypeId": 3784,
"FeeDescription": "Records-Prelim(MF)",
"FeeQuantityRequired": "1",
"FeeTypeUnit": "Each",
"FeeAmount": 60.0,
"PreviousCreditInv": "",
"FeeAuthority": "CC Ordinance R-305326 - Bulltn:",
"InvoiceCalcRules": [{
"InvoiceDetailId": 3694257,
"FeeThresholdId": 27839,
"BaseQuantity": "0",
"BaseIncrement": "1",
"RuleRate": "60",
"RuleRateAmt": 0.0,
"FeeRule": "$60 each = $60.00",
"PreSurchargeAmt": 60.0,
"PreviousCreditAmt": "",
"FeeSurchargeRules": []
}]
}],
"ProjectId": 319781,
"Title": "Kaiser SD PI/Grading/Ded",
"Scope": "KEARNY MESA Grading and public improvement, and public right of way dedication and Street Name for the new Kaiser Hospital. ",
"ApplicationExpiration": "2014-04-11T17:00:00",
"ApplicationExpired": true,
"AdminHold": false,
"DevelopmentId": 176644,
"DevelopmentTitle": "Kaiser Hospital",
"ApplicationDate": "2013-04-11T17:00:00",
"AccountNum": "24003691",
"JobOrderNum": null,
"ProjectFeesTotal": 19207.0,
"ProjectFeesSubTotal": 19207.0,
"ProjectManagerId": 3329,
"ProjectManager": {
"ProjectManagerId": 3329,
"Name": "Lynch, Pete",
"PhoneNum": "",
"EmailAddress": "[email protected]",
"ActiveIndicator": true
}
}],
"InvoiceRevenue": [{
"InvoiceId": null,
"FundNum": "100000",
"GLNum": "416158",
"CostObjectNum": "1619110011",
"Fund": "GENERAL FUND",
"GL": "DSD APPL FEE XFER-PLANNG",
"Amount": 275.0
}, {
"InvoiceId": null,
"FundNum": "200459",
"GLNum": "422020",
"CostObjectNum": "1611170012",
"Fund": "DEPOSITS",
"GL": "PLANNING SUBDIVISION DPST",
"Amount": 18600.0
}, {
"InvoiceId": null,
"FundNum": "700036",
"GLNum": "416090",
"CostObjectNum": "1611000013",
"Fund": "PLANNING & DEVEL REV ENTR FUND",
"GL": "STREET ADDRESS CHANGE FEE",
"Amount": 10.0
}, {
"InvoiceId": null,
"FundNum": "700036",
"GLNum": "422043",
"CostObjectNum": "1611120011",
"Fund": "PLANNING & DEVEL REV ENTR FUND",
"GL": "OTHER FEES",
"Amount": 262.0
}, {
"InvoiceId": null,
"FundNum": "700036",
"GLNum": "423011",
"CostObjectNum": "1611000015",
"Fund": "PLANNING & DEVEL REV ENTR FUND",
"GL": "Sale of Publications",
"Amount": 60.0
}]
}`
func TestDecodeInvoice(t *testing.T) {
var err error
buf := bytes.NewBufferString(invoiceTestData)
invoice, err := opendsd.DecodeInvoice(buf)
if err != nil {
t.Errorf("error parsing: %v", err)
}
log.Printf("invoice %+v", invoice)
}
func TestInvoiceByID(t *testing.T) {
var err error
// setup test muxer
mux := http.NewServeMux()
// register our test route
mux.HandleFunc("/invoice/483626",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, invoiceTestData)
},
)
// setup test server
server := httptest.NewServer(mux)
// setup test client
client := opendsd.NewClient()
// use the generated testing url
client.APIRoot = server.URL
invoice, err := client.InvoiceByID(483626)
if err != nil {
t.Errorf("InvoiceByID error: %v", err)
}
log.Printf("invoice %+v", invoice)
}