1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.pdp.businessobject;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
25 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26 import org.kuali.rice.krad.service.KualiModuleService;
27 import org.kuali.rice.krad.service.ModuleService;
28 import org.kuali.rice.location.api.LocationConstants;
29 import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
30 import org.kuali.rice.location.framework.state.StateEbo;
31
32 public class ACHBank extends PersistableBusinessObjectBase implements MutableInactivatable {
33
34 protected String bankRoutingNumber;
35 protected String bankOfficeCode;
36 protected String bankServiceNumber;
37 protected String bankTypeCode;
38 protected String bankNewRoutingNumber;
39 protected String bankName;
40 protected String bankStreetAddress;
41 protected String bankCityName;
42 protected String bankStateCode;
43 protected String bankZipCode;
44 protected String bankPhoneAreaCode;
45 protected String bankPhonePrefixNumber;
46 protected String bankPhoneSuffixNumber;
47 protected String bankInstitutionStatusCode;
48 protected String bankDataViewCode;
49 protected boolean active;
50
51 protected StateEbo bankState;
52 protected PostalCodeEbo postalCode;
53
54
55
56
57 public ACHBank() {
58
59 }
60
61
62
63
64
65
66 public ACHBank(String fileData) {
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 setBankRoutingNumber(getField(fileData, 1, 9));
92 setBankOfficeCode(getField(fileData, 10, 1));
93 setBankServiceNumber(getField(fileData, 11, 9));
94 setBankTypeCode(getField(fileData, 20, 1));
95 setBankNewRoutingNumber(getField(fileData, 27, 9));
96 setBankName(getField(fileData, 36, 36));
97 setBankStreetAddress(getField(fileData, 72, 36));
98 setBankCityName(getField(fileData, 108, 20));
99 setBankStateCode(getField(fileData, 128, 2));
100 setBankZipCode(getField(fileData, 130, 5));
101 setBankPhoneAreaCode(getField(fileData, 139, 3));
102 setBankPhonePrefixNumber(getField(fileData, 142, 3));
103 setBankPhoneSuffixNumber(getField(fileData, 145, 4));
104 setBankInstitutionStatusCode(getField(fileData, 149, 1));
105 setBankDataViewCode(getField(fileData, 150, 1));
106 setActive(true);
107 }
108
109 protected String getField(String data, int startChar, int length) {
110 return data.substring(startChar - 1, startChar + length - 1).trim();
111 }
112
113
114
115
116
117
118 public String getBankRoutingNumber() {
119 return bankRoutingNumber;
120 }
121
122
123
124
125
126
127 public void setBankRoutingNumber(String bankRoutingNumber) {
128 this.bankRoutingNumber = bankRoutingNumber;
129 }
130
131
132
133
134
135
136
137 public String getBankOfficeCode() {
138 return bankOfficeCode;
139 }
140
141
142
143
144
145
146 public void setBankOfficeCode(String bankOfficeCode) {
147 this.bankOfficeCode = bankOfficeCode;
148 }
149
150
151
152
153
154
155
156 public String getBankServiceNumber() {
157 return bankServiceNumber;
158 }
159
160
161
162
163
164
165 public void setBankServiceNumber(String bankServiceNumber) {
166 this.bankServiceNumber = bankServiceNumber;
167 }
168
169
170
171
172
173
174
175 public String getBankTypeCode() {
176 return bankTypeCode;
177 }
178
179
180
181
182
183
184 public void setBankTypeCode(String bankTypeCode) {
185 this.bankTypeCode = bankTypeCode;
186 }
187
188
189
190
191
192
193
194 public String getBankNewRoutingNumber() {
195 return bankNewRoutingNumber;
196 }
197
198
199
200
201
202
203 public void setBankNewRoutingNumber(String bankNewRoutingNumber) {
204 this.bankNewRoutingNumber = bankNewRoutingNumber;
205 }
206
207
208
209
210
211
212
213 public String getBankName() {
214 return bankName;
215 }
216
217
218
219
220
221
222 public void setBankName(String bankName) {
223 this.bankName = bankName;
224 }
225
226
227
228
229
230
231
232 public String getBankStreetAddress() {
233 return bankStreetAddress;
234 }
235
236
237
238
239
240
241 public void setBankStreetAddress(String bankStreetAddress) {
242 this.bankStreetAddress = bankStreetAddress;
243 }
244
245
246
247
248
249
250
251 public String getBankCityName() {
252 return bankCityName;
253 }
254
255
256
257
258
259
260 public void setBankCityName(String bankCityName) {
261 this.bankCityName = bankCityName;
262 }
263
264
265
266
267
268
269
270 public String getBankStateCode() {
271 return bankStateCode;
272 }
273
274
275
276
277
278
279 public void setBankStateCode(String bankStateCode) {
280 this.bankStateCode = bankStateCode;
281 }
282
283
284
285
286
287
288
289 public String getBankZipCode() {
290 return bankZipCode;
291 }
292
293
294
295
296
297
298 public void setBankZipCode(String bankZipCode) {
299 this.bankZipCode = bankZipCode;
300 }
301
302
303
304
305
306
307 public String getBankPhoneAreaCode() {
308 return bankPhoneAreaCode;
309 }
310
311
312
313
314
315
316 public void setBankPhoneAreaCode(String bankPhoneAreaCode) {
317 this.bankPhoneAreaCode = bankPhoneAreaCode;
318 }
319
320
321
322
323
324
325
326 public String getBankPhonePrefixNumber() {
327 return bankPhonePrefixNumber;
328 }
329
330
331
332
333
334
335 public void setBankPhonePrefixNumber(String bankPhonePrefixNumber) {
336 this.bankPhonePrefixNumber = bankPhonePrefixNumber;
337 }
338
339
340
341
342
343
344
345 public String getBankPhoneSuffixNumber() {
346 return bankPhoneSuffixNumber;
347 }
348
349
350
351
352
353
354 public void setBankPhoneSuffixNumber(String bankPhoneSuffixNumber) {
355 this.bankPhoneSuffixNumber = bankPhoneSuffixNumber;
356 }
357
358
359
360
361
362
363
364 public String getBankInstitutionStatusCode() {
365 return bankInstitutionStatusCode;
366 }
367
368
369
370
371
372
373 public void setBankInstitutionStatusCode(String bankInstitutionStatusCode) {
374 this.bankInstitutionStatusCode = bankInstitutionStatusCode;
375 }
376
377
378
379
380
381
382
383 public String getBankDataViewCode() {
384 return bankDataViewCode;
385 }
386
387
388
389
390
391
392 public void setBankDataViewCode(String bankDataViewCode) {
393 this.bankDataViewCode = bankDataViewCode;
394 }
395
396
397
398
399
400
401 public StateEbo getBankState() {
402 if ( StringUtils.isBlank(bankStateCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
403 bankState = null;
404 } else {
405 if ( bankState == null || !StringUtils.equals( bankState.getCode(),bankStateCode) || !StringUtils.equals(bankState.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
406 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
407 if ( moduleService != null ) {
408 Map<String,Object> keys = new HashMap<String, Object>(2);
409 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);
410 keys.put(LocationConstants.PrimaryKeyConstants.CODE, bankStateCode);
411 bankState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
412 } else {
413 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
414 }
415 }
416 }
417 return bankState;
418 }
419
420
421
422
423
424
425 public PostalCodeEbo getPostalCode() {
426 if ( StringUtils.isBlank(bankZipCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
427 postalCode = null;
428 } else {
429 if ( postalCode == null || !StringUtils.equals( postalCode.getCode(),bankZipCode) || !StringUtils.equals(postalCode.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
430 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
431 if ( moduleService != null ) {
432 Map<String,Object> keys = new HashMap<String, Object>(2);
433 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);
434 keys.put(LocationConstants.PrimaryKeyConstants.CODE, bankZipCode);
435 postalCode = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
436 } else {
437 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
438 }
439 }
440 }
441 return postalCode;
442 }
443
444
445
446
447
448 @Override
449 public boolean isActive() {
450 return active;
451 }
452
453
454
455
456
457 @Override
458 public void setActive(boolean active) {
459 this.active = active;
460 }
461 }