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.sql.Date;
19 import java.sql.Timestamp;
20 import java.text.ParseException;
21 import java.util.ArrayList;
22 import java.util.Iterator;
23 import java.util.LinkedHashMap;
24 import java.util.List;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.kuali.ole.pdp.PdpConstants;
28 import org.kuali.ole.pdp.PdpKeyConstants;
29 import org.kuali.ole.pdp.PdpPropertyConstants;
30 import org.kuali.ole.sys.OLEConstants;
31 import org.kuali.ole.sys.OLEPropertyConstants;
32 import org.kuali.ole.sys.businessobject.Bank;
33 import org.kuali.ole.sys.businessobject.TimestampedBusinessObjectBase;
34 import org.kuali.ole.sys.context.SpringContext;
35 import org.kuali.rice.core.api.config.property.ConfigurationService;
36 import org.kuali.rice.core.api.datetime.DateTimeService;
37 import org.kuali.rice.core.api.util.type.KualiDecimal;
38 import org.kuali.rice.core.api.util.type.KualiInteger;
39 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
40 import org.kuali.rice.krad.service.KeyValuesService;
41
42
43
44
45 public class PaymentGroup extends TimestampedBusinessObjectBase {
46 private static KualiDecimal zero = KualiDecimal.ZERO;
47
48 private KualiInteger id;
49 private String payeeName;
50 private String payeeId;
51 private String payeeIdTypeCd;
52 private String alternatePayeeId;
53 private String alternatePayeeIdTypeCd;
54 private String payeeOwnerCd;
55 private String line1Address;
56 private String line2Address;
57 private String line3Address;
58 private String line4Address;
59 private String city;
60 private String state;
61 private String country;
62 private String zipCd;
63 private Boolean campusAddress;
64 private Date paymentDate;
65 private Boolean pymtAttachment;
66 private Boolean pymtSpecialHandling;
67 private Boolean taxablePayment;
68 private Boolean nraPayment;
69 private Boolean processImmediate;
70 private boolean combineGroups;
71 private String achBankRoutingNbr;
72 private String adviceEmailAddress;
73 private Boolean employeeIndicator;
74 private String creditMemoNbr;
75 private KualiDecimal creditMemoAmount;
76 private KualiInteger disbursementNbr;
77 private Date disbursementDate;
78 private String physCampusProcessCd;
79 private String sortValue;
80 private String achAccountType;
81 private Timestamp epicPaymentCancelledExtractedDate;
82 private Timestamp epicPaymentPaidExtractedDate;
83 private Timestamp adviceEmailSentDate;
84 private String vendorAliasName;
85
86 private KualiInteger batchId;
87 private Batch batch;
88
89 private KualiInteger processId;
90 private PaymentProcess process;
91
92 private String paymentStatusCode;
93 private PaymentStatus paymentStatus;
94
95 private String disbursementTypeCode;
96 private DisbursementType disbursementType;
97
98 private String bankCode;
99 private Bank bank;
100
101 private AchAccountNumber achAccountNumber;
102
103 private List<PaymentGroupHistory> paymentGroupHistory = new ArrayList<PaymentGroupHistory>();
104 private List<PaymentDetail> paymentDetails = new ArrayList<PaymentDetail>();
105
106
107
108
109 public PaymentGroup() {
110 super();
111 }
112
113
114
115
116
117 public boolean isDailyReportSpecialHandling() {
118 return pymtSpecialHandling && !processImmediate;
119 }
120
121
122
123
124
125 public boolean isDailyReportAttachment() {
126 return !pymtSpecialHandling && !processImmediate && pymtAttachment;
127 }
128
129
130
131
132
133 public String getPaymentStatusCode() {
134 return paymentStatusCode;
135 }
136
137
138
139
140 public String getPaymentStatusCodeWithHistory() {
141 if (paymentStatus == null) {
142 this.refreshReferenceObject(PdpPropertyConstants.PAYMENT_STATUS);
143 }
144
145
146 String paymentStatusWithHistory = "";
147 if (paymentStatus != null) {
148 paymentStatusWithHistory += paymentStatus.getName();
149 }
150
151 boolean isCanceledReissued = false;
152 for (PaymentGroupHistory paymentGroupHistory : getPaymentGroupHistory()) {
153 if (PdpConstants.PaymentChangeCodes.CANCEL_REISSUE_DISBURSEMENT.equals(paymentGroupHistory.getPaymentChangeCode())) {
154 isCanceledReissued = true;
155 }
156 if (PdpConstants.PaymentChangeCodes.REISSUE_DISBURSEMENT.equals(paymentGroupHistory.getPaymentChangeCode())) {
157 isCanceledReissued = true;
158 }
159
160 }
161
162 if (isCanceledReissued) {
163 paymentStatusWithHistory += " (Reissued)";
164 }
165
166
167 PaymentDetail paymentDetail = getPaymentDetails().get(0);
168 if (!paymentDetail.isDisbursementActionAllowed()) {
169 paymentStatusWithHistory += " (Stale)";
170 }
171
172 return paymentStatusWithHistory;
173 }
174
175
176
177
178
179
180
181
182 private String getWidthString(int width, String val) {
183 return (val + " ").substring(0, width - 1);
184 }
185
186
187
188
189
190
191 private boolean booleanValue(Boolean b) {
192 boolean bv = false;
193 if (b != null) {
194 bv = b.booleanValue();
195 }
196 return bv;
197 }
198
199
200
201
202
203 public int getNoteLines() {
204 int count = 0;
205 for (Iterator iter = this.getPaymentDetails().iterator(); iter.hasNext();) {
206 PaymentDetail element = (PaymentDetail) iter.next();
207 count++;
208 count = count + element.getNotes().size();
209 }
210 return count;
211 }
212
213
214
215
216
217
218 public KualiDecimal getNetPaymentAmount() {
219 KualiDecimal amt = KualiDecimal.ZERO;
220 for (Iterator iter = this.getPaymentDetails().iterator(); iter.hasNext();) {
221 PaymentDetail element = (PaymentDetail) iter.next();
222 amt = amt.add(element.getNetPaymentAmount());
223 }
224 return amt;
225 }
226
227
228
229
230
231
232 public List<PaymentDetail> getPaymentDetails() {
233 return paymentDetails;
234 }
235
236
237
238
239
240 public void setPaymentDetails(List<PaymentDetail> paymentDetail) {
241 this.paymentDetails = paymentDetail;
242 }
243
244
245
246
247
248 public void addPaymentDetails(PaymentDetail pgh) {
249 pgh.setPaymentGroup(this);
250 paymentDetails.add(pgh);
251 }
252
253 public void deletePaymentDetails(PaymentDetail pgh) {
254 paymentDetails.remove(pgh);
255 }
256
257
258
259
260
261
262 public List<PaymentGroupHistory> getPaymentGroupHistory() {
263 return paymentGroupHistory;
264 }
265
266
267
268
269
270 public void setPaymentGroupHistory(List<PaymentGroupHistory> paymentGroupHistory) {
271 this.paymentGroupHistory = paymentGroupHistory;
272 }
273
274
275
276
277
278 public void addPaymentGroupHistory(PaymentGroupHistory pd) {
279 pd.setPaymentGroup(this);
280 paymentGroupHistory.add(pd);
281 }
282
283
284
285
286
287 public void deletePaymentGroupHistory(PaymentGroupHistory pd) {
288 paymentGroupHistory.remove(pd);
289 }
290
291
292
293
294
295
296 public KualiInteger getId() {
297 return id;
298 }
299
300
301
302
303
304 public AchAccountNumber getAchAccountNumber() {
305 return achAccountNumber;
306 }
307
308
309
310
311
312 public void setAchAccountNumber(AchAccountNumber aan) {
313 this.achAccountNumber = aan;
314 }
315
316
317
318
319
320 public String getSortValue() {
321 return sortValue;
322 }
323
324
325
326
327
328 public void setSortValue(int sortGroupId) {
329 String defaultSortOrderParameterName = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PdpKeyConstants.DEFAULT_SORT_GROUP_ID_PARAMETER);
330 String defaultSortOrderParameterValue = SpringContext.getBean(ParameterService.class).getParameterValueAsString(PaymentGroup.class, defaultSortOrderParameterName);
331
332 StringBuffer sb = new StringBuffer();
333
334 sb.append(sortGroupId);
335
336 CustomerProfile cp = this.getBatch().getCustomerProfile();
337 sb.append(cp.getChartCode());
338 sb.append(getWidthString(4, cp.getUnitCode()));
339 sb.append(getWidthString(4, cp.getSubUnitCode()));
340
341 if (defaultSortOrderParameterValue.equals(String.valueOf(sortGroupId))) {
342 sb.append(this.getPayeeId());
343 sb.append(this.getPayeeIdTypeCd());
344 }
345 else {
346 sb.append(this.getPayeeName());
347 }
348 this.sortValue = sb.toString();
349 }
350
351
352
353
354
355 public String getCity() {
356 return city;
357 }
358
359
360
361
362 public void setCity(String city) {
363 this.city = city;
364 }
365
366 public boolean getCombineGroups() {
367 return combineGroups;
368 }
369
370 public void setCombineGroups(boolean combineGroups) {
371 this.combineGroups = combineGroups;
372 }
373
374
375
376
377
378 public String getCountry() {
379 return country;
380 }
381
382
383
384
385 public void setCountry(String country) {
386 this.country = country;
387 }
388
389
390
391
392
393 public String getState() {
394 return state;
395 }
396
397
398
399
400 public void setState(String state) {
401 this.state = state;
402 }
403
404
405
406
407
408 public String getAchBankRoutingNbr() {
409 return achBankRoutingNbr;
410 }
411
412
413
414
415
416 public String getAdviceEmailAddress() {
417 return adviceEmailAddress;
418 }
419
420
421
422
423
424 public String getAlternatePayeeId() {
425 return alternatePayeeId;
426 }
427
428
429
430
431
432 public String getAlternatePayeeIdTypeCd() {
433 return alternatePayeeIdTypeCd;
434 }
435
436
437
438
439
440 public Bank getBank() {
441 return bank;
442 }
443
444
445
446
447
448 public Batch getBatch() {
449 return batch;
450 }
451
452
453
454
455
456
457 public String getBankCode() {
458 return bankCode;
459 }
460
461
462
463
464
465
466 public void setBankCode(String bankCode) {
467 this.bankCode = bankCode;
468 }
469
470
471
472
473
474 public Boolean getCampusAddress() {
475 return campusAddress;
476 }
477
478
479
480
481
482 public KualiDecimal getCreditMemoAmount() {
483 return creditMemoAmount;
484 }
485
486
487
488
489
490 public String getCreditMemoNbr() {
491 return creditMemoNbr;
492 }
493
494
495
496
497
498 public Date getDisbursementDate() {
499 return disbursementDate;
500 }
501
502
503
504
505
506 public KualiInteger getDisbursementNbr() {
507 return disbursementNbr;
508 }
509
510
511
512
513
514 public DisbursementType getDisbursementType() {
515 return disbursementType;
516 }
517
518 public Boolean getEmployeeIndicator() {
519 return employeeIndicator;
520 }
521
522
523
524
525
526 public String getLine1Address() {
527 return line1Address;
528 }
529
530
531
532
533
534 public String getLine2Address() {
535 return line2Address;
536 }
537
538
539
540
541
542 public String getLine3Address() {
543 return line3Address;
544 }
545
546
547
548
549
550 public String getLine4Address() {
551 return line4Address;
552 }
553
554
555
556
557
558 public Boolean getNraPayment() {
559 return nraPayment;
560 }
561
562
563
564
565
566 public String getPayeeId() {
567 return payeeId;
568 }
569
570
571
572
573
574 public String getPayeeIdTypeCd() {
575 return payeeIdTypeCd;
576 }
577
578
579
580
581
582 public String getPayeeName() {
583 return payeeName;
584 }
585
586
587
588
589
590 public String getPayeeOwnerCd() {
591 return payeeOwnerCd;
592 }
593
594
595
596
597
598 public Date getPaymentDate() {
599 return paymentDate;
600 }
601
602
603
604
605
606 public PaymentStatus getPaymentStatus() {
607 return paymentStatus;
608 }
609
610
611
612
613
614 public String getPhysCampusProcessCd() {
615 return physCampusProcessCd;
616 }
617
618
619
620
621
622 public PaymentProcess getProcess() {
623 return process;
624 }
625
626
627
628
629
630 public Boolean getProcessImmediate() {
631 return processImmediate;
632 }
633
634
635
636
637
638 public Boolean getPymtAttachment() {
639 return pymtAttachment;
640 }
641
642
643
644
645
646 public Boolean getPymtSpecialHandling() {
647 return pymtSpecialHandling;
648 }
649
650
651
652
653
654 public Boolean getTaxablePayment() {
655 return taxablePayment;
656 }
657
658
659
660
661
662 public String getZipCd() {
663 return zipCd;
664 }
665
666
667
668
669 public void setAchBankRoutingNbr(String s) {
670 achBankRoutingNbr = s;
671 }
672
673
674
675
676 public void setAdviceEmailAddress(String string) {
677 adviceEmailAddress = string;
678 }
679
680
681
682
683 public void setAlternatePayeeId(String string) {
684 alternatePayeeId = string;
685 }
686
687
688
689
690 public void setAlternatePayeeIdTypeCd(String string) {
691 alternatePayeeIdTypeCd = string;
692 }
693
694
695
696
697 public void setBank(Bank bank) {
698 this.bank = bank;
699 }
700
701
702
703
704 public void setBatch(Batch b) {
705 batch = b;
706 }
707
708
709
710
711 public void setCampusAddress(Boolean boolean1) {
712 campusAddress = boolean1;
713 }
714
715
716
717
718 public void setCreditMemoAmount(KualiDecimal decimal) {
719 creditMemoAmount = decimal;
720 }
721
722 public void setCreditMemoAmount(String decimal) {
723 creditMemoAmount = new KualiDecimal(decimal);
724 }
725
726
727
728
729 public void setCreditMemoNbr(String string) {
730 creditMemoNbr = string;
731 }
732
733
734
735
736 public void setDisbursementDate(Date timestamp) {
737 disbursementDate = timestamp;
738 }
739
740
741
742
743
744
745 public void setDisbursementDate(String disbursementDate) throws ParseException {
746 this.disbursementDate = SpringContext.getBean(DateTimeService.class).convertToSqlDate(disbursementDate);
747 }
748
749
750
751
752 public void setDisbursementNbr(KualiInteger integer) {
753 disbursementNbr = integer;
754 }
755
756 public void setDisbursementNbr(String integer) {
757 disbursementNbr = new KualiInteger(integer);
758 }
759
760
761
762
763 public void setDisbursementType(DisbursementType dt) {
764 disbursementType = dt;
765 }
766
767
768
769
770 public void setId(KualiInteger integer) {
771 id = integer;
772 }
773
774
775
776
777 public void setEmployeeIndicator(Boolean boolean1) {
778 employeeIndicator = boolean1;
779 }
780
781
782
783
784 public void setLine1Address(String string) {
785 line1Address = string;
786 }
787
788
789
790
791 public void setLine2Address(String string) {
792 line2Address = string;
793 }
794
795
796
797
798 public void setLine3Address(String string) {
799 line3Address = string;
800 }
801
802
803
804
805 public void setLine4Address(String string) {
806 line4Address = string;
807 }
808
809
810
811
812 public void setNraPayment(Boolean boolean1) {
813 nraPayment = boolean1;
814 }
815
816
817
818
819 public void setPayeeId(String string) {
820 payeeId = string;
821 }
822
823
824
825
826 public void setPayeeIdTypeCd(String string) {
827 payeeIdTypeCd = string;
828 }
829
830
831
832
833 public void setPayeeName(String string) {
834 payeeName = string;
835 }
836
837
838
839
840 public void setPayeeOwnerCd(String string) {
841 payeeOwnerCd = string;
842 }
843
844
845
846
847 public void setPaymentDate(Date timestamp) {
848 paymentDate = timestamp;
849 }
850
851
852
853
854
855
856
857 public void setPaymentDate(String paymentDate) throws ParseException {
858 this.paymentDate = SpringContext.getBean(DateTimeService.class).convertToSqlDate(paymentDate);
859 }
860
861
862
863
864 public void setPaymentStatus(PaymentStatus stat) {
865 paymentStatus = stat;
866 }
867
868
869
870
871 public void setPhysCampusProcessCd(String string) {
872 physCampusProcessCd = string;
873 }
874
875
876
877
878 public void setProcess(PaymentProcess p) {
879 if (p != null) {
880 processId = p.getId();
881 }
882 else {
883 processId = null;
884 }
885 this.process = p;
886 }
887
888
889
890
891 public void setProcessImmediate(Boolean boolean1) {
892 processImmediate = boolean1;
893 }
894
895
896
897
898 public void setPymtAttachment(Boolean boolean1) {
899 pymtAttachment = boolean1;
900 }
901
902
903
904
905 public void setTaxablePayment(Boolean boolean1) {
906 taxablePayment = boolean1;
907 }
908
909
910
911
912 public void setZipCd(String string) {
913 zipCd = string;
914 }
915
916
917
918
919 public void setPymtSpecialHandling(Boolean pymtSpecialHandling) {
920 this.pymtSpecialHandling = pymtSpecialHandling;
921 }
922
923 public String toStringKey() {
924 StringBuffer buffer = new StringBuffer();
925 CustomerProfile customerProfile = batch.getCustomerProfile();
926
927 buffer.append(PdpPropertyConstants.CustomerProfile.CUSTOMER_PROFILE_CHART_CODE);
928 buffer.append("=");
929 buffer.append(customerProfile.getChartCode());
930 buffer.append(PdpPropertyConstants.CustomerProfile.CUSTOMER_PROFILE_UNIT_CODE);
931 buffer.append("=");
932 buffer.append(customerProfile.getUnitCode());
933 buffer.append(PdpPropertyConstants.CustomerProfile.CUSTOMER_PROFILE_SUB_UNIT_CODE);
934 buffer.append("=");
935 buffer.append(customerProfile.getSubUnitCode());
936 buffer.append(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYEE_NAME);
937 buffer.append("=");
938 buffer.append(payeeName);
939 buffer.append(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_LINE1_ADDRESS);
940 buffer.append("=");
941 buffer.append(line1Address);
942 buffer.append(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYEE_ID);
943 buffer.append("=");
944 buffer.append(payeeId);
945 buffer.append(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYEE_ID_TYPE_CODE);
946 buffer.append("=");
947 buffer.append(payeeIdTypeCd);
948 buffer.append(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE);
949 buffer.append("=");
950 buffer.append(bankCode);
951
952 return buffer.toString();
953 }
954
955
956
957
958 public String getAchAccountType() {
959 return achAccountType;
960 }
961
962
963
964
965 public void setAchAccountType(String achAccountType) {
966 this.achAccountType = achAccountType;
967 }
968
969 public Timestamp getEpicPaymentCancelledExtractedDate() {
970 return epicPaymentCancelledExtractedDate;
971 }
972
973 public void setEpicPaymentCancelledExtractedDate(Timestamp epicPaymentCancelledExtractedDate) {
974 this.epicPaymentCancelledExtractedDate = epicPaymentCancelledExtractedDate;
975 }
976
977 public Timestamp getEpicPaymentPaidExtractedDate() {
978 return epicPaymentPaidExtractedDate;
979 }
980
981 public void setEpicPaymentPaidExtractedDate(Timestamp epicPaymentPaidExtractedDate) {
982 this.epicPaymentPaidExtractedDate = epicPaymentPaidExtractedDate;
983 }
984
985
986
987
988
989
990 public KualiInteger getBatchId() {
991 return batchId;
992 }
993
994
995
996
997
998
999 public void setBatchId(KualiInteger batchId) {
1000 this.batchId = batchId;
1001 }
1002
1003
1004 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
1005 LinkedHashMap m = new LinkedHashMap();
1006
1007 m.put(OLEPropertyConstants.ID, this.id);
1008
1009 return m;
1010 }
1011
1012 public String getDisbursementTypeCode() {
1013 return disbursementTypeCode;
1014 }
1015
1016 public void setDisbursementTypeCode(String disbursementTypeCode) {
1017 this.disbursementTypeCode = disbursementTypeCode;
1018 }
1019
1020 public KualiInteger getProcessId() {
1021 return processId;
1022 }
1023
1024 public void setProcessId(KualiInteger processId) {
1025 this.processId = processId;
1026 }
1027
1028 public void setPaymentStatusCode(String paymentStatusCode) {
1029 this.paymentStatusCode = paymentStatusCode;
1030 }
1031
1032 public void setId_type(String idType) {
1033 this.payeeIdTypeCd = idType;
1034 }
1035
1036
1037
1038
1039
1040
1041 public Timestamp getAdviceEmailSentDate() {
1042 return adviceEmailSentDate;
1043 }
1044
1045
1046
1047
1048
1049
1050 public void setAdviceEmailSentDate(Timestamp adviceEmailSentDate) {
1051 this.adviceEmailSentDate = adviceEmailSentDate;
1052 }
1053
1054 public String getVendorAliasName() {
1055 return vendorAliasName;
1056 }
1057
1058 public void setVendorAliasName(String vendorAliasName) {
1059 this.vendorAliasName = vendorAliasName;
1060 }
1061
1062
1063
1064
1065
1066 public String getStreet() {
1067 StringBuffer street = new StringBuffer();
1068
1069 street.append(StringUtils.isNotBlank(line1Address) ? (line1Address + OLEConstants.NEWLINE) : OLEConstants.EMPTY_STRING);
1070 street.append(StringUtils.isNotBlank(line2Address) ? (line2Address + OLEConstants.NEWLINE) : OLEConstants.EMPTY_STRING);
1071 street.append(StringUtils.isNotBlank(line3Address) ? (line3Address + OLEConstants.NEWLINE) : OLEConstants.EMPTY_STRING);
1072 street.append(StringUtils.isNotBlank(line4Address) ? (line4Address + OLEConstants.NEWLINE) : OLEConstants.EMPTY_STRING);
1073
1074 return street.toString();
1075 }
1076
1077
1078
1079
1080
1081 public String getPayeeIdTypeDesc() {
1082 String payeeIdTypeCd = getPayeeIdTypeCd();
1083 List<PayeeType> boList = (List) SpringContext.getBean(KeyValuesService.class).findAll(PayeeType.class);
1084 for (PayeeType payeeType : boList) {
1085 if (payeeType.getCode().equalsIgnoreCase(payeeIdTypeCd)) {
1086 return payeeType.getName();
1087 }
1088 }
1089 return OLEConstants.EMPTY_STRING;
1090 }
1091 }