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.LinkedHashMap;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.pdp.PdpPropertyConstants;
23 import org.kuali.ole.pdp.PdpConstants.PayeeIdTypeCodes;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.vnd.businessobject.VendorDetail;
26 import org.kuali.ole.vnd.document.service.VendorService;
27 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
28 import org.kuali.rice.core.api.util.type.KualiInteger;
29 import org.kuali.rice.kim.api.identity.Person;
30 import org.kuali.rice.kim.api.identity.PersonService;
31 import org.kuali.rice.kim.api.identity.entity.EntityDefault;
32 import org.kuali.rice.kim.api.identity.principal.Principal;
33 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
34 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
35 import org.kuali.rice.krad.util.ObjectUtils;
36
37 public class PayeeACHAccount extends PersistableBusinessObjectBase implements MutableInactivatable {
38
39 private KualiInteger achAccountGeneratedIdentifier;
40 private String bankRoutingNumber;
41 private String bankAccountNumber;
42 private String payeeIdNumber;
43 private String payeeName;
44 private String payeeEmailAddress;
45 private String payeeIdentifierTypeCode;
46 private String achTransactionType;
47 private String bankAccountTypeCode;
48 private boolean active;
49
50 private ACHBank bankRouting;
51 private ACHTransactionType transactionType;
52 private ACHPayee achPayee;
53
54
55
56
57 public PayeeACHAccount() {
58
59 }
60
61
62
63
64
65
66 public KualiInteger getAchAccountGeneratedIdentifier() {
67 return achAccountGeneratedIdentifier;
68 }
69
70
71
72
73
74
75 public void setAchAccountGeneratedIdentifier(KualiInteger achAccountGeneratedIdentifier) {
76 this.achAccountGeneratedIdentifier = achAccountGeneratedIdentifier;
77 }
78
79
80
81
82
83
84
85 public String getBankRoutingNumber() {
86 return bankRoutingNumber;
87 }
88
89
90
91
92
93
94 public void setBankRoutingNumber(String bankRoutingNumber) {
95 this.bankRoutingNumber = bankRoutingNumber;
96 }
97
98
99
100
101
102
103
104 public String getBankAccountNumber() {
105 return bankAccountNumber;
106 }
107
108
109
110
111
112
113 public void setBankAccountNumber(String bankAccountNumber) {
114 this.bankAccountNumber = bankAccountNumber;
115 }
116
117
118
119
120
121
122
123 public String getPayeeName() {
124
125 if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
126 Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
127 if (ObjectUtils.isNotNull(person)) {
128 return person.getName();
129 }
130 }
131
132 else if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
133 if(ObjectUtils.isNotNull(payeeIdNumber)) {
134 EntityDefault entity = KimApiServiceLocator.getIdentityService().getEntityDefault(payeeIdNumber);
135 if (ObjectUtils.isNotNull(entity) && ObjectUtils.isNotNull(entity.getName())) {
136 return entity.getName().getCompositeName();
137 }
138 }
139 }
140
141 else if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.VENDOR_ID)) {
142 VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail(payeeIdNumber);
143 if (ObjectUtils.isNotNull(vendor)) {
144 return vendor.getVendorName();
145 }
146 }
147
148
149 return payeeName;
150 }
151
152
153
154
155
156
157 public void setPayeeName(String payeeName) {
158 this.payeeName = payeeName;
159 }
160
161
162
163
164
165
166
167 public String getPayeeEmailAddress() {
168
169 if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
170 Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
171 if (ObjectUtils.isNotNull(person)) {
172 return person.getEmailAddress();
173 }
174 }
175
176 else if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
177 if(ObjectUtils.isNotNull(payeeIdNumber)) {
178 EntityDefault entity = KimApiServiceLocator.getIdentityService().getEntityDefault(payeeIdNumber);
179 if (ObjectUtils.isNotNull(entity)) {
180 List<Principal> principals = entity.getPrincipals();
181 if (principals.size() > 0 && ObjectUtils.isNotNull(principals.get(0))) {
182 String principalId = principals.get(0).getPrincipalId();
183 Person person = SpringContext.getBean(PersonService.class).getPerson(principalId);
184 if (ObjectUtils.isNotNull(person)) {
185 return person.getEmailAddress();
186 }
187 }
188 }
189 }
190 }
191
192
193 return payeeEmailAddress;
194 }
195
196
197
198
199
200
201 public void setPayeeEmailAddress(String payeeEmailAddress) {
202 this.payeeEmailAddress = payeeEmailAddress;
203 }
204
205
206
207
208
209
210 public String getPayeeIdentifierTypeCode() {
211 return payeeIdentifierTypeCode;
212 }
213
214
215
216
217
218
219 public void setPayeeIdentifierTypeCode(String payeeIdentifierTypeCode) {
220 this.payeeIdentifierTypeCode = payeeIdentifierTypeCode;
221 }
222
223
224
225
226
227
228 public String getAchTransactionType() {
229 return achTransactionType;
230 }
231
232
233
234
235
236
237 public void setAchTransactionType(String achTransactionType) {
238 this.achTransactionType = achTransactionType;
239 }
240
241
242
243
244
245
246 public ACHTransactionType getTransactionType() {
247 return transactionType;
248 }
249
250
251
252
253
254
255 public void setTransactionType(ACHTransactionType transactionType) {
256 this.transactionType = transactionType;
257 }
258
259
260
261
262
263
264 @Override
265 public boolean isActive() {
266 return active;
267 }
268
269
270
271
272
273
274 @Override
275 public void setActive(boolean active) {
276 this.active = active;
277 }
278
279
280
281
282
283
284 public String getBankAccountTypeCode() {
285 return bankAccountTypeCode;
286 }
287
288
289
290
291
292
293 public void setBankAccountTypeCode(String bankAccountTypeCode) {
294 this.bankAccountTypeCode = bankAccountTypeCode;
295 }
296
297
298
299
300
301
302 public ACHBank getBankRouting() {
303 return bankRouting;
304 }
305
306
307
308
309
310
311
312 @Deprecated
313 public void setBankRouting(ACHBank bankRouting) {
314 this.bankRouting = bankRouting;
315 }
316
317
318
319
320
321
322
323 public String getPayeeIdNumber() {
324 return payeeIdNumber;
325 }
326
327
328
329
330
331
332 public void setPayeeIdNumber(String payeeIdNumber) {
333 this.payeeIdNumber = payeeIdNumber;
334 }
335
336
337
338
339
340
341
342 public ACHPayee getAchPayee() {
343 return achPayee;
344 }
345
346
347
348
349
350
351 public void setAchPayee(ACHPayee achPayee) {
352 this.achPayee = achPayee;
353 }
354
355
356
357
358 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
359 LinkedHashMap m = new LinkedHashMap();
360 if (this.achAccountGeneratedIdentifier != null) {
361 m.put(PdpPropertyConstants.ACH_ACCOUNT_GENERATED_IDENTIFIER, this.achAccountGeneratedIdentifier.toString());
362 }
363 return m;
364 }
365 }