1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.web.struts;
17
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.Properties;
22
23 import javax.servlet.http.HttpServletRequest;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.kuali.ole.fp.businessobject.DisbursementVoucherNonEmployeeExpense;
27 import org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail;
28 import org.kuali.ole.fp.businessobject.DisbursementVoucherPreConferenceRegistrant;
29 import org.kuali.ole.fp.businessobject.TravelPerDiem;
30 import org.kuali.ole.fp.document.DisbursementVoucherConstants;
31 import org.kuali.ole.fp.document.DisbursementVoucherDocument;
32 import org.kuali.ole.fp.document.service.DisbursementVoucherCoverSheetService;
33 import org.kuali.ole.pdp.PdpPropertyConstants;
34 import org.kuali.ole.pdp.businessobject.PurchasingPaymentDetail;
35 import org.kuali.ole.sys.OLEConstants;
36 import org.kuali.ole.sys.OLEParameterKeyConstants;
37 import org.kuali.ole.sys.OLEPropertyConstants;
38 import org.kuali.ole.sys.context.SpringContext;
39 import org.kuali.ole.sys.service.UniversityDateService;
40 import org.kuali.ole.sys.service.impl.OleParameterConstants;
41 import org.kuali.ole.sys.web.struts.KualiAccountingDocumentFormBase;
42 import org.kuali.rice.core.api.config.property.ConfigurationService;
43 import org.kuali.rice.core.web.format.SimpleBooleanFormatter;
44 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
45 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
46 import org.kuali.rice.krad.service.KeyValuesService;
47 import org.kuali.rice.krad.util.KRADConstants;
48 import org.kuali.rice.krad.util.UrlFactory;
49
50
51
52 public class DisbursementVoucherForm extends KualiAccountingDocumentFormBase {
53 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherForm.class);
54
55 protected static final long serialVersionUID = 1L;
56
57 protected String payeeIdNumber;
58 protected String vendorHeaderGeneratedIdentifier = StringUtils.EMPTY;
59 protected String vendorDetailAssignedIdentifier = StringUtils.EMPTY;
60 protected String vendorAddressGeneratedIdentifier;
61
62 protected String tempPayeeIdNumber;
63 protected String tempVendorHeaderGeneratedIdentifier = StringUtils.EMPTY;
64 protected String tempVendorDetailAssignedIdentifier = StringUtils.EMPTY;
65 protected String tempVendorAddressGeneratedIdentifier;
66 protected String oldPayeeType = StringUtils.EMPTY;
67
68 protected boolean hasMultipleAddresses = false;
69
70 protected DisbursementVoucherNonEmployeeExpense newNonEmployeeExpenseLine;
71 protected DisbursementVoucherNonEmployeeExpense newPrePaidNonEmployeeExpenseLine;
72 protected DisbursementVoucherPreConferenceRegistrant newPreConferenceRegistrantLine;
73 protected String wireChargeMessage;
74
75 protected boolean canExport = false;
76
77
78
79
80 public DisbursementVoucherForm() {
81 super();
82 setFormatterType("canPrintCoverSheet", SimpleBooleanFormatter.class);
83 }
84
85 @Override
86 protected String getDefaultDocumentTypeName() {
87 return "OLE_DV";
88 }
89
90
91
92
93 public DisbursementVoucherNonEmployeeExpense getNewNonEmployeeExpenseLine() {
94 return newNonEmployeeExpenseLine;
95 }
96
97
98
99
100 public void setNewNonEmployeeExpenseLine(DisbursementVoucherNonEmployeeExpense newNonEmployeeExpenseLine) {
101 this.newNonEmployeeExpenseLine = newNonEmployeeExpenseLine;
102 }
103
104
105
106
107 public DisbursementVoucherPreConferenceRegistrant getNewPreConferenceRegistrantLine() {
108 return newPreConferenceRegistrantLine;
109 }
110
111
112
113
114 public void setNewPreConferenceRegistrantLine(DisbursementVoucherPreConferenceRegistrant newPreConferenceRegistrantLine) {
115 this.newPreConferenceRegistrantLine = newPreConferenceRegistrantLine;
116 }
117
118
119
120
121 public DisbursementVoucherNonEmployeeExpense getNewPrePaidNonEmployeeExpenseLine() {
122 return newPrePaidNonEmployeeExpenseLine;
123 }
124
125
126
127
128 public void setNewPrePaidNonEmployeeExpenseLine(DisbursementVoucherNonEmployeeExpense newPrePaidNonEmployeeExpenseLine) {
129 this.newPrePaidNonEmployeeExpenseLine = newPrePaidNonEmployeeExpenseLine;
130 }
131
132
133
134
135 public String getWireChargeMessage() {
136 return wireChargeMessage;
137 }
138
139
140
141
142 public void setWireChargeMessage(String wireChargeMessage) {
143 this.wireChargeMessage = wireChargeMessage;
144 }
145
146
147
148
149
150
151 public boolean getCanPrintCoverSheet() {
152 DisbursementVoucherDocument disbursementVoucherDocument = (DisbursementVoucherDocument) this.getDocument();
153 return SpringContext.getBean(DisbursementVoucherCoverSheetService.class).isCoverSheetPrintable(disbursementVoucherDocument);
154 }
155
156
157
158
159 public List<TravelPerDiem> getTravelPerDiemCategoryCodes() {
160 Map<String, Object> criteria = new HashMap<String, Object>();
161 criteria.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear());
162
163 return (List<TravelPerDiem>) SpringContext.getBean(KeyValuesService.class).findMatching(TravelPerDiem.class, criteria);
164 }
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179 public String getPayeeIdNumber() {
180 return payeeIdNumber;
181 }
182
183
184
185
186
187
188 public void setPayeeIdNumber(String payeeIdNumber) {
189 String separator = "-";
190 if (this.isVendor() && StringUtils.contains(payeeIdNumber, separator)) {
191 this.vendorHeaderGeneratedIdentifier = StringUtils.substringBefore(payeeIdNumber, separator);
192 this.vendorDetailAssignedIdentifier = StringUtils.substringAfter(payeeIdNumber, separator);
193 }
194
195 this.payeeIdNumber = payeeIdNumber;
196 }
197
198
199
200
201
202
203 public String getTempPayeeIdNumber() {
204 return tempPayeeIdNumber;
205 }
206
207
208
209
210
211
212 public void setTempPayeeIdNumber(String payeeIdNumber) {
213 String separator = "-";
214 if (this.isVendor() && StringUtils.contains(payeeIdNumber, separator)) {
215 this.tempVendorHeaderGeneratedIdentifier = StringUtils.substringBefore(payeeIdNumber, separator);
216 this.tempVendorDetailAssignedIdentifier = StringUtils.substringAfter(payeeIdNumber, separator);
217 }
218
219 this.tempPayeeIdNumber = payeeIdNumber;
220 }
221
222
223
224
225
226
227
228 public boolean hasMultipleAddresses() {
229 return hasMultipleAddresses;
230 }
231
232
233
234
235
236
237 public boolean getHasMultipleAddresses() {
238 return hasMultipleAddresses;
239 }
240
241
242
243
244
245
246 public void setHasMultipleAddresses(boolean hasMultipleAddresses) {
247 this.hasMultipleAddresses = hasMultipleAddresses;
248 }
249
250
251
252
253
254
255 public String getVendorHeaderGeneratedIdentifier() {
256 return vendorHeaderGeneratedIdentifier;
257 }
258
259
260
261
262
263
264 public void setVendorHeaderGeneratedIdentifier(String vendorHeaderGeneratedIdentifier) {
265 this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
266 }
267
268
269
270
271
272
273 public String getVendorDetailAssignedIdentifier() {
274 return vendorDetailAssignedIdentifier;
275 }
276
277
278
279
280
281
282 public void setVendorDetailAssignedIdentifier(String vendorDetailAssignedIdentifier) {
283 this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier;
284 }
285
286
287
288
289
290
291 public String getVendorAddressGeneratedIdentifier() {
292 return vendorAddressGeneratedIdentifier;
293 }
294
295
296
297
298
299
300 public void setVendorAddressGeneratedIdentifier(String vendorAddressGeneratedIdentifier) {
301 this.vendorAddressGeneratedIdentifier = vendorAddressGeneratedIdentifier;
302 }
303
304 public DisbursementVoucherDocument getDisbursementVoucherDocument() {
305 return (DisbursementVoucherDocument) getDocument();
306
307 }
308
309
310
311 @Override
312 public void populate(HttpServletRequest request) {
313 super.populate(request);
314 DisbursementVoucherPayeeDetail payeeDetail = getDisbursementVoucherDocument().getDvPayeeDetail();
315 SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(payeeDetail);
316 }
317
318
319
320
321
322
323
324
325 public String getTempVendorHeaderGeneratedIdentifier() {
326 return tempVendorHeaderGeneratedIdentifier;
327 }
328
329
330
331
332
333 public void setTempVendorHeaderGeneratedIdentifier(String tempVendorHeaderGeneratedIdentifier) {
334 this.tempVendorHeaderGeneratedIdentifier = tempVendorHeaderGeneratedIdentifier;
335 }
336
337
338
339
340
341 public String getTempVendorDetailAssignedIdentifier() {
342 return tempVendorDetailAssignedIdentifier;
343 }
344
345
346
347
348
349 public void setTempVendorDetailAssignedIdentifier(String tempVendorDetailAssignedIdentifier) {
350 this.tempVendorDetailAssignedIdentifier = tempVendorDetailAssignedIdentifier;
351 }
352
353
354
355
356
357 public String getTempVendorAddressGeneratedIdentifier() {
358 return tempVendorAddressGeneratedIdentifier;
359 }
360
361
362
363
364
365 public void setTempVendorAddressGeneratedIdentifier(String tempVendorAddressGeneratedIdentifier) {
366 this.tempVendorAddressGeneratedIdentifier = tempVendorAddressGeneratedIdentifier;
367 }
368
369
370
371
372
373
374
375 public String getOldPayeeType() {
376 return oldPayeeType;
377 }
378
379
380
381
382
383 public void setOldPayeeType(String oldPayeeType) {
384 this.oldPayeeType = oldPayeeType;
385 }
386
387
388
389
390 public boolean isEmployee() {
391 DisbursementVoucherDocument disbursementVoucherDocument = (DisbursementVoucherDocument) this.getDocument();
392 return disbursementVoucherDocument.getDvPayeeDetail().isEmployee();
393 }
394
395
396
397
398 public boolean isVendor() {
399 DisbursementVoucherDocument disbursementVoucherDocument = (DisbursementVoucherDocument) this.getDocument();
400 return disbursementVoucherDocument.getDvPayeeDetail().isVendor();
401 }
402
403
404
405
406
407 @Override
408 public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
409 if (StringUtils.equals(methodToCallParameterName, KRADConstants.DISPATCH_REQUEST_PARAMETER)) {
410 if (this.getExcludedmethodToCall().contains(methodToCallParameterValue)) {
411 return true;
412 }
413 }
414 return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
415 }
416
417
418
419
420 protected List<String> getExcludedmethodToCall() {
421 List<String> execludedMethodToCall = super.getExcludedmethodToCall();
422 execludedMethodToCall.add("printDisbursementVoucherCoverSheet");
423 execludedMethodToCall.add("showTravelPerDiemLinks");
424
425 return execludedMethodToCall;
426 }
427
428
429
430
431
432 public boolean isCanExport() {
433 return canExport;
434 }
435
436
437
438
439
440 public void setCanExport(boolean canExport) {
441 this.canExport = canExport;
442 }
443
444
445
446
447
448
449
450
451
452
453
454 public String getDisbursementInfoUrl() {
455 String basePath = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEConstants.APPLICATION_URL_KEY);
456 ParameterService parameterService = SpringContext.getBean(ParameterService.class);
457
458 String orgCode = parameterService.getParameterValueAsString(OleParameterConstants.PURCHASING_BATCH.class, OLEParameterKeyConstants.PurapPdpParameterConstants.PURAP_PDP_ORG_CODE);
459
460 Properties parameters = new Properties();
461 parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.SEARCH_METHOD);
462 parameters.put(OLEConstants.BACK_LOCATION, basePath + "/" + OLEConstants.MAPPING_PORTAL + ".do");
463 parameters.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, PurchasingPaymentDetail.class.getName());
464 parameters.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, "true");
465 parameters.put(OLEConstants.SUPPRESS_ACTIONS, "false");
466 parameters.put(PdpPropertyConstants.PaymentDetail.PAYMENT_UNIT_CODE, orgCode);
467
468 String lookupUrl = UrlFactory.parameterizeUrl(basePath + "/" + OLEConstants.LOOKUP_ACTION, parameters);
469
470 return lookupUrl;
471 }
472 }