1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document;
17
18 import org.apache.commons.lang.StringEscapeUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
21 import org.kuali.ole.docstore.common.document.Bib;
22 import org.kuali.ole.docstore.common.document.BibMarc;
23 import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord;
24 import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecords;
25 import org.kuali.ole.docstore.common.document.content.bib.marc.xstream.BibMarcRecordProcessor;
26 import org.kuali.ole.docstore.common.document.content.enums.DocCategory;
27 import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
28 import org.kuali.ole.DocumentUniqueIDPrefix;
29 import org.kuali.ole.gl.service.SufficientFundsService;
30 import org.kuali.ole.module.purap.PurapConstants;
31 import org.kuali.ole.module.purap.PurapConstants.RequisitionStatuses;
32 import org.kuali.ole.module.purap.PurapParameterConstants;
33 import org.kuali.ole.module.purap.PurapWorkflowConstants;
34 import org.kuali.ole.module.purap.businessobject.DefaultPrincipalAddress;
35 import org.kuali.ole.module.purap.businessobject.PurchaseOrderType;
36 import org.kuali.ole.module.purap.businessobject.RequisitionItem;
37 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
38 import org.kuali.ole.module.purap.document.RequisitionDocument;
39 import org.kuali.ole.module.purap.document.VendorCreditMemoDocument;
40 import org.kuali.ole.module.purap.document.service.OlePurapService;
41 import org.kuali.ole.module.purap.document.service.PurapService;
42 import org.kuali.ole.module.purap.document.service.RequisitionService;
43 import org.kuali.ole.module.purap.service.PurapAccountingService;
44 import org.kuali.ole.select.OleSelectConstant;
45 import org.kuali.ole.select.businessobject.*;
46 import org.kuali.ole.select.document.service.*;
47 import org.kuali.ole.select.service.BibInfoService;
48 import org.kuali.ole.select.service.BibInfoWrapperService;
49 import org.kuali.ole.select.service.FileProcessingService;
50 import org.kuali.ole.select.service.impl.BibInfoServiceImpl;
51 import org.kuali.ole.select.service.impl.exception.DocStoreConnectionException;
52 import org.kuali.ole.sys.OLEConstants;
53 import org.kuali.ole.sys.OLEPropertyConstants;
54 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
55 import org.kuali.ole.sys.businessobject.SourceAccountingLine;
56 import org.kuali.ole.sys.businessobject.SufficientFundsItem;
57 import org.kuali.ole.sys.context.SpringContext;
58 import org.kuali.ole.sys.service.GeneralLedgerPendingEntryService;
59 import org.kuali.ole.sys.service.UniversityDateService;
60 import org.kuali.ole.sys.service.impl.OleParameterConstants;
61 import org.kuali.ole.vnd.businessobject.VendorAlias;
62 import org.kuali.rice.core.api.config.property.ConfigContext;
63 import org.kuali.rice.core.api.config.property.ConfigurationService;
64 import org.kuali.rice.core.api.datetime.DateTimeService;
65 import org.kuali.rice.core.api.util.RiceKeyConstants;
66 import org.kuali.rice.core.api.util.type.KualiDecimal;
67 import org.kuali.rice.core.api.util.type.KualiInteger;
68 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
69 import org.kuali.rice.coreservice.api.parameter.Parameter;
70 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
71 import org.kuali.rice.coreservice.framework.parameter.ParameterConstants.COMPONENT;
72 import org.kuali.rice.coreservice.framework.parameter.ParameterConstants.NAMESPACE;
73 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
74 import org.kuali.rice.kew.api.action.ActionRequestType;
75 import org.kuali.rice.kew.api.action.RoutingReportCriteria;
76 import org.kuali.rice.kew.api.document.WorkflowDocumentService;
77 import org.kuali.rice.kew.api.exception.WorkflowException;
78 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
79 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
80 import org.kuali.rice.kim.api.identity.Person;
81 import org.kuali.rice.kim.api.identity.PersonService;
82 import org.kuali.rice.krad.bo.Note;
83 import org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent;
84 import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
85 import org.kuali.rice.krad.rules.rule.event.RouteDocumentEvent;
86 import org.kuali.rice.krad.service.BusinessObjectService;
87 import org.kuali.rice.krad.service.DocumentHeaderService;
88 import org.kuali.rice.krad.service.DocumentService;
89 import org.kuali.rice.krad.service.KRADServiceLocator;
90 import org.kuali.rice.krad.util.GlobalVariables;
91 import org.kuali.rice.krad.util.ObjectUtils;
92
93 import java.math.BigDecimal;
94 import java.text.SimpleDateFormat;
95 import java.util.*;
96
97
98 @NAMESPACE(namespace = OleParameterConstants.PURCHASING_NAMESPACE)
99 @COMPONENT(component = "Requisition")
100 public class OleRequisitionDocument extends RequisitionDocument {
101
102
103
104
105 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleRequisitionDocument.class);
106
107 private static final String dateTimeFormat = "MMddHHmm";
108 private static final String dateFormat = "MMddyy";
109 private static final String timeStampFormat = "MMddyyHHmm";
110 private String vendorPoNumber;
111 private PurchasingAccountsPayableDocument purchasingAccountsPayableDocument;
112 private String vendorAliasName;
113 private DocstoreClientLocator docstoreClientLocator;
114 private static transient ConfigurationService kualiConfigurationService;
115 private static transient BibInfoWrapperService bibInfoWrapperService;
116 private static transient DateTimeService dateTimeService;
117 private static transient OleRequestSourceService oleRequestSourceService;
118 private static transient PurchaseOrderTypeService purchaseOrderTypeService;
119 private static transient FileProcessingService fileProcessingService;
120 private static transient BusinessObjectService businessObjectService;
121 private static transient ParameterService parameterService;
122 private static transient RequisitionService RequisitionService;
123 private static transient OlePurchaseOrderService olePurchaseOrderService;
124 private static transient WorkflowDocumentService workflowDocumentService;
125 private static transient OlePurapAccountingService olePurapAccountingService;
126 private static transient PurapService purapServiceImpl;
127 private static transient BibInfoService bibInfoService;
128 private static transient OlePurapService olePurapService;
129 private static transient OlePatronDocumentList olePatronDocumentList;
130 private static transient OleCopyHelperService oleCopyHelperService;
131
132 public String getVendorAliasName() {
133 return vendorAliasName;
134 }
135
136 public void setVendorAliasName(String vendorAliasName) {
137 this.vendorAliasName = vendorAliasName;
138 }
139
140 public DocstoreClientLocator getDocstoreClientLocator() {
141 if (null == docstoreClientLocator) {
142 return SpringContext.getBean(DocstoreClientLocator.class);
143 }
144 return docstoreClientLocator;
145 }
146
147 @Override
148 public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperationException {
149 if (nodeName.equals(PurapWorkflowConstants.HAS_ACCOUNTING_LINES)) {
150 return !isMissingAccountingLines();
151 }
152
153
154
155 if (nodeName.equals(PurapWorkflowConstants.AMOUNT_REQUIRES_SEPARATION_OF_DUTIES_REVIEW_SPLIT)) {
156 return isSeparationOfDutiesReviewRequired();
157
158
159
160
161 }
162
163
164
165
166
167
168 if (nodeName.equals(PurapWorkflowConstants.YBP_ORDERS)) {
169 return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM);
170 }
171 if (nodeName.equals(PurapWorkflowConstants.STANDING_ORDERS)) {
172 return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_STANDING);
173 }
174 if (nodeName.equals(PurapWorkflowConstants.SUBSCRIPTION_ORDERS)) {
175 return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_SUBSCRIPTION);
176 }
177 if (nodeName.equals(PurapWorkflowConstants.APPROVAL_ORDERS)) {
178 return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_APPROVAL);
179 }
180 if (nodeName.equals(PurapWorkflowConstants.HAS_VENDOR)) {
181 return isMissingVendor();
182 }
183 if (nodeName.equals(PurapWorkflowConstants.HAS_FIRMFIXED_WITH_LR)) {
184 return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM);
185 }
186 if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) {
187 return isBudgetReviewRequired();
188 }
189 if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) {
190 return isNotificationRequired();
191 }
192 throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\"");
193 }
194
195
196
197
198 protected boolean isMissingVendor() {
199 if (this.getVendorHeaderGeneratedIdentifier() == null || this.getVendorDetailAssignedIdentifier() == null) {
200 return false;
201 } else {
202 return true;
203 }
204 }
205
206
207
208
209
210
211
212
213
214
215 @Override
216 protected boolean isMissingAccountingLines() {
217 for (Iterator iterator = getItems().iterator(); iterator.hasNext(); ) {
218 RequisitionItem item = (RequisitionItem) iterator.next();
219 if (item.isConsideredEntered() && item.isAccountListEmpty()) {
220 return true;
221 }
222 }
223
224 return false;
225 }
226
227
228
229
230 protected boolean isRequiredOrderType(BigDecimal purchaseOrderTypeId, String orderType) {
231 LOG.debug("----Inside isRequiredOrderType------");
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250 return true;
251 }
252
253 public static OlePurapAccountingService getOlePurapAccountingService() {
254 if (olePurapAccountingService == null) {
255 olePurapAccountingService = SpringContext.getBean(OlePurapAccountingService.class);
256 }
257 return olePurapAccountingService;
258 }
259
260 public static void setOlePurapAccountingService(OlePurapAccountingService olePurapAccountingService) {
261 OleRequisitionDocument.olePurapAccountingService = olePurapAccountingService;
262 }
263
264 public static PurapService getPurapServiceImpl() {
265 if (purapServiceImpl == null) {
266 purapServiceImpl = SpringContext.getBean(PurapService.class);
267 }
268 return purapServiceImpl;
269 }
270
271 public static void setPurapServiceImpl(PurapService purapServiceImpl) {
272 OleRequisitionDocument.purapServiceImpl = purapServiceImpl;
273 }
274
275 public static OlePurchaseOrderService getOlePurchaseOrderService() {
276 if (olePurchaseOrderService == null) {
277 olePurchaseOrderService = SpringContext.getBean(OlePurchaseOrderService.class);
278 }
279 return olePurchaseOrderService;
280 }
281
282 public static void setOlePurchaseOrderService(OlePurchaseOrderService olePurchaseOrderService) {
283 OleRequisitionDocument.olePurchaseOrderService = olePurchaseOrderService;
284 }
285
286 public static WorkflowDocumentService getWorkflowDocumentService() {
287 if (workflowDocumentService == null) {
288 workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
289 }
290 return workflowDocumentService;
291 }
292
293 public static void setWorkflowDocumentService(WorkflowDocumentService workflowDocumentService) {
294 OleRequisitionDocument.workflowDocumentService = workflowDocumentService;
295 }
296
297 @Override
298 public ParameterService getParameterService() {
299 if (parameterService == null) {
300 parameterService = SpringContext.getBean(ParameterService.class);
301 }
302 return parameterService;
303 }
304
305 public static void setParameterService(ParameterService parameterService) {
306 OleRequisitionDocument.parameterService = parameterService;
307 }
308
309 public static RequisitionService getRequisitionService() {
310 if (RequisitionService == null) {
311 RequisitionService = SpringContext.getBean(RequisitionService.class);
312 }
313 return RequisitionService;
314 }
315
316 public static void setRequisitionService(RequisitionService RequisitionService) {
317 OleRequisitionDocument.RequisitionService = RequisitionService;
318 }
319
320 public static ConfigurationService getConfigurationService() {
321 if (kualiConfigurationService == null) {
322 kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
323 }
324 return kualiConfigurationService;
325 }
326
327 public static void setConfigurationService(ConfigurationService kualiConfigurationService) {
328 OleRequisitionDocument.kualiConfigurationService = kualiConfigurationService;
329 }
330
331 public static BibInfoWrapperService getBibInfoWrapperService() {
332 if (bibInfoWrapperService == null) {
333 bibInfoWrapperService = SpringContext.getBean(BibInfoWrapperService.class);
334 }
335 return bibInfoWrapperService;
336 }
337
338 public static void setBibInfoWrapperService(BibInfoWrapperService bibInfoWrapperService) {
339 OleRequisitionDocument.bibInfoWrapperService = bibInfoWrapperService;
340 }
341
342 public static OleRequestSourceService getOleRequestSourceService() {
343 if (oleRequestSourceService == null) {
344 oleRequestSourceService = SpringContext.getBean(OleRequestSourceService.class);
345 }
346 return oleRequestSourceService;
347 }
348
349 public static void setOleRequestSourceService(OleRequestSourceService oleRequestSourceService) {
350 OleRequisitionDocument.oleRequestSourceService = oleRequestSourceService;
351 }
352
353
354 public static PurchaseOrderTypeService getPurchaseOrderTypeService() {
355 if (purchaseOrderTypeService == null) {
356 purchaseOrderTypeService = SpringContext.getBean(PurchaseOrderTypeService.class);
357 }
358 return purchaseOrderTypeService;
359 }
360
361 public static void setPurchaseOrderTypeService(PurchaseOrderTypeService purchaseOrderTypeService) {
362 OleRequisitionDocument.purchaseOrderTypeService = purchaseOrderTypeService;
363 }
364
365
366 public static FileProcessingService getFileProcessingService() {
367 if (fileProcessingService == null) {
368 fileProcessingService = SpringContext.getBean(FileProcessingService.class);
369 }
370 return fileProcessingService;
371 }
372
373 public static void setFileProcessingService(FileProcessingService fileProcessingService) {
374 OleRequisitionDocument.fileProcessingService = fileProcessingService;
375 }
376
377 public static DateTimeService getDateTimeService() {
378 if (dateTimeService == null) {
379 dateTimeService = SpringContext.getBean(DateTimeService.class);
380 }
381 return dateTimeService;
382 }
383
384 public static void setDateTimeService(DateTimeService dateTimeService) {
385 OleRequisitionDocument.dateTimeService = dateTimeService;
386 }
387
388 @Override
389 public BusinessObjectService getBusinessObjectService() {
390 if (businessObjectService == null) {
391 businessObjectService = SpringContext.getBean(BusinessObjectService.class);
392 }
393 return businessObjectService;
394 }
395
396 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
397 this.businessObjectService = businessObjectService;
398 }
399
400 public static BibInfoService getBibInfoService() {
401 if (bibInfoService == null) {
402 bibInfoService = SpringContext.getBean(BibInfoServiceImpl.class);
403 }
404 return bibInfoService;
405 }
406
407 public static void setBibInfoService(BibInfoService bibInfoService) {
408 OleRequisitionDocument.bibInfoService = bibInfoService;
409 }
410
411 public static OlePurapService getOlePurapService() {
412 if (olePurapService == null) {
413 olePurapService = SpringContext.getBean(OlePurapService.class);
414 }
415 return olePurapService;
416 }
417
418 public static void setOlePurapService(OlePurapService olePurapService) {
419 OleRequisitionDocument.olePurapService = olePurapService;
420 }
421
422 public static OlePatronDocumentList getOlePatronDocumentList() {
423 if (olePatronDocumentList == null) {
424 olePatronDocumentList = SpringContext.getBean(OlePatronDocumentList.class);
425 }
426 return olePatronDocumentList;
427 }
428
429 public static void setOlePatronDocumentList(OlePatronDocumentList olePatronDocumentList) {
430 OleRequisitionDocument.olePatronDocumentList = olePatronDocumentList;
431 }
432
433 public static OleCopyHelperService getOleCopyHelperService() {
434 if(oleCopyHelperService == null){
435 oleCopyHelperService = SpringContext.getBean(OleCopyHelperService.class);
436 }
437 return oleCopyHelperService;
438 }
439
440 public static void setOleCopyHelperService(OleCopyHelperService oleCopyHelperService) {
441 OleRequisitionDocument.oleCopyHelperService = oleCopyHelperService;
442 }
443
444 @Override
445 public void prepareForSave() {
446 try {
447 LOG.debug("###########Inside OleRequisitionDocument prepareForSave###########");
448 if (this.getRequisitionSourceCode() == null) {
449 this.setRequisitionSourceCode(OleSelectConstant.REQUISITON_SRC_TYPE_DIRECTINPUT);
450 }
451 List<OleRequisitionItem> items = this.getItems();
452 Iterator iterator = items.iterator();
453 while (iterator.hasNext()) {
454 LOG.debug("###########inside prepareForSave ole requisition item###########");
455 OleRequisitionItem singleItem = (OleRequisitionItem) iterator.next();
456 KRADServiceLocator.getBusinessObjectService().delete(singleItem.getDeletedCopiesList());
457 setItemDetailWhilePrepareForSave(singleItem);
458 setDocumentHeaderDescription(singleItem);
459
460 if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_WEBFORM)) {
461 createBib(singleItem);
462 }
463 }
464 } catch (DocStoreConnectionException dsce) {
465 GlobalVariables.getMessageMap().putError("error.requisition.docstore.connectionError", RiceKeyConstants.ERROR_CUSTOM, "Error while connecting to document storage server, contact system administrator.");
466 } catch (Exception e) {
467 LOG.error("Exception during prepareForSave() in OleRequisitionDocument", e);
468 GlobalVariables.getMessageMap().putError("error.requisition.docstore.connectionError", RiceKeyConstants.ERROR_CUSTOM, e.getMessage());
469 throw new RuntimeException(e);
470 }
471 }
472
473
474
475
476
477 private void setItemDetailWhilePrepareForSave(OleRequisitionItem singleItem){
478 if (!this.getRequisitionSourceCode().equalsIgnoreCase(
479 OleSelectConstant.REQUISITON_SRC_TYPE_DIRECTINPUT)) {
480 singleItem.setVendorItemPoNumber(this.vendorPoNumber);
481 }
482 if (singleItem.getRequestSourceTypeId() == null) {
483 setRequestSourceTypeId(singleItem);
484 if(this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_AUTOINGEST)){
485 if (singleItem.getCopyList() == null || singleItem.getCopyList().size() == 0) {
486 singleItem.setCopyList(getCopyList(singleItem));
487 }
488 }
489 if (singleItem.getBibInfoBean() != null) {
490 singleItem.getBibInfoBean().setRequestSource(OleSelectConstant.REQUEST_SRC_TYPE_STAFF);
491 }
492 }
493 if (!StringUtils.isEmpty(singleItem.getInternalRequestorId()) && singleItem.getRequestorTypeId() == null) {
494 singleItem.setRequestorTypeId(getOlePurapService().getRequestorTypeId(OleSelectConstant.REQUESTOR_TYPE_STAFF));
495 }
496 }
497
498
499
500
501
502 private void createBib(OleRequisitionItem singleItem){
503 LOG.debug("### Inside createBib() on OleRequisitionDocument ###");
504 try{
505 if (singleItem.getBibInfoBean() != null && singleItem.getBibInfoBean().getTitle() != null && singleItem.getItemTitleId() == null) {
506 List<BibMarcRecord> bibMarcRecordList = new ArrayList<>();
507 BibMarcRecords bibMarcRecords = new BibMarcRecords();
508 BibMarcRecord bibMarcRecord = new BibMarcRecord();
509 getOlePurapService().setBibMarcRecord(bibMarcRecord,singleItem.getBibInfoBean());
510 bibMarcRecordList.add(bibMarcRecord);
511 bibMarcRecords.setRecords(bibMarcRecordList);
512 BibMarcRecordProcessor bibMarcRecordProcessor = new BibMarcRecordProcessor();
513 Bib newBib = new BibMarc();
514 newBib.setCategory(DocCategory.WORK.getCode());
515 newBib.setType(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode());
516 newBib.setFormat(DocFormat.MARC.getCode());
517 newBib.setContent(bibMarcRecordProcessor.toXml(bibMarcRecords));
518 getDocstoreClientLocator().getDocstoreClient().createBib(newBib);
519 newBib.deserializeContent(newBib);
520 if (newBib.getId() != null) {
521 singleItem.setItemTitleId(newBib.getId());
522 singleItem.getBibInfoBean().setTitleId(newBib.getId());
523 singleItem.setItemDescription(getOlePurapService().getItemDescription(newBib));
524
525 }
526 }
527 }catch(Exception e){
528 LOG.error("Exception while creating bib for Preorderservice in OleRequisitionDocument class",e);
529 }
530 }
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549 private void setRequestSourceTypeId(OleRequisitionItem singleItem){
550 try{
551 if(LOG.isInfoEnabled()){
552 LOG.info("RequisitionSourceCode---->" + this.getRequisitionSourceCode());
553 }
554 if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_DIRECTINPUT)) {
555 singleItem.setRequestSourceTypeId(getOleRequestSourceService().getRequestSourceTypeId(OleSelectConstant.REQUEST_SRC_TYPE_STAFF));
556 } else if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_WEBFORM)) {
557 singleItem.setRequestSourceTypeId(getOleRequestSourceService().getRequestSourceTypeId(OleSelectConstant.REQUEST_SRC_TYPE_WEBFORM));
558 } else {
559 singleItem.setRequestSourceTypeId(getOleRequestSourceService().getRequestSourceTypeId(OleSelectConstant.REQUEST_SRC_TYPE_BATCHINGEST));
560 }
561 }catch (Exception e){
562 LOG.error("Error while setting RequestSourceTypeId");
563 }
564 }
565
566
567
568
569
570 private List<OleCopy> getCopyList(OleRequisitionItem singleItem){
571 LOG.debug("### Inside getCopyList() of OleRequisitionDocument ###");
572 List<OleCopies> itemCopies = new ArrayList<>();
573 OleRequisitionCopies oleRequisitionCopies = new OleRequisitionCopies();
574 oleRequisitionCopies.setItemCopies(singleItem.getItemQuantity());
575 oleRequisitionCopies.setParts(singleItem.getItemNoOfParts());
576 oleRequisitionCopies.setLocationCopies(singleItem.getItemLocation());
577 if (singleItem.getOleOrderRecord() != null && singleItem.getOleOrderRecord().getOleTxRecord() != null) {
578 oleRequisitionCopies.setCaption(singleItem.getOleOrderRecord().getOleTxRecord().getCaption());
579 if (singleItem.getItemNoOfParts().isGreaterThan(new KualiInteger(1))) {
580 StringBuffer stringBuffer = new StringBuffer();
581 for (int i = 1; i <= singleItem.getItemNoOfParts().intValue(); i++) {
582 stringBuffer.append(i + ",");
583 }
584 oleRequisitionCopies.setVolumeNumber(stringBuffer.toString());
585 } else {
586 oleRequisitionCopies.setVolumeNumber(singleItem.getOleOrderRecord().getOleTxRecord().getVolumeNumber());
587 }
588 }
589 itemCopies.add(oleRequisitionCopies);
590 List<OleCopy> oleCopyList = getOleCopyHelperService().setCopyValuesForList(itemCopies, singleItem.getItemTitleId(), singleItem.getBibTree());
591 if (oleCopyList != null && oleCopyList.size() > 0) {
592 if (oleCopyList.size() == 1) {
593 OleCopy oleCopy = oleCopyList.get(0);
594 singleItem.setItemLocation(oleCopy.getLocation());
595 } else {
596 singleItem.setItemLocation(OLEConstants.MULTIPLE_ITEM_LOC);
597 }
598 }
599 return oleCopyList;
600 }
601
602 private void setDocumentHeaderDescription(OleRequisitionItem singleItem) throws Exception {
603 LOG.debug("### Inside setDocumentHeaderDescription of OleRequisitionDocument ###");
604 if (this.getDocumentHeader().getDocumentDescription() == null || StringUtils.isEmpty(this.getDocumentHeader().getDocumentDescription())) {
605 if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_DIRECTINPUT)) {
606 String operatorInitials = getOlePurapService().getOperatorInitials();
607 this.getDocumentHeader().setDocumentDescription(OleSelectConstant.STAFF_REQUEST + (StringUtils.isEmpty(operatorInitials) ? "" : "_" + operatorInitials) + "_" + getCurrentDateTime());
608 } else if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_WEBFORM)) {
609 String operatorInitials = getOlePurapService().getOperatorInitials();
610 this.getDocumentHeader().setDocumentDescription(OleSelectConstant.WEBFORM_REQUEST + (StringUtils.isEmpty(operatorInitials) ? "" : "_" + operatorInitials) + "_" + getCurrentDateTime());
611 } else if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_MANUALINGEST)) {
612 String operatorInitials = getOlePurapService().getOperatorInitials();
613 this.getDocumentHeader().setDocumentDescription(OLEConstants.MANUAL_INGEST_DOCUMENT_DESCRIPTION + (StringUtils.isEmpty(operatorInitials) ? "" : "_" + operatorInitials) + "_" + getCurrentDateTime() + (StringUtils.isEmpty(singleItem.getBibInfoBean().getYbp()) ? "" : "_" + singleItem.getBibInfoBean().getYbp()));
614 }
615 }
616 }
617
618
619 @Override
620 public void processAfterRetrieve() {
621
622 try {
623 LOG.debug("###########inside OleRequisitionDocument processAfterRetrieve###########");
624 PurchaseOrderType purchaseOrderTypeDoc = getOlePurapService().getPurchaseOrderType(this.getPurchaseOrderTypeId());
625 if(purchaseOrderTypeDoc != null){
626 this.setOrderType(purchaseOrderTypeDoc);
627 }
628 if (this.getVendorAliasName() == null) {
629 populateVendorAliasName();
630 }
631 List<OleRequisitionItem> items = this.getItems();
632 Iterator iterator = items.iterator();
633 while (iterator.hasNext()) {
634 LOG.debug("###Inside while loop of processAfterRetrive()###");
635 OleRequisitionItem singleItem = (OleRequisitionItem) iterator.next();
636 setItemDetailWhileProcessAfterRetrive(singleItem);
637 }
638 } catch (Exception e) {
639 LOG.error("Exception in during processAfterRetrieve for OleRequisitionDocument " + e);
640 throw new RuntimeException(e);
641 }
642 }
643
644
645
646
647
648
649 private void setItemDetailWhileProcessAfterRetrive(OleRequisitionItem singleItem){
650 try{
651 if (LOG.isInfoEnabled()) {
652 LOG.info("Title id while retriving in REQ------>" + singleItem.getItemTitleId());
653 }
654
655
656 if (singleItem.getRequestorId() != null) {
657 singleItem.setRequestorFirstName(getOlePurapService().getPatronName(singleItem.getRequestorId()));
658 }
659 if (singleItem.getItemUnitPrice() != null) {
660 singleItem.setItemUnitPrice(singleItem.getItemUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
661 }
662
663 if (singleItem.getItemTitleId() != null) {
664 LOG.debug("###########inside processAfterRetrieve ole requisition item###########");
665 Bib bib = new BibMarc();
666 if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") {
667 bib = getDocstoreClientLocator().getDocstoreClient().retrieveBib(singleItem.getItemTitleId());
668 singleItem.setBibUUID(bib.getId());
669 }
670 singleItem.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId()));
671 singleItem.setBibInfoBean(new BibInfoBean());
672 singleItem.setItemDescription(getOlePurapService().getItemDescription(bib));
673 }
674 if (singleItem.getItemType() != null && singleItem.getItemType().isQuantityBasedGeneralLedgerIndicator()) {
675 populateCopiesSection(singleItem);
676 }
677 if (singleItem.getCopyList().size() > 0) {
678 getOlePurapService().setInvoiceDocumentsForRequisition(singleItem);
679 }
680 if (singleItem.getClaimDate() == null) {
681 getOlePurapService().setClaimDateForReq(singleItem,this.vendorDetail);
682 }
683 }catch (Exception e){
684 LOG.error("Error while setting the requisition item detail.",e);
685 }
686 }
687
688
689
690
691
692 private void populateCopiesSection(OleRequisitionItem singleItem) {
693 if (singleItem.getCopies().size() > 0) {
694 List<OleCopy> copyList = getOleCopyHelperService().setCopyValuesForList(singleItem.getCopies(), singleItem.getItemTitleId(), null);
695 if (copyList.size() >= singleItem.getCopyList().size()) {
696 int copyCount = 0;
697 for (OleCopy oleCopy : singleItem.getCopyList()) {
698 OleCopy copy = copyList.get(copyCount);
699 oleCopy.setLocation(copy.getLocation());
700 oleCopy.setEnumeration(copy.getEnumeration());
701 oleCopy.setCopyNumber(copy.getCopyNumber());
702 oleCopy.setPartNumber(copy.getPartNumber());
703 oleCopy.setReqDocNum(this.getPurapDocumentIdentifier());
704 copyCount++;
705 }
706 for (int i = copyCount; i < copyList.size(); i++) {
707 singleItem.getCopyList().add(copyList.get(copyCount));
708 copyCount++;
709 }
710 }
711 } else if (singleItem.getCopyList() != null && singleItem.getCopyList().size() == 1) {
712 singleItem.getCopyList().get(0).setReqDocNum(this.getPurapDocumentIdentifier());
713 } else {
714 if (singleItem.getItemQuantity() != null && singleItem.getItemNoOfParts() != null && (singleItem.getItemQuantity().isGreaterThan(new KualiDecimal(1))
715 || singleItem.getItemNoOfParts().isGreaterThan(new KualiInteger(1)))) {
716 singleItem.setCopies(getOleCopyHelperService().setCopiesToLineItem(singleItem.getCopyList(), singleItem.getItemNoOfParts(), singleItem.getItemTitleId()));
717 }
718 }
719 if (singleItem.getItemQuantity() != null && singleItem.getItemNoOfParts() != null && !singleItem.getItemQuantity().isGreaterThan(new KualiDecimal(1))
720 && !singleItem.getItemNoOfParts().isGreaterThan(new KualiInteger(1)) && singleItem.getCopyList().size() > 0) {
721 singleItem.setSingleCopyNumber(singleItem.getCopyList().get(0).getCopyNumber());
722 }
723 }
724
725 @Override
726 public Class getItemClass() {
727
728 return OleRequisitionItem.class;
729 }
730
731
732
733
734
735
736 public String getCurrentDateTime() {
737 LOG.debug("Inside getCurrentDateTime()");
738 Date date = getDateTimeService().getCurrentDate();
739 String currentDate = SpringContext.getBean(DateTimeService.class).toString(date, timeStampFormat);
740 LOG.debug("End of getCurrentDateTime()");
741 return currentDate;
742 }
743
744
745
746
747
748
749 @Override
750 public void initiateDocument() throws WorkflowException {
751 String description = getOlePurapService().getParameter(OLEConstants.REQ_DESC);
752 description = getOlePurapService().setDocumentDescription(description,null);
753 this.getDocumentHeader().setDocumentDescription(description);
754 this.setPurchaseOrderTypeId(getParameterService().getParameterValueAsString(RequisitionDocument.class, PurapParameterConstants.DEFAULT_ORDER_TYPE));
755
756 super.initiateDocument();
757 setDeliveryDetail(this);
758 this.setPurchaseOrderTransmissionMethodCode(OleSelectConstant.METHOD_OF_PO_TRANSMISSION_NOPR);
759
760 getOlePurapService().getInitialCollapseSections(this);
761 }
762
763 public boolean getIsFinalReqs() {
764 if (this.getDocumentHeader().getWorkflowDocument().isFinal()) {
765 return true;
766 }
767 return false;
768 }
769
770 private void setDeliveryDetail(OleRequisitionDocument document) {
771 Person currentUser = GlobalVariables.getUserSession().getPerson();
772 DefaultPrincipalAddress defaultPrincipalAddress = new DefaultPrincipalAddress(currentUser.getPrincipalId());
773 Map addressKeys = getPersistenceService().getPrimaryKeyFieldValues(defaultPrincipalAddress);
774 defaultPrincipalAddress = getBusinessObjectService().findByPrimaryKey(DefaultPrincipalAddress.class, addressKeys);
775 boolean isDefaultAddress = false;
776 if (ObjectUtils.isNotNull(defaultPrincipalAddress) && ObjectUtils.isNotNull(defaultPrincipalAddress.getBuilding())) {
777 isDefaultAddress = defaultPrincipalAddress.getBuilding().isActive();
778 }
779 if (!isDefaultAddress) {
780 Person personImpl = SpringContext.getBean(PersonService.class).getPerson(GlobalVariables.getUserSession().getPrincipalId());
781
782 String defaultRoomNumber = getParameter("DELIVERY_DEFAULT_ROOMNUMBER");
783 if(defaultRoomNumber != null){
784 defaultRoomNumber = defaultRoomNumber.trim();
785 }
786 document.setDeliveryBuildingLine1Address(personImpl.getAddressLine1());
787 document.setDeliveryBuildingLine2Address(personImpl.getAddressLine2());
788
789 if (document.getDeliveryBuildingLine1Address() != null && !(document.getDeliveryBuildingLine1Address().trim().equals(""))) {
790 document.setDeliveryBuildingRoomNumber(defaultRoomNumber);
791 }
792 document.setDeliveryCityName(personImpl.getAddressCity());
793 document.setDeliveryStateCode(personImpl.getAddressStateProvinceCode());
794 document.setDeliveryPostalCode(personImpl.getAddressPostalCode());
795 document.setDeliveryToName(personImpl.getName());
796 document.setDeliveryCountryCode(personImpl.getAddressCountryCode());
797
798 }
799
800 }
801
802
803
804
805
806
807 public String getCurrentDate() {
808 LOG.debug("Inside getCurrentDate()");
809
810 Date date = getDateTimeService().getCurrentDate();
811 SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
812 String currentDate = sdf.format(date);
813 LOG.debug("End of getCurrentDate()");
814 return currentDate;
815 }
816
817
818
819
820 @Override
821 public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
822 LOG.debug("doRouteStatusChange() started");
823 super.doRouteStatusChange(statusChangeEvent);
824 try {
825 if (this.getDocumentHeader().getWorkflowDocument().isProcessed()) {
826 String newRequisitionStatus = PurapConstants.RequisitionStatuses.APPDOC_IN_PROCESS;
827 if (SpringContext.getBean(RequisitionService.class).isAutomaticPurchaseOrderAllowed(this)) {
828 newRequisitionStatus = PurapConstants.RequisitionStatuses.APPDOC_CLOSED;
829 if (this.getDocumentHeader().getDocumentNumber() == null) {
830 this.setDocumentHeader((SpringContext.getBean(DocumentHeaderService.class).getDocumentHeaderById(this.getDocumentNumber())));
831 SpringContext.getBean(OlePurchaseOrderService.class).createAutomaticPurchaseOrderDocument(this);
832 } else {
833 SpringContext.getBean(OlePurchaseOrderService.class).createAutomaticPurchaseOrderDocument(this);
834 }
835 }
836 this.setApplicationDocumentStatus(newRequisitionStatus);
837 }
838
839 else if (this.getDocumentHeader().getWorkflowDocument().isDisapproved()) {
840 String nodeName = getDocumentHeader().getWorkflowDocument().getCurrentNodeNames().iterator().next();
841
842 HashMap<String, String> disApprovedStatusMap = PurapConstants.RequisitionStatuses.getRequistionAppDocStatuses();
843 if (ObjectUtils.isNotNull(nodeName)) {
844 if (StringUtils.isNotBlank(disApprovedStatusMap.get(nodeName))) {
845 this.setApplicationDocumentStatus(disApprovedStatusMap.get(nodeName));
846
847 return;
848 }
849 }
850 logAndThrowRuntimeException("No status found to set for document being disapproved in node '" + nodeName + "'");
851 }
852
853 else if (this.getDocumentHeader().getWorkflowDocument().isCanceled()) {
854 this.setApplicationDocumentStatus(RequisitionStatuses.APPDOC_CANCELLED);
855 }
856 } catch (Exception e) {
857 logAndThrowRuntimeException("Error saving routing data while saving document with id " + getDocumentNumber(), e);
858 }
859 LOG.debug("doRouteStatusChange() ending");
860 }
861
862
863
864
865 @Override
866 public void doRouteLevelChange(DocumentRouteLevelChange change) {
867 LOG.debug("handleRouteLevelChange() started");
868 super.doRouteLevelChange(change);
869 try {
870 String newNodeName = change.getNewNodeName();
871 if (StringUtils.isNotBlank(newNodeName)) {
872 RoutingReportCriteria.Builder reportCriteria = RoutingReportCriteria.Builder
873 .createByDocumentIdAndTargetNodeName(getDocumentNumber(), newNodeName);
874 List<String> desiredActions = new ArrayList<String>(2);
875 desiredActions.add(ActionRequestType.APPROVE.getCode());
876 desiredActions.add(ActionRequestType.COMPLETE.getCode());
877 String note = "";
878 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE)
879 || newNodeName.equalsIgnoreCase(PurapWorkflowConstants.FYI_BUDGET)) {
880 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE)) {
881 note = OLEConstants.SufficientFundCheck.REQ_NOTE;
882 }
883 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.FYI_BUDGET)) {
884 note = OLEConstants.SufficientFundCheck.FYI_NOTE;
885 }
886 DocumentService documentService = SpringContext.getBean(DocumentService.class);
887 Note apoNote = documentService.createNoteFromDocument(this, note);
888 this.addNote(apoNote);
889 documentService.saveDocumentNotes(this);
890
891 }
892 }
893 } catch (Exception e) {
894 String errorMsg = "Workflow Error found checking actions requests on document with id "
895 + getDocumentNumber() + ". *** WILL NOT UPDATE PURAP STATUS ***";
896 LOG.error(errorMsg, e);
897 }
898 }
899
900
901
902
903
904
905 public String getBibeditorCreateURL() {
906 String bibeditorCreateURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_CREATE_URL_KEY);
907 return bibeditorCreateURL;
908 }
909
910 public String getBibSearchURL() {
911 String bibSearchURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_SEARCH_URL_KEY);
912 return bibSearchURL;
913 }
914
915
916
917
918
919
920 public String getDublinEditorEditURL() {
921 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
922 }
923
924
925
926
927
928
929 public String getBibeditorEditURL() {
930 String bibeditorEditURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_URL_KEY);
931 return bibeditorEditURL;
932 }
933
934
935
936
937
938
939 public String getInstanceEditorURL() {
940 String instanceEditorURL = getConfigurationService().getPropertyValueAsString(
941 OLEConstants.INSTANCEEDITOR_URL_KEY);
942 return instanceEditorURL;
943 }
944
945
946
947
948
949
950 public String getDublinEditorViewURL() {
951 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
952 }
953
954
955
956
957
958
959 public String getBibeditorViewURL() {
960 String bibeditorViewURL = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEConstants.DOCSTORE_APP_URL_KEY);
961 return bibeditorViewURL;
962 }
963
964
965
966
967
968
969 public String getMarcXMLFileDirLocation() throws Exception {
970 String externaleDirectory = getFileProcessingService().getMarcXMLFileDirLocation();
971 return externaleDirectory;
972 }
973
974 public boolean getIsSplitPO() {
975 LOG.debug("Inside getIsSplitPO of OleRequisitionDocument");
976 if (this.getDocumentHeader().getWorkflowDocument().getDocumentTypeName().equalsIgnoreCase(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_SPLIT) && this.getDocumentHeader().getWorkflowDocument().isSaved()) {
977 return true;
978 }
979 return false;
980 }
981
982 public boolean getIsReOpenPO() {
983 LOG.debug("Inside getIsReOpenPO of OleRequisitionDocument");
984 if (this.getDocumentHeader().getWorkflowDocument().getDocumentTypeName().equalsIgnoreCase(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_REOPEN) && this.getDocumentHeader().getWorkflowDocument().isSaved()) {
985 return true;
986 }
987 return false;
988 }
989
990 public String getVendorPoNumber() {
991 return vendorPoNumber;
992 }
993
994 public void setVendorPoNumber(String vendorPoNumber) {
995 this.vendorPoNumber = vendorPoNumber;
996 }
997
998
999 @Override
1000 public void customPrepareForSave(KualiDocumentEvent event) {
1001
1002 getOlePurapAccountingService().updateAccountAmounts(this);
1003
1004 if (event instanceof RouteDocumentEvent || event instanceof ApproveDocumentEvent) {
1005 if (purchasingAccountsPayableDocument instanceof VendorCreditMemoDocument && ((VendorCreditMemoDocument) purchasingAccountsPayableDocument).isSourceVendor()) {
1006 return;
1007 }
1008 getPurapServiceImpl().calculateTax(this);
1009 }
1010 }
1011
1012
1013
1014
1015
1016
1017 public boolean getIsSaved() {
1018 if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
1019 return true;
1020 }
1021 return false;
1022 }
1023
1024 @Override
1025 public String getLicenseURL() {
1026 return ConfigContext.getCurrentContextConfig().getProperty("license.web.service.url");
1027 }
1028
1029
1030 public boolean isBudgetReviewRequired() {
1031 OleRequisitionDocumentService oleRequisitionDocumentService = (OleRequisitionDocumentService) SpringContext
1032 .getBean("oleRequisitionDocumentService");
1033 List<SourceAccountingLine> sourceAccountingLineList = this.getSourceAccountingLines();
1034 boolean sufficientFundCheck = false;
1035 for (SourceAccountingLine accLine : sourceAccountingLineList) {
1036 String notificationOption = null;
1037 Map<String, Object> key = new HashMap<String, Object>();
1038 String chartCode = accLine.getChartOfAccountsCode();
1039 String accNo = accLine.getAccountNumber();
1040 key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
1041 key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo);
1042 OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(
1043 OleSufficientFundCheck.class, key);
1044 if (account != null) {
1045 notificationOption = account.getNotificationOption();
1046 }
1047 if (notificationOption != null
1048 && (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW))) {
1049 sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine);
1050 if (sufficientFundCheck) {
1051 return sufficientFundCheck;
1052 }
1053
1054 }
1055 }
1056 return sufficientFundCheck;
1057 }
1058
1059 private boolean isNotificationRequired() {
1060 OleRequisitionDocumentService oleRequisitionDocumentService = (OleRequisitionDocumentService) SpringContext
1061 .getBean("oleRequisitionDocumentService");
1062 List<SourceAccountingLine> sourceAccountingLineList = this.getSourceAccountingLines();
1063 boolean sufficientFundCheck = false;
1064 for (SourceAccountingLine accLine : sourceAccountingLineList) {
1065 String notificationOption = null;
1066 Map<String, Object> key = new HashMap<String, Object>();
1067 String chartCode = accLine.getChartOfAccountsCode();
1068 String accNo = accLine.getAccountNumber();
1069 key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
1070 key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo);
1071 OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(
1072 OleSufficientFundCheck.class, key);
1073 if (account != null) {
1074 notificationOption = account.getNotificationOption();
1075 }
1076 if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) {
1077 sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine);
1078 if (sufficientFundCheck) {
1079 return sufficientFundCheck;
1080 }
1081 }
1082 }
1083 return sufficientFundCheck;
1084 }
1085
1086 @Override
1087 protected void populateAccountsForRouting() {
1088
1089 List<SufficientFundsItem> fundsItems = new ArrayList<SufficientFundsItem>();
1090 try {
1091 String nodeName = getFinancialSystemDocumentHeader().getWorkflowDocument().getCurrentNodeNames().iterator()
1092 .next();
1093 if (nodeName != null
1094 && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName
1095 .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) {
1096 if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()
1097 .compareTo(getPostingYear()) >= 0) {
1098 List<GeneralLedgerPendingEntry> pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking();
1099 for (GeneralLedgerPendingEntry glpe : pendingEntries) {
1100 glpe.getChartOfAccountsCode();
1101 }
1102 SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber());
1103 fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFunds(
1104 pendingEntries);
1105 SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(
1106 this);
1107 SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries());
1108 }
1109 SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this);
1110 accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems()));
1111 List<String> fundsItemList = new ArrayList<String>();
1112 for (SufficientFundsItem fundsItem : fundsItems) {
1113 fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode());
1114 }
1115 setAccountsForRouting(accountsForRouting);
1116 refreshNonUpdateableReferences();
1117 for (SourceAccountingLine sourceLine : getAccountsForRouting()) {
1118 sourceLine.refreshNonUpdateableReferences();
1119 }
1120 } else {
1121 super.populateAccountsForRouting();
1122 }
1123 } catch (Exception e) {
1124 logAndThrowRuntimeException("Error in populateAccountsForRouting while submitting document with id "
1125 + getDocumentNumber(), e);
1126 }
1127
1128 }
1129
1130 private void populateVendorAliasName() {
1131 Map vendorDetailMap = new HashMap();
1132 vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
1133 vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
1134 List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
1135 if (vendorDetailList != null && vendorDetailList.size() > 0) {
1136 this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
1137 }
1138 }
1139
1140 public boolean getIsATypeOfRCVGDoc() {
1141 return false;
1142 }
1143
1144 public boolean getIsATypeOfCORRDoc() {
1145 return false;
1146 }
1147
1148 public String getParameter(String name){
1149 ParameterKey parameterKey = ParameterKey.create(org.kuali.ole.OLEConstants.APPL_ID, org.kuali.ole.OLEConstants.SELECT_NMSPC, org.kuali.ole.OLEConstants.SELECT_CMPNT,name);
1150 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
1151 return parameter!=null?parameter.getValue():null;
1152 }
1153 }