1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.gl.businessobject;
18
19 import java.sql.Date;
20 import java.util.LinkedHashMap;
21 import java.util.Map;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.kuali.ole.coa.businessobject.Account;
25 import org.kuali.ole.coa.businessobject.BalanceType;
26 import org.kuali.ole.coa.businessobject.Chart;
27 import org.kuali.ole.coa.businessobject.ObjectCode;
28 import org.kuali.ole.coa.businessobject.ObjectType;
29 import org.kuali.ole.coa.service.AccountService;
30 import org.kuali.ole.gl.GeneralLedgerConstants;
31 import org.kuali.ole.sys.OLEConstants;
32 import org.kuali.ole.sys.OLEKeyConstants;
33 import org.kuali.ole.sys.OLEPropertyConstants;
34 import org.kuali.ole.sys.businessobject.UniversityDate;
35 import org.kuali.ole.sys.context.SpringContext;
36 import org.kuali.rice.core.api.util.type.KualiDecimal;
37 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
38 import org.kuali.rice.krad.util.MessageMap;
39
40
41
42
43 public class CollectorDetail extends PersistableBusinessObjectBase {
44
45 private String universityFiscalPeriodCode;
46 private Integer universityFiscalYear;
47 private Date createDate;
48 private Integer transactionLedgerEntrySequenceNumber;
49 private String chartOfAccountsCode;
50 private String accountNumber;
51 private String subAccountNumber;
52 private String financialObjectCode;
53 private String financialSubObjectCode;
54 private String financialBalanceTypeCode;
55 private String financialObjectTypeCode;
56 private String collectorDetailSequenceNumber;
57 private String financialDocumentTypeCode;
58 private String financialSystemOriginationCode;
59 private String documentNumber;
60 private KualiDecimal collectorDetailItemAmount;
61 private String collectorDetailNoteText;
62 private String glCreditCode;
63
64 private ObjectCode financialObject;
65 private Account account;
66 private Chart chartOfAccounts;
67 private ObjectType objectType;
68 private BalanceType balanceType;
69
70 private static CollectorDetailFieldUtil collectorDetailFieldUtil;
71
72
73
74
75 public CollectorDetail() {
76 setSubAccountNumber(OLEConstants.getDashSubAccountNumber());
77 setFinancialSubObjectCode(OLEConstants.getDashFinancialSubObjectCode());
78 }
79
80
81
82
83
84
85 public String getUniversityFiscalPeriodCode() {
86 return universityFiscalPeriodCode;
87 }
88
89
90
91
92
93
94 public void setUniversityFiscalPeriodCode(String universityFiscalPeriodCode) {
95 this.universityFiscalPeriodCode = universityFiscalPeriodCode;
96 }
97
98
99
100
101
102
103
104 public Integer getUniversityFiscalYear() {
105 return universityFiscalYear;
106 }
107
108
109
110
111
112
113 public void setUniversityFiscalYear(Integer universityFiscalYear) {
114 this.universityFiscalYear = universityFiscalYear;
115 }
116
117
118
119
120
121
122
123 public Date getCreateDate() {
124 return createDate;
125 }
126
127
128
129
130
131
132 public void setCreateDate(Date createDate) {
133 this.createDate = createDate;
134 }
135
136
137
138
139
140 public Integer getTransactionLedgerEntrySequenceNumber() {
141 return transactionLedgerEntrySequenceNumber;
142 }
143
144
145
146
147
148 public void setTransactionLedgerEntrySequenceNumber(Integer transactionLedgerEntrySequenceNumber) {
149 this.transactionLedgerEntrySequenceNumber = transactionLedgerEntrySequenceNumber;
150 }
151
152
153
154
155
156
157 public String getChartOfAccountsCode() {
158 return chartOfAccountsCode;
159 }
160
161
162
163
164
165
166 public void setChartOfAccountsCode(String chartOfAccountsCode) {
167 this.chartOfAccountsCode = chartOfAccountsCode;
168 }
169
170
171
172
173
174
175
176 public String getAccountNumber() {
177 return accountNumber;
178 }
179
180
181
182
183
184
185 public void setAccountNumber(String accountNumber) {
186 this.accountNumber = accountNumber;
187 }
188
189
190
191
192
193
194
195 public String getSubAccountNumber() {
196 return subAccountNumber;
197 }
198
199
200
201
202
203
204 public void setSubAccountNumber(String subAccountNumber) {
205 this.subAccountNumber = subAccountNumber;
206 }
207
208
209
210
211
212
213
214 public String getFinancialObjectCode() {
215 return financialObjectCode;
216 }
217
218
219
220
221
222
223 public void setFinancialObjectCode(String financialObjectCode) {
224 this.financialObjectCode = financialObjectCode;
225 }
226
227
228
229
230
231
232
233 public String getFinancialSubObjectCode() {
234 return financialSubObjectCode;
235 }
236
237
238
239
240
241
242 public void setFinancialSubObjectCode(String financialSubObjectCode) {
243 this.financialSubObjectCode = financialSubObjectCode;
244 }
245
246
247
248
249
250
251
252 public String getCollectorDetailSequenceNumber() {
253 return collectorDetailSequenceNumber;
254 }
255
256
257
258
259
260
261 public void setCollectorDetailSequenceNumber(String collectorDetailSequenceNumber) {
262 this.collectorDetailSequenceNumber = collectorDetailSequenceNumber;
263 }
264
265
266
267
268
269
270
271 public String getFinancialDocumentTypeCode() {
272 return financialDocumentTypeCode;
273 }
274
275
276
277
278
279
280 public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
281 this.financialDocumentTypeCode = financialDocumentTypeCode;
282 }
283
284
285
286
287
288
289
290 public String getFinancialSystemOriginationCode() {
291 return financialSystemOriginationCode;
292 }
293
294
295
296
297
298
299 public void setFinancialSystemOriginationCode(String financialSystemOriginationCode) {
300 this.financialSystemOriginationCode = financialSystemOriginationCode;
301 }
302
303
304
305
306
307
308
309 public String getDocumentNumber() {
310 return documentNumber;
311 }
312
313
314
315
316
317
318 public void setDocumentNumber(String documentNumber) {
319 this.documentNumber = documentNumber;
320 }
321
322
323
324
325
326
327
328 public KualiDecimal getCollectorDetailItemAmount() {
329 return collectorDetailItemAmount;
330 }
331
332
333
334
335
336
337 public void setCollectorDetailItemAmount(KualiDecimal collectorDetailItemAmount) {
338 this.collectorDetailItemAmount = collectorDetailItemAmount;
339 }
340
341 public void setCollectorDetailItemAmount(String collectorDetailItemAmount) {
342 this.collectorDetailItemAmount = new KualiDecimal(collectorDetailItemAmount);
343 }
344
345 public void clearcollectorDetailItemAmount() {
346 this.collectorDetailItemAmount = null;
347 }
348
349
350
351
352
353
354 public String getCollectorDetailNoteText() {
355 return collectorDetailNoteText;
356 }
357
358
359
360
361
362
363 public void setCollectorDetailNoteText(String collectorDetailNoteText) {
364 this.collectorDetailNoteText = collectorDetailNoteText;
365 }
366
367
368
369
370
371
372
373 public ObjectCode getFinancialObject() {
374 return financialObject;
375 }
376
377
378
379
380
381
382
383 public void setFinancialObject(ObjectCode financialObject) {
384 this.financialObject = financialObject;
385 }
386
387
388
389
390
391
392 public Account getAccount() {
393 return account;
394 }
395
396
397
398
399
400
401
402 public void setAccount(Account account) {
403 this.account = account;
404 }
405
406
407
408
409
410
411 public Chart getChartOfAccounts() {
412 return chartOfAccounts;
413 }
414
415
416
417
418
419
420
421 public void setChartOfAccounts(Chart chartOfAccounts) {
422 this.chartOfAccounts = chartOfAccounts;
423 }
424
425
426
427
428 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
429 LinkedHashMap m = new LinkedHashMap();
430 m.put("universityFiscalPeriodCode", getUniversityFiscalPeriodCode());
431 if (getUniversityFiscalYear() != null) {
432 m.put("universityFiscalYear", getUniversityFiscalYear().toString());
433 }
434 if (getCreateDate() != null) {
435 m.put("createDate", getCreateDate().toString());
436 }
437 m.put("transactionLedgerEntrySequenceNumber", getTransactionLedgerEntrySequenceNumber());
438 m.put("chartOfAccountsCode", getChartOfAccountsCode());
439 m.put("accountNumber", getAccountNumber());
440 m.put("subAccountNumber", getSubAccountNumber());
441 m.put("financialObjectCode", getFinancialObjectCode());
442 m.put("financialSubObjectCode", getFinancialSubObjectCode());
443 m.put("collectorDetailSequenceNumber", getCollectorDetailSequenceNumber());
444 m.put("financialDocumentTypeCode", getFinancialDocumentTypeCode());
445 m.put(OLEPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
446 return m;
447 }
448
449
450
451
452
453
454 public BalanceType getBalanceType() {
455 return balanceType;
456 }
457
458
459
460
461
462
463 public void setBalanceType(BalanceType balanceTyp) {
464 this.balanceType = balanceTyp;
465 }
466
467
468
469
470
471
472 public String getFinancialBalanceTypeCode() {
473 return financialBalanceTypeCode;
474 }
475
476
477
478
479
480
481 public void setFinancialBalanceTypeCode(String financialBalanceTypeCode) {
482 this.financialBalanceTypeCode = financialBalanceTypeCode;
483 }
484
485
486
487
488
489
490 public String getFinancialObjectTypeCode() {
491 return financialObjectTypeCode;
492 }
493
494
495
496
497
498
499 public void setFinancialObjectTypeCode(String financialObjectTypeCode) {
500 this.financialObjectTypeCode = financialObjectTypeCode;
501 }
502
503
504
505
506
507
508 public String getGlCreditCode() {
509 return glCreditCode;
510 }
511
512
513
514
515
516
517 public void setGLCreditCode(String glCreditCode) {
518 this.glCreditCode = glCreditCode;
519 }
520
521
522
523
524
525
526
527 public ObjectType getObjectType() {
528 return objectType;
529 }
530
531
532
533
534
535
536 public void setObjectType(ObjectType objectType) {
537 this.objectType = objectType;
538 }
539
540 protected String getValue(String headerLine, int s, int e) {
541 return org.springframework.util.StringUtils.trimTrailingWhitespace(StringUtils.substring(headerLine, s, e));
542 }
543
544
545
546
547 protected static CollectorDetailFieldUtil getCollectorDetailFieldUtil() {
548 if (collectorDetailFieldUtil == null) {
549 collectorDetailFieldUtil = new CollectorDetailFieldUtil();
550 }
551 return collectorDetailFieldUtil;
552 }
553
554 public void setFromFileForCollectorDetail(String detailLine, Map<String, String>accountRecordBalanceTypeMap, Date curDate, UniversityDate universityDate, int lineNumber, MessageMap messageMap) {
555
556 try{
557
558 final Map<String, Integer> pMap = getCollectorDetailFieldUtil().getFieldBeginningPositionMap();
559
560 detailLine = org.apache.commons.lang.StringUtils.rightPad(detailLine, GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length(), ' ');
561
562 setCreateDate(curDate);
563 if (!GeneralLedgerConstants.getSpaceUniversityFiscalYear().equals(detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)))) {
564 try {
565 setUniversityFiscalYear(new Integer(getValue(detailLine, pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE))));
566 }
567 catch (NumberFormatException e) {
568 messageMap.putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.ERROR_CUSTOM, "Collector detail university fiscal year " + lineNumber + " string " + detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)));
569 setUniversityFiscalYear(null);
570 }
571 }
572 else {
573 setUniversityFiscalYear(null);
574 }
575
576 if (!GeneralLedgerConstants.getSpaceChartOfAccountsCode().equals(detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE))))
577 setChartOfAccountsCode(getValue(detailLine, pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE), pMap.get(OLEPropertyConstants.ACCOUNT_NUMBER)));
578 else
579 setChartOfAccountsCode(GeneralLedgerConstants.getSpaceChartOfAccountsCode());
580 setAccountNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.ACCOUNT_NUMBER), pMap.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER)));
581
582
583 AccountService acctserv = SpringContext.getBean(AccountService.class);
584 if (StringUtils.isEmpty(getChartOfAccountsCode()) && StringUtils.isNotEmpty(getAccountNumber()) && !acctserv.accountsCanCrossCharts()) {
585 Account account = acctserv.getUniqueAccountForAccountNumber(getAccountNumber());
586 if (account != null) {
587 setChartOfAccountsCode(account.getChartOfAccountsCode());
588 }
589 }
590
591 setSubAccountNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER), pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_CODE)));
592 setFinancialObjectCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE)));
593 setFinancialSubObjectCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE)));
594
595
596
597 String accountRecordKey = generateAccountRecordBalanceTypeKey();
598 String financialBalanceTypeCode = accountRecordBalanceTypeMap.get(accountRecordKey);
599
600 setFinancialBalanceTypeCode(StringUtils.defaultIfEmpty(financialBalanceTypeCode, GeneralLedgerConstants.FINALNCIAL_BALANCE_TYPE_FOR_COLLECTOR_DETAIL_RECORD));
601 setFinancialObjectTypeCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER)));
602 setUniversityFiscalPeriodCode(universityDate.getUniversityFiscalAccountingPeriod());
603 setCollectorDetailSequenceNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER), pMap.get(OLEPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE)));
604 setFinancialDocumentTypeCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE)));
605 setFinancialSystemOriginationCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE), pMap.get(OLEPropertyConstants.DOCUMENT_NUMBER)));
606 setDocumentNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.DOCUMENT_NUMBER), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT)));
607 try {
608 setCollectorDetailItemAmount(getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE)));
609 }
610 catch (NumberFormatException e) {
611 setCollectorDetailItemAmount(KualiDecimal.ZERO);
612 messageMap.putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.ERROR_CUSTOM, "Collector detail amount cannot be parsed on line " + lineNumber + " amount string " + detailLine.substring(pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(OLEPropertyConstants.GL_CREDIT_CODE)));
613 }
614 if (OLEConstants.GL_CREDIT_CODE.equalsIgnoreCase(getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT)))) {
615 setCollectorDetailItemAmount(getCollectorDetailItemAmount().negated());
616 }
617 setCollectorDetailNoteText(getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT), GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length()));
618
619 if (org.apache.commons.lang.StringUtils.isEmpty(getSubAccountNumber())) {
620 setSubAccountNumber(OLEConstants.getDashSubAccountNumber());
621 }
622 if (org.apache.commons.lang.StringUtils.isEmpty(getFinancialSubObjectCode())) {
623 setFinancialSubObjectCode(OLEConstants.getDashFinancialSubObjectCode());
624 }
625 if (org.apache.commons.lang.StringUtils.isEmpty(getCollectorDetailSequenceNumber())) {
626 setCollectorDetailSequenceNumber(" ");
627 }
628 } catch (Exception e){
629 throw new RuntimeException(e + " occurred in CollectorDetail.setFromFileForCollectorDetail()");
630 }
631 }
632
633
634
635
636
637
638
639
640
641
642
643
644 private String generateAccountRecordBalanceTypeKey() {
645 StringBuilder builder = new StringBuilder();
646 builder.append(getUniversityFiscalYear()).append("|")
647 .append(getChartOfAccountsCode()).append("|")
648 .append(getAccountNumber()).append("|")
649 .append(StringUtils.replace(getSubAccountNumber(), "-", "")).append("|")
650 .append(getFinancialObjectCode()).append("|")
651 .append(StringUtils.replace(getFinancialSubObjectCode(), "-", ""));
652 return builder.toString();
653 }
654 }