1 package com.instantbank.collections.creditInfo.web;
2
3 import java.io.ByteArrayInputStream;
4 import oracle.xml.parser.v2.DOMParser;
5 import oracle.xml.parser.v2.XMLDocument;
6 import oracle.xml.parser.v2.XMLElement;
7 import oracle.xml.parser.v2.XMLNode;
8 import oracle.xml.parser.v2.XSLException;
9 import java.text.ParsePosition;
10 import java.text.SimpleDateFormat;
11 import java.util.Date;
12 import com.instantbank.collections.util.DateUtils;
13 import com.instantbank.collections.util.StringFormat;
14
15 public class AccountDetailsTransformer {
16
17 private String accountDetailsXmlString;
18 private XMLDocument accountDetailsXml;
19 private XMLNode addressNode;
20 private XMLNode agreementDetailsNode;
21 private XMLNode collateralNode;
22 private XMLNode primaryNode;
23 private XMLNode statusValuesNode;
24 private XMLNode queueValuesNode;
25 private long lCompanyID = 0L;
26
27
28 public AccountDetailsTransformer() { }
29
30
31 public String get15Days() throws XSLException, Exception {
32 return agreementDetailsNode.valueOf("./del15");
33 }
34
35
36 public String get30Days() throws XSLException, Exception {
37 return agreementDetailsNode.valueOf("./del30");
38 }
39
40
41 public String get60Days() throws XSLException, Exception {
42 return agreementDetailsNode.valueOf("./del60");
43 }
44
45
46 public String get90Days() throws XSLException, Exception {
47 return agreementDetailsNode.valueOf("./del90");
48 }
49
50
51 public String getAccountNumber() throws XSLException, Exception {
52 return StringFormat.toSafeHTMLString(agreementDetailsNode.valueOf("./accountnumber"));
53 }
54
55
56 public String getAddressLine1() throws XSLException, Exception {
57 return StringFormat.toSafeHTMLString(addressNode.valueOf("./line1"));
58 }
59
60
61 public String getAddressLine2() throws XSLException, Exception {
62 return StringFormat.toSafeHTMLString(addressNode.valueOf("./line2"));
63 }
64
65
66 public String getAlert() throws XSLException, Exception {
67 return StringFormat.toSafeHTMLString(agreementDetailsNode.valueOf("./miscalert"));
68 }
69
70
71 public String getAPR() throws XSLException, Exception {
72 return collateralNode.valueOf("./apr");
73 }
74
75
76 public String getBalance() throws XSLException, Exception {
77 return agreementDetailsNode.valueOf("./finbalance");
78 }
79
80
81 public String getBooked() throws XSLException, Exception {
82 return collateralNode.valueOf("./datebooked");
83 }
84
85
86 public String getBroken() throws XSLException, Exception {
87 return agreementDetailsNode.valueOf("./promisesbroken");
88 }
89
90
91 public String getBusinessPhone() throws XSLException, Exception {
92 String extension = primaryNode.valueOf("./businessextension");
93 if((extension != null) && (!extension.equals(""))) {
94 extension = " Ext. " + extension;
95 }
96 return primaryNode.valueOf("./businessphone") + extension;
97 }
98
99
100 public String getCity() throws XSLException, Exception {
101 return StringFormat.toSafeHTMLString(addressNode.valueOf("./city"));
102 }
103
104
105 public String getCurrentQueues() throws XSLException, Exception {
106 return agreementDetailsNode.valueOf("./misccurrentqueues");
107 }
108
109
110 public String getDate() throws XSLException, Exception {
111 return agreementDetailsNode.valueOf("./misclasttreffectivedate");
112 }
113
114
115 public String getDelinquecy() throws XSLException, Exception {
116 return agreementDetailsNode.valueOf("./delinquency");
117 }
118
119
120 public String getEmail() throws XSLException, Exception {
121 return StringFormat.toSafeHTMLString(primaryNode.valueOf("./email"));
122 }
123
124
125 public String getMiddleName() throws XSLException, Exception {
126 return primaryNode.valueOf("./middlename");
127 }
128
129
130 public String getFirstName() throws XSLException, Exception {
131 return primaryNode.valueOf("./firstname");
132 }
133
134
135 public String getLastName() throws XSLException, Exception {
136 return primaryNode.valueOf("./lastname");
137 }
138
139
140 public String getGenerationCode() throws XSLException, Exception {
141 return primaryNode.valueOf("./generationcode");
142 }
143
144
145 public String getEmployer() throws XSLException, Exception {
146 return StringFormat.toSafeHTMLString(primaryNode.valueOf("./employer"));
147 }
148
149
150 public String getFinanced() throws XSLException, Exception {
151 return agreementDetailsNode.valueOf("./finfinanced");
152 }
153
154
155 public String getHomePhone() throws XSLException, Exception {
156 String homePhone = addressNode.valueOf("./homephone");
157 if((homePhone.equals("")) || (homePhone == null)) {
158 homePhone = primaryNode.valueOf("./homephone");
159 }
160 return homePhone;
161 }
162
163
164 public String getKept() throws XSLException, Exception {
165 return agreementDetailsNode.valueOf("./promiseskept");
166 }
167
168
169 public String getLastPaymentAmount() throws XSLException, Exception {
170 Float interestAmt = new Float(0);
171 Float fees = new Float(0);
172 boolean nullValue = false;
173 Float principalAmt = new Float(0);
174 String sumTotalStr = "";
175 if((agreementDetailsNode.valueOf("./misclasttrprincipal") != null) && (!agreementDetailsNode.valueOf("./misclasttrprincipal").equals(""))) {
176 principalAmt = new Float(agreementDetailsNode.valueOf("./misclasttrprincipal"));
177 }
178 else {
179 nullValue = true;
180 }
181 if((agreementDetailsNode.valueOf("./misclasttrinterest") != null) && (!agreementDetailsNode.valueOf("./misclasttrinterest").equals(""))) {
182 interestAmt = new Float(agreementDetailsNode.valueOf("./misclasttrinterest"));
183 nullValue = false;
184 }
185
186
187 if((agreementDetailsNode.valueOf("./misclasttrfees") != null) && (!agreementDetailsNode.valueOf("./misclasttrfees").equals(""))) {
188 fees = new Float(agreementDetailsNode.valueOf("./misclasttrfees"));
189 nullValue = false;
190 }
191
192 if(!nullValue) {
193 sumTotalStr = (new Float(principalAmt.floatValue() + interestAmt.floatValue()
194 + fees.floatValue())).toString();
195 }
196 else {
197 sumTotalStr = "";
198 }
199 return sumTotalStr;
200 }
201
202
203 public String getLateCharges() throws XSLException, Exception {
204 return agreementDetailsNode.valueOf("./finlatecharges");
205 }
206
207
208 public String getMake() throws XSLException, Exception {
209 return StringFormat.toSafeHTMLString(collateralNode.valueOf("./make"));
210 }
211
212
213 public String getMatDate() throws XSLException, Exception {
214 return agreementDetailsNode.valueOf("./finmaturitydate");
215 }
216
217
218 public String getMobilePhone() throws XSLException, Exception {
219 return primaryNode.valueOf("./mobilephone");
220 }
221
222
223 public String getModel() throws XSLException, Exception {
224 return StringFormat.toSafeHTMLString(collateralNode.valueOf("./model"));
225 }
226
227
228 public String getMoExt() throws XSLException, Exception {
229 return agreementDetailsNode.valueOf("./miscmonthsextended");
230 }
231
232
233 public String getNSFNo() throws XSLException, Exception {
234 return agreementDetailsNode.valueOf("./miscnonsf");
235 }
236
237
238 public String getOpen() throws XSLException, Exception {
239 return agreementDetailsNode.valueOf("./promisescurrent");
240 }
241
242
243 public String getPager() throws XSLException, Exception {
244 String pgCode = primaryNode.valueOf("./pagercode");
245 if((pgCode != null) && (!pgCode.equals(""))) {
246 pgCode = " Cod. " + pgCode;
247 }
248 return primaryNode.valueOf("./pagerphone") + pgCode;
249 }
250
251
252 public String getPartial() throws XSLException, Exception {
253 return agreementDetailsNode.valueOf("./finpartial");
254 }
255
256
257 public String getPastDueAmt() throws XSLException, Exception {
258 return agreementDetailsNode.valueOf("./finamountpastdue");
259 }
260
261
262 public String getPastDueNo() throws XSLException, Exception {
263 return agreementDetailsNode.valueOf("./finnopastdue");
264 }
265
266
267 public String getPayOff() throws XSLException, Exception {
268 return agreementDetailsNode.valueOf("./finpayoff");
269 }
270
271
272 public String getPayOffDate() throws XSLException, Exception {
273 return agreementDetailsNode.valueOf("./finpayoffdate");
274 }
275
276
277 public String getPrinDue() throws XSLException, Exception {
278 float fAmntPastDue = 0f;
279 float fFee = 0f;
280 float fPrinDue = 0f;
281 float fRegPymnt = 0f;
282 float fLateCharges = 0f;
283 float fPartial = 0f;
284 float fPayOffAmnt = 0f;
285
286
287 Date dtProc = DateUtils.processDate(lCompanyID);
288
289 int nDelinq = Integer.parseInt(agreementDetailsNode.valueOf("./delinquency"));
290
291 fRegPymnt = Float.parseFloat(agreementDetailsNode.valueOf("./finregularpayment"));
292 fPrinDue = Float.parseFloat(agreementDetailsNode.valueOf("./prindue"));
293 fAmntPastDue = Float.parseFloat(agreementDetailsNode.valueOf("./finamountpastdue"));
294 fFee = Float.parseFloat(agreementDetailsNode.valueOf("./fee"));
295 fLateCharges = Float.parseFloat(agreementDetailsNode.valueOf("./finlatecharges"));
296 fPartial = Float.parseFloat(agreementDetailsNode.valueOf("./finpartial"));
297
298 String sDate = agreementDetailsNode.valueOf("./finmaturitydate");
299 SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
300 Date dtMaturity = sdf.parse(sDate, new ParsePosition(0));
301
302 int nResult = dtProc.compareTo(dtMaturity);
303
304 if(nResult >= 0) {
305 fPayOffAmnt = Float.parseFloat(agreementDetailsNode.valueOf("./finpayoff"));
306 fPrinDue = fPayOffAmnt;
307 }
308 else {
309 if(nDelinq > 0) {
310 fPrinDue = fAmntPastDue + fRegPymnt + fLateCharges + fFee;
311 }
312 else {
313 fPrinDue = (fRegPymnt - fPartial) + fLateCharges + fFee;
314 }
315 }
316
317 return Float.toString(fPrinDue);
318 }
319
320
321 public String getQueueType() throws XSLException, Exception {
322 System.out.println(queueValuesNode.valueOf("./QueueType"));
323 return queueValuesNode.valueOf("./QueueType");
324 }
325
326
327 public String getRegularPayment() throws XSLException, Exception {
328 return agreementDetailsNode.valueOf("./finregularpayment");
329 }
330
331
332 public String getStateCode() throws XSLException, Exception {
333 return StringFormat.toSafeHTMLString(addressNode.valueOf("./state"));
334 }
335
336
337 public String getStatusValuesOptions() throws XSLException, Exception {
338 String statusOptionValues = "";
339 for(int i = 0; i < statusValuesNode.getChildNodes().getLength(); i++) {
340 statusOptionValues += "<OPTION>" +
341 StringFormat.toSafeHTMLString(((XMLNode)(statusValuesNode.getChildNodes().item(i))).valueOf("./categoryname")) +
342 " - " +
343 StringFormat.toSafeHTMLString(((XMLNode)(statusValuesNode.getChildNodes().item(i))).valueOf("./valuename")) +
344 "</OPTION>";
345 }
346 return statusOptionValues;
347 }
348
349
350 public String getFee() throws XSLException, Exception {
351 return agreementDetailsNode.valueOf("./fee");
352 }
353
354
355 public String getIntBal() throws XSLException, Exception {
356 return agreementDetailsNode.valueOf("./intbal");
357 }
358
359
360 public String getYear() throws XSLException, Exception {
361 return collateralNode.valueOf("./year");
362 }
363
364
365 public String getZipCode() throws XSLException, Exception {
366 return addressNode.valueOf("./zipcode");
367 }
368
369
370 public void setData(String data, long lCompId) throws Exception {
371 DOMParser docParser = new DOMParser();
372 XMLElement primaryElement;
373 ByteArrayInputStream stream;
374
375 try {
376
377 lCompanyID = lCompId;
378
379 stream = new ByteArrayInputStream(data.getBytes());
380 docParser.setValidationMode(false);
381 docParser.parse(stream);
382 accountDetailsXmlString = data;
383 accountDetailsXml = docParser.getDocument();
384 primaryNode = (XMLNode)(accountDetailsXml.getElementsByTagName("PrimariesList").item(0).getFirstChild());
385 primaryElement = (XMLElement)primaryNode;
386 addressNode = (XMLNode)(primaryElement.getElementsByTagName("AddressesList").item(0).getFirstChild());
387 collateralNode = (XMLNode)(accountDetailsXml.getElementsByTagName("CollateralsList").item(0).getFirstChild());
388 agreementDetailsNode = (XMLNode)(accountDetailsXml.getElementsByTagName("AgreementDetailsList").item(0).getFirstChild());
389 statusValuesNode = (XMLNode)(accountDetailsXml.getElementsByTagName("StatusValuesList").item(0));
390 queueValuesNode = (XMLNode)(accountDetailsXml.getElementsByTagName("QueueValuesList").item(0));
391 }
392 catch(Exception e) {
393 }
394 }
395 }
396
397