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.ArrayUtils;
19 import org.apache.commons.lang.StringEscapeUtils;
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
22 import org.kuali.ole.docstore.common.document.Bib;
23 import org.kuali.ole.docstore.common.document.BibMarc;
24 import org.kuali.ole.DocumentUniqueIDPrefix;
25 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.BibInfoRecord;
26 import org.kuali.ole.gl.service.SufficientFundsService;
27 import org.kuali.ole.module.purap.PurapConstants;
28 import org.kuali.ole.module.purap.PurapConstants.InvoiceStatuses;
29 import org.kuali.ole.module.purap.PurapParameterConstants;
30 import org.kuali.ole.module.purap.PurapPropertyConstants;
31 import org.kuali.ole.module.purap.PurapWorkflowConstants;
32 import org.kuali.ole.module.purap.businessobject.*;
33 import org.kuali.ole.module.purap.document.InvoiceDocument;
34 import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
35 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
36 import org.kuali.ole.module.purap.document.service.AccountsPayableService;
37 import org.kuali.ole.module.purap.document.service.InvoiceService;
38 import org.kuali.ole.module.purap.document.service.PurapService;
39 import org.kuali.ole.module.purap.document.validation.event.AttributedContinuePurapEvent;
40 import org.kuali.ole.module.purap.service.PurapAccountingService;
41 import org.kuali.ole.module.purap.util.ExpiredOrClosedAccountEntry;
42 import org.kuali.ole.module.purap.util.SummaryAccount;
43 import org.kuali.ole.select.OleSelectConstant;
44 import org.kuali.ole.select.bo.OLELinkPurapDonor;
45 import org.kuali.ole.select.businessobject.*;
46 import org.kuali.ole.select.document.service.OleInvoiceService;
47 import org.kuali.ole.select.document.service.impl.OleInvoiceFundCheckServiceImpl;
48 import org.kuali.ole.select.form.OLEInvoiceForm;
49 import org.kuali.ole.select.service.BibInfoService;
50 import org.kuali.ole.select.service.BibInfoWrapperService;
51 import org.kuali.ole.select.service.FileProcessingService;
52 import org.kuali.ole.select.service.impl.BibInfoServiceImpl;
53 import org.kuali.ole.sys.OLEConstants;
54 import org.kuali.ole.sys.OLEPropertyConstants;
55 import org.kuali.ole.sys.businessobject.Bank;
56 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
57 import org.kuali.ole.sys.businessobject.SourceAccountingLine;
58 import org.kuali.ole.sys.businessobject.SufficientFundsItem;
59 import org.kuali.ole.sys.context.SpringContext;
60 import org.kuali.ole.sys.service.BankService;
61 import org.kuali.ole.sys.service.GeneralLedgerPendingEntryService;
62 import org.kuali.ole.sys.service.UniversityDateService;
63 import org.kuali.ole.vnd.VendorConstants;
64 import org.kuali.ole.vnd.businessobject.OleCurrencyType;
65 import org.kuali.ole.vnd.businessobject.OleExchangeRate;
66 import org.kuali.ole.vnd.businessobject.VendorAddress;
67 import org.kuali.ole.vnd.document.service.VendorService;
68 import org.kuali.rice.core.api.config.property.ConfigContext;
69 import org.kuali.rice.core.api.config.property.ConfigurationService;
70 import org.kuali.rice.core.api.datetime.DateTimeService;
71 import org.kuali.rice.core.api.util.type.KualiDecimal;
72 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
73 import org.kuali.rice.kew.api.KewApiConstants;
74 import org.kuali.rice.kew.api.KewApiServiceLocator;
75 import org.kuali.rice.kew.api.WorkflowDocument;
76 import org.kuali.rice.kew.api.action.ActionRequestType;
77 import org.kuali.rice.kew.api.action.ActionTaken;
78 import org.kuali.rice.kew.api.action.RoutingReportCriteria;
79 import org.kuali.rice.kew.api.exception.WorkflowException;
80 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
81 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
82 import org.kuali.rice.kim.api.identity.Person;
83 import org.kuali.rice.kim.api.identity.PersonService;
84 import org.kuali.rice.kim.api.identity.principal.Principal;
85 import org.kuali.rice.kim.api.services.IdentityManagementService;
86 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
87 import org.kuali.rice.krad.bo.Note;
88 import org.kuali.rice.krad.document.Copyable;
89 import org.kuali.rice.krad.exception.ValidationException;
90 import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
91 import org.kuali.rice.krad.service.BusinessObjectService;
92 import org.kuali.rice.krad.service.DocumentService;
93 import org.kuali.rice.krad.util.GlobalVariables;
94 import org.kuali.rice.krad.util.ObjectUtils;
95 import org.kuali.rice.krad.workflow.service.WorkflowDocumentService;
96
97 import java.math.BigDecimal;
98 import java.math.RoundingMode;
99 import java.util.*;
100
101
102
103
104
105 public class OleInvoiceDocument extends InvoiceDocument implements Copyable {
106
107 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleInvoiceDocument.class);
108
109 private Integer invoiceTypeId;
110 private Integer invoiceSubTypeId;
111 private String vendorId;
112 private String invoiceTypeHdnId;
113 private String invoiceSubTypeHdnId;
114 private String acquisitionUnit;
115 private String empty;
116 protected transient List<SummaryAccount> summaryAccounts;
117 private boolean sfcFlag;
118 private String invoiceItemTotal;
119 private String invoiceForeignItemTotal;
120 private String invoiceAmount;
121 private boolean baSfcFlag;
122 private boolean validationFlag;
123 private boolean blanketApproveValidationFlag;
124 private boolean blanketApproveSubscriptionDateValidationFlag;
125 private boolean subscriptionDateValidationFlag;
126 private String purchaseOrderDocumentNums;
127 private boolean duplicateApproveFlag = false;
128 private boolean blanketApproveFlag=true;
129 private boolean overviewFlag = true;
130 private boolean vendorInfoFlag = true;
131 private boolean invoiceInfoFlag = true;
132 private boolean processItemFlag = false;
133 private boolean processTitlesFlag = false;
134 private boolean currentItemsFlag = false;
135
136
137 private boolean additionalChargesFlag = false;
138 private boolean accountSummaryFlag = false;
139 private boolean notesAndAttachmentFlag = false;
140 private boolean adHocRecipientsFlag = false;
141 private boolean routeLogFlag = false;
142 private boolean routeLogDisplayFlag = false;
143 private boolean unsaved = false;
144 private boolean canClose = false;
145
146 private String cloneDebitInvoice;
147 private boolean cloneFlag = false;
148 private boolean amountExceeds = false;
149 private String exceedsEncumbranceTitle;
150 private String exceedsEncumbranceExtendedCost;
151 private String exceedsEncumbranceListPrice;
152 private boolean amountExceedsForBlanketApprove;
153 private boolean itemSign;
154
155 private String vendorLink;
156 private boolean foreignCurrencyFlag=false;
157 private Long invoiceCurrencyTypeId;
158 private String invoiceCurrencyType;
159 private OleCurrencyType oleCurrencyType;
160 private boolean currencyOverrideFlag = false;
161 private String currencyOverrideMessage;
162 private String invoiceCurrencyExchangeRate;
163 private boolean dbRetrieval= false;
164 private boolean enableCurrentItems = false;
165 private String foreignVendorAmount;
166 private String foreignInvoiceAmount;
167
168 public boolean isBlanketApproveFlag() {
169 return blanketApproveFlag;
170 }
171 private boolean currencyTypeIndicator = true;
172
173 public void setBlanketApproveFlag(boolean blanketApproveFlag) {
174 this.blanketApproveFlag = blanketApproveFlag;
175 }
176
177 private List<OlePaymentRequestDocument> paymentRequestDocuments = new ArrayList<OlePaymentRequestDocument>();
178
179 public boolean isCanClose() {
180 return canClose;
181 }
182
183 public void setCanClose(boolean canClose) {
184 this.canClose = canClose;
185 }
186
187 public boolean isUnsaved() {
188 return unsaved;
189 }
190
191 public void setUnsaved(boolean unsaved) {
192 this.unsaved = unsaved;
193 }
194
195 private boolean duplicateFlag = false;
196
197
198 private BigDecimal priorTotal = new BigDecimal(0);
199
200 public String getAcquisitionUnit() {
201 return acquisitionUnit;
202 }
203
204 public void setAcquisitionUnit(String acquisitionUnit) {
205 this.acquisitionUnit = acquisitionUnit;
206 }
207
208 public BigDecimal getPriorTotal() {
209 return priorTotal;
210 }
211
212 public void setPriorTotal(BigDecimal priorTotal) {
213 this.priorTotal = priorTotal;
214 }
215
216 public String getEmpty() {
217 return empty;
218 }
219
220 public void setEmpty(String empty) {
221 this.empty = empty;
222 }
223
224
225
226
227
228
229 private OleInvoiceSubType oleInvoiceSubType;
230 private OleInvoiceType oleInvoiceType;
231
232
233 private boolean prorateQty;
234 private boolean prorateDollar;
235 private boolean prorateManual;
236 private boolean noProrate;
237
238 private String prorateBy;
239
240 private BigDecimal foreignVendorInvoiceAmount;
241
242 private BigDecimal purchaseOrderTypeId;
243 private PurchaseOrderType orderType;
244 private static transient BibInfoService bibInfoService;
245 private String paymentMethodIdentifier;
246 private Integer paymentMethodId;
247 private OlePaymentMethod paymentMethod;
248 private String vendorFaxNumber;
249
250 protected Integer accountsPayablePurchasingDocumentLinkIdentifier;
251 protected List<PurchasingAccountsPayableDocument> purchaseOrders;
252
253
254 private String invoicedGrandTotal;
255 private String invoicedItemTotal;
256
257 private String searchResultInvoiceDate;
258 private String searchResultInvoicePayDate;
259 private boolean offsetAccountIndicator;
260
261 public boolean isNoProrate() {
262 return noProrate;
263 }
264
265 public void setNoProrate(boolean noProrate) {
266 this.noProrate = noProrate;
267 }
268
269 @SuppressWarnings("rawtypes")
270 public List getPurchaseOrders() {
271 return purchaseOrders;
272 }
273
274 @SuppressWarnings("rawtypes")
275 public void setPurchaseOrders(List purchaseOrders) {
276 this.purchaseOrders = purchaseOrders;
277 }
278
279 public String getVendorFaxNumber() {
280 return vendorFaxNumber;
281 }
282
283 public void setVendorFaxNumber(String vendorFaxNumber) {
284 this.vendorFaxNumber = vendorFaxNumber;
285 }
286
287 public String getPaymentMethodIdentifier() {
288 return paymentMethodIdentifier;
289 }
290
291 public void setPaymentMethodIdentifier(String paymentMethodIdentifier) {
292 this.paymentMethodIdentifier = paymentMethodIdentifier;
293 }
294
295 public String getVendorId() {
296 return vendorId;
297 }
298
299 public void setVendorId(String vendorId) {
300 this.vendorId = vendorId;
301 }
302
303 public String getInvoiceSubTypeHdnId() {
304 return invoiceSubTypeHdnId;
305 }
306
307 public void setInvoiceSubTypeHdnId(String invoiceSubTypeHdnId) {
308 this.invoiceSubTypeHdnId = invoiceSubTypeHdnId;
309 }
310
311
312 private String documentYear;
313 private String documentTotalAmount;
314
315
316
317
318 public String getDocumentYear() {
319 return documentYear;
320 }
321
322 public void setDocumentYear(String documentYear) {
323 this.documentYear = documentYear;
324 }
325
326 public String getDocumentTotalAmount() {
327 if (!isDbRetrieval()) {
328 this.documentTotalAmount = this.getTotalDollarAmount().toString();
329 }
330 return documentTotalAmount;
331
332 }
333
334 public void setDocumentTotalAmount(String documentTotalAmount) {
335 this.documentTotalAmount = documentTotalAmount;
336 }
337
338
339
340
341
342
343
344
345
346 private List<OlePurchaseOrderItem> purchaseOrderItems = new ArrayList<OlePurchaseOrderItem>();
347
348
349 public List<OlePurchaseOrderItem> getPurchaseOrderItems() {
350 return purchaseOrderItems;
351 }
352
353 public void setPurchaseOrderItems(List<OlePurchaseOrderItem> purchaseOrderItems) {
354 this.purchaseOrderItems = purchaseOrderItems;
355 }
356
357 public Integer getPaymentMethodId() {
358 return paymentMethodId;
359 }
360
361 public void setPaymentMethodId(Integer paymentMethodId) {
362 this.paymentMethodId = paymentMethodId;
363 }
364
365 public OlePaymentMethod getPaymentMethod() {
366 return paymentMethod;
367 }
368
369 public void setPaymentMethod(OlePaymentMethod paymentMethod) {
370 this.paymentMethod = paymentMethod;
371 }
372
373 public static BibInfoService getBibInfoService() {
374 if (bibInfoService == null) {
375 bibInfoService = SpringContext.getBean(BibInfoServiceImpl.class);
376 }
377 return bibInfoService;
378 }
379
380 @Override
381 public BigDecimal getPurchaseOrderTypeId() {
382 return purchaseOrderTypeId;
383 }
384
385 @Override
386 public void setPurchaseOrderTypeId(BigDecimal purchaseOrderTypeId) {
387 this.purchaseOrderTypeId = purchaseOrderTypeId;
388 }
389
390 @Override
391 public PurchaseOrderType getOrderType() {
392 return orderType;
393 }
394
395 @Override
396 public Integer getAccountsPayablePurchasingDocumentLinkIdentifier() {
397 return accountsPayablePurchasingDocumentLinkIdentifier;
398 }
399
400 @Override
401 public void setAccountsPayablePurchasingDocumentLinkIdentifier(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
402 this.accountsPayablePurchasingDocumentLinkIdentifier = accountsPayablePurchasingDocumentLinkIdentifier;
403 }
404
405 @Override
406 public void setOrderType(PurchaseOrderType orderType) {
407 this.orderType = orderType;
408 }
409
410 public Integer getInvoiceTypeId() {
411 return invoiceTypeId;
412 }
413
414 public void setInvoiceTypeId(Integer invoiceTypeId) {
415 this.invoiceTypeId = invoiceTypeId;
416 }
417
418 public String getInvoiceTypeHdnId() {
419 return invoiceTypeHdnId;
420 }
421
422 public void setInvoiceTypeHdnId(String invoiceTypeHdnId) {
423 this.invoiceTypeHdnId = invoiceTypeHdnId;
424 }
425
426 public Integer getInvoiceSubTypeId() {
427 return invoiceSubTypeId;
428 }
429
430 public void setInvoiceSubTypeId(Integer invoiceSubTypeId) {
431 this.invoiceSubTypeId = invoiceSubTypeId;
432 }
433
434 public String getInvoiceType() {
435 return invoiceType;
436 }
437
438 public void setInvoiceType(String invoiceType) {
439 this.invoiceType = invoiceType;
440 }
441
442
443 public String getInvoiceSubType() {
444 return invoiceSubType;
445 }
446
447 public void setInvoiceSubType(String invoiceSubType) {
448 this.invoiceSubType = invoiceSubType;
449 }
450
451 public OleInvoiceSubType getOleInvoiceSubType() {
452 return oleInvoiceSubType;
453 }
454
455 public void setOleInvoiceSubType(OleInvoiceSubType oleInvoiceSubType) {
456 this.oleInvoiceSubType = oleInvoiceSubType;
457 }
458
459 public OleInvoiceType getOleInvoiceType() {
460 return oleInvoiceType;
461 }
462
463 public void setOleInvoiceType(OleInvoiceType oleInvoiceType) {
464 this.oleInvoiceType = oleInvoiceType;
465 }
466
467 public boolean isProrateQty() {
468 return prorateQty;
469 }
470
471 public void setProrateQty(boolean prorateQty) {
472 this.prorateQty = prorateQty;
473 }
474
475 public boolean isProrateDollar() {
476 return prorateDollar;
477 }
478
479 public void setProrateDollar(boolean prorateDollar) {
480 this.prorateDollar = prorateDollar;
481 }
482
483 public boolean isProrateManual() {
484 return prorateManual;
485 }
486
487 public void setProrateManual(boolean prorateManual) {
488 this.prorateManual = prorateManual;
489 }
490
491 public boolean isAmountExceeds() {
492 return amountExceeds;
493 }
494
495 public void setAmountExceeds(boolean amountExceeds) {
496 this.amountExceeds = amountExceeds;
497 }
498
499 public String getExceedsEncumbranceTitle() {
500 return exceedsEncumbranceTitle;
501 }
502
503 public void setExceedsEncumbranceTitle(String exceedsEncumbranceTitle) {
504 this.exceedsEncumbranceTitle = exceedsEncumbranceTitle;
505 }
506
507 public String getExceedsEncumbranceExtendedCost() {
508 return exceedsEncumbranceExtendedCost;
509 }
510
511 public void setExceedsEncumbranceExtendedCost(String exceedsEncumbranceExtendedCost) {
512 this.exceedsEncumbranceExtendedCost = exceedsEncumbranceExtendedCost;
513 }
514
515 public String getExceedsEncumbranceListPrice() {
516 return exceedsEncumbranceListPrice;
517 }
518
519 public void setExceedsEncumbranceListPrice(String exceedsEncumbranceListPrice) {
520 this.exceedsEncumbranceListPrice = exceedsEncumbranceListPrice;
521 }
522
523 public boolean isAmountExceedsForBlanketApprove() {
524 return amountExceedsForBlanketApprove;
525 }
526
527 public void setAmountExceedsForBlanketApprove(boolean amountExceedsForBlanketApprove) {
528 this.amountExceedsForBlanketApprove = amountExceedsForBlanketApprove;
529 }
530
531 private static transient ConfigurationService kualiConfigurationService;
532 private static transient BibInfoWrapperService bibInfoWrapperService;
533 private static transient FileProcessingService fileProcessingService;
534 private static transient BusinessObjectService businessObjectService;
535 private static transient VendorService vendorService;
536 private static transient InvoiceService invoiceService;
537 private static transient OleInvoiceService oleInvoiceService;
538 private static transient PurapService purapService;
539 private static transient AccountsPayableService accountsPayableService;
540 private static transient IdentityManagementService identityManagementService;
541 private static transient WorkflowDocumentService workflowDocumentService;
542
543
544 private boolean proformaIndicator;
545
546 public static WorkflowDocumentService getWorkflowDocumentService() {
547 if (workflowDocumentService == null) {
548 workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
549 }
550 return workflowDocumentService;
551 }
552
553 public static void setWorkflowDocumentService(WorkflowDocumentService workflowDocumentService) {
554 OleInvoiceDocument.workflowDocumentService = workflowDocumentService;
555 }
556
557 public static InvoiceService getInvoiceService() {
558 if (invoiceService == null) {
559 invoiceService = SpringContext.getBean(InvoiceService.class);
560 }
561 return invoiceService;
562 }
563
564 public static void setInvoiceService(InvoiceService invoiceService) {
565 OleInvoiceDocument.invoiceService = invoiceService;
566 }
567
568 public static VendorService getVendorService() {
569 if (vendorService == null) {
570 vendorService = SpringContext.getBean(VendorService.class);
571 }
572 return vendorService;
573 }
574
575 public static void setVendorService(VendorService vendorService) {
576 OleInvoiceDocument.vendorService = vendorService;
577 }
578
579 public static PurapService getPurapService() {
580 if (purapService == null) {
581 purapService = SpringContext.getBean(PurapService.class);
582 }
583 return purapService;
584 }
585
586 public static void setPurapService(PurapService purapService) {
587 OleInvoiceDocument.purapService = purapService;
588 }
589
590 public static OleInvoiceService getOleInvoiceService() {
591 if (oleInvoiceService == null) {
592 oleInvoiceService = SpringContext.getBean(OleInvoiceService.class);
593 }
594 return oleInvoiceService;
595 }
596
597 public static void setOleInvoiceService(OleInvoiceService oleInvoiceService) {
598 OleInvoiceDocument.oleInvoiceService = oleInvoiceService;
599 }
600
601 public static IdentityManagementService getIdentityManagementService() {
602 if (identityManagementService == null) {
603 identityManagementService = SpringContext.getBean(IdentityManagementService.class);
604 }
605 return identityManagementService;
606 }
607
608 public static void setIdentityManagementService(IdentityManagementService identityManagementService) {
609 OleInvoiceDocument.identityManagementService = identityManagementService;
610 }
611
612 public static AccountsPayableService getAccountsPayableService() {
613 if (accountsPayableService == null) {
614 accountsPayableService = SpringContext.getBean(AccountsPayableService.class);
615 }
616 return accountsPayableService;
617 }
618
619 public static void setAccountsPayableService(AccountsPayableService accountsPayableService) {
620 OleInvoiceDocument.accountsPayableService = accountsPayableService;
621 }
622
623 public static ConfigurationService getConfigurationService() {
624 if (kualiConfigurationService == null) {
625 kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
626 }
627 return kualiConfigurationService;
628 }
629
630 public static void setConfigurationService(ConfigurationService kualiConfigurationService) {
631 OleInvoiceDocument.kualiConfigurationService = kualiConfigurationService;
632 }
633
634 public static BibInfoWrapperService getBibInfoWrapperService() {
635 if (bibInfoWrapperService == null) {
636 bibInfoWrapperService = SpringContext.getBean(BibInfoWrapperService.class);
637 }
638 return bibInfoWrapperService;
639 }
640
641 public static void setBibInfoWrapperService(BibInfoWrapperService bibInfoWrapperService) {
642 OleInvoiceDocument.bibInfoWrapperService = bibInfoWrapperService;
643 }
644
645
646 public static FileProcessingService getFileProcessingService() {
647 if (fileProcessingService == null) {
648 fileProcessingService = SpringContext.getBean(FileProcessingService.class);
649 }
650 return fileProcessingService;
651 }
652
653 public static void setFileProcessingService(FileProcessingService fileProcessingService) {
654 OleInvoiceDocument.fileProcessingService = fileProcessingService;
655 }
656
657 public static DateTimeService getDateTimeService() {
658 if (dateTimeService == null) {
659 dateTimeService = SpringContext.getBean(DateTimeService.class);
660 }
661 return dateTimeService;
662 }
663
664 public static void setDateTimeService(DateTimeService dateTimeService) {
665 OleInvoiceDocument.dateTimeService = dateTimeService;
666 }
667
668 @Override
669 public BusinessObjectService getBusinessObjectService() {
670 if (businessObjectService == null) {
671 businessObjectService = SpringContext.getBean(BusinessObjectService.class);
672 }
673 return businessObjectService;
674 }
675
676 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
677 this.businessObjectService = businessObjectService;
678 }
679
680
681
682
683 public OleInvoiceDocument() {
684 super();
685
686
687 }
688
689 public void initiateDocument() throws WorkflowException {
690 super.initiateDocument();
691 OleInvoiceItem item;
692 this.setUseTaxIndicator(false);
693 String[] collapseSections = getOleInvoiceService().getDefaultCollapseSections();
694 this.setOverviewFlag(getOleInvoiceService().canCollapse(OLEConstants.OVERVIEW_SECTION, collapseSections));
695 this.setVendorInfoFlag(getOleInvoiceService().canCollapse(OLEConstants.VENDOR_INFO_SECTION, collapseSections));
696 this.setInvoiceInfoFlag(getOleInvoiceService().canCollapse(OLEConstants.INVOICE_INFO_SECTION, collapseSections));
697 this.setProcessTitlesFlag(getOleInvoiceService().canCollapse(OLEConstants.PROCESS_TITLES_SECTION, collapseSections));
698 this.setCurrentItemsFlag(getOleInvoiceService().canCollapse(OLEConstants.CURRENT_ITEM_SECTION, collapseSections));
699 this.setAdditionalChargesFlag(getOleInvoiceService().canCollapse(OLEConstants.ADDITIONAL_CHARGES_SECTION, collapseSections));
700 this.setAccountSummaryFlag(getOleInvoiceService().canCollapse(OLEConstants.ACCOUNT_SUMMARY_SECTION, collapseSections));
701 this.setAdHocRecipientsFlag(getOleInvoiceService().canCollapse(OLEConstants.ADHOC_RECIPIENT_SECTION, collapseSections));
702 this.setRouteLogFlag(getOleInvoiceService().canCollapse(OLEConstants.ROUTE_LOG_SECTION, collapseSections));
703 this.setNotesAndAttachmentFlag(getOleInvoiceService().canCollapse(OLEConstants.NOTES_AND_ATTACH_SECTION, collapseSections));
704
705 if (this.getItems() == null || this.getItems().size() == 0) {
706 this.items = new ArrayList<>();
707 SpringContext.getBean(PurapService.class).addBelowLineItems(this);
708 List<OleInvoiceItem> oleInvItems = this.getItems();
709 for (OleInvoiceItem oleInvoiceItem : oleInvItems) {
710 oleInvoiceItem.setPostingYear(SpringContext.getBean(UniversityDateService.class).getCurrentUniversityDate().getUniversityFiscalYear());
711 }
712 }
713 }
714
715
716
717
718
719
720 @Override
721 public void populateInvoiceFromPurchaseOrder(PurchaseOrderDocument po, HashMap<String, ExpiredOrClosedAccountEntry> expiredOrClosedAccountList) {
722 LOG.debug("Inside populateInvoiceFromPurchaseOrder method of OleInvoice Document");
723 this.setPaymentMethodId(po.getVendorDetail().getPaymentMethodId());
724 this.setPurchaseOrderIdentifier(po.getPurapDocumentIdentifier());
725 this.getDocumentHeader().setOrganizationDocumentNumber(po.getDocumentHeader().getOrganizationDocumentNumber());
726 this.setPostingYear(po.getPostingYear());
727 this.setReceivingDocumentRequiredIndicator(po.isReceivingDocumentRequiredIndicator());
728 this.setUseTaxIndicator(po.isUseTaxIndicator());
729 this.setInvoicePositiveApprovalIndicator(po.isPaymentRequestPositiveApprovalIndicator());
730 this.setVendorCustomerNumber(po.getVendorCustomerNumber());
731
732 if (po.getPurchaseOrderCostSource() != null) {
733 this.setInvoiceCostSource(po.getPurchaseOrderCostSource());
734 this.setInvoiceCostSourceCode(po.getPurchaseOrderCostSourceCode());
735 }
736
737 if (po.getVendorShippingPaymentTerms() != null) {
738 this.setVendorShippingPaymentTerms(po.getVendorShippingPaymentTerms());
739 this.setVendorShippingPaymentTermsCode(po.getVendorShippingPaymentTermsCode());
740 }
741
742 if (po.getVendorPaymentTerms() != null) {
743 this.setVendorPaymentTermsCode(po.getVendorPaymentTermsCode());
744 this.setVendorPaymentTerms(po.getVendorPaymentTerms());
745 }
746
747 if (po.getRecurringPaymentType() != null) {
748 this.setRecurringPaymentType(po.getRecurringPaymentType());
749 this.setRecurringPaymentTypeCode(po.getRecurringPaymentTypeCode());
750 }
751
752 Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(this.getClass());
753 if (defaultBank != null) {
754 this.setBankCode(defaultBank.getBankCode());
755 this.setBank(defaultBank);
756 }
757 this.setVendorHeaderGeneratedIdentifier(po.getVendorHeaderGeneratedIdentifier());
758 this.setVendorDetailAssignedIdentifier(po.getVendorDetailAssignedIdentifier());
759 this.setVendorCustomerNumber(po.getVendorCustomerNumber());
760 this.setVendorName(po.getVendorName());
761
762
763 this.setOriginalVendorHeaderGeneratedIdentifier(po.getVendorHeaderGeneratedIdentifier());
764 this.setOriginalVendorDetailAssignedIdentifier(po.getVendorDetailAssignedIdentifier());
765
766
767 this.setAlternateVendorHeaderGeneratedIdentifier(po.getAlternateVendorHeaderGeneratedIdentifier());
768 this.setAlternateVendorDetailAssignedIdentifier(po.getAlternateVendorDetailAssignedIdentifier());
769
770
771 String userCampus = GlobalVariables.getUserSession().getPerson().getCampusCode();
772 VendorAddress vendorAddress = getVendorService().getVendorDefaultAddress(po.getVendorHeaderGeneratedIdentifier(), po.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.REMIT, userCampus);
773 if (vendorAddress != null) {
774 this.templateVendorAddress(vendorAddress);
775 this.setVendorAddressGeneratedIdentifier(vendorAddress.getVendorAddressGeneratedIdentifier());
776 setVendorAttentionName(StringUtils.defaultString(vendorAddress.getVendorAttentionName()));
777 } else {
778
779 this.setVendorAddressGeneratedIdentifier(po.getVendorAddressGeneratedIdentifier());
780 this.setVendorLine1Address(po.getVendorLine1Address());
781 this.setVendorLine2Address(po.getVendorLine2Address());
782 this.setVendorCityName(po.getVendorCityName());
783 this.setVendorAddressInternationalProvinceName(po.getVendorAddressInternationalProvinceName());
784 this.setVendorStateCode(po.getVendorStateCode());
785 this.setVendorPostalCode(po.getVendorPostalCode());
786 this.setVendorCountryCode(po.getVendorCountryCode());
787
788 boolean blankAttentionLine = StringUtils.equalsIgnoreCase(
789 "Y",
790 SpringContext.getBean(ParameterService.class).getParameterValueAsString(
791 PurapConstants.PURAP_NAMESPACE, "Document",
792 PurapParameterConstants.BLANK_ATTENTION_LINE_FOR_PO_TYPE_ADDRESS));
793
794 if (blankAttentionLine) {
795 setVendorAttentionName(StringUtils.EMPTY);
796 } else {
797 setVendorAttentionName(StringUtils.defaultString(po.getVendorAttentionName()));
798 }
799 }
800
801 this.setInvoicePayDate(getInvoiceService().calculatePayDate(this.getInvoiceDate(), this.getVendorPaymentTerms()));
802
803 if (getInvoiceService().encumberedItemExistsForInvoicing(po)) {
804 for (OlePurchaseOrderItem poi : (List<OlePurchaseOrderItem>) po.getItems()) {
805
806 if (getDocumentSpecificService().poItemEligibleForAp(this, poi)) {
807 OleInvoiceItem invoiceItem = new OleInvoiceItem(poi, this, expiredOrClosedAccountList);
808 invoiceItem.setReceivingDocumentRequiredIndicator(po.isReceivingDocumentRequiredIndicator());
809 this.getItems().add(invoiceItem);
810 PurchasingCapitalAssetItem purchasingCAMSItem = po.getPurchasingCapitalAssetItemByItemIdentifier(poi.getItemIdentifier());
811 if (purchasingCAMSItem != null) {
812 invoiceItem.setCapitalAssetTransactionTypeCode(purchasingCAMSItem.getCapitalAssetTransactionTypeCode());
813 }
814
815
816
817
818
819
820
821
822 }
823 }
824 }
825
826
827 getPurapService().addBelowLineItems(this);
828 this.setAccountsPayablePurchasingDocumentLinkIdentifier(po.getAccountsPayablePurchasingDocumentLinkIdentifier());
829
830
831 getInvoiceService().removeIneligibleAdditionalCharges(this);
832
833 this.fixItemReferences();
834 this.refreshNonUpdateableReferences();
835 }
836
837 @Override
838 public Class getItemClass() {
839 return OleInvoiceItem.class;
840 }
841
842 @Override
843 public PurApAccountingLine getFirstAccount() {
844
845 if ((getItems() != null) && (!getItems().isEmpty())) {
846 OleInvoiceItem itemToUse = null;
847 for (Iterator iter = getItems().iterator(); iter.hasNext(); ) {
848 OleInvoiceItem item = (OleInvoiceItem) iter.next();
849 if ((item.isConsideredEntered()) && ((item.getSourceAccountingLines() != null) && (!item.getSourceAccountingLines().isEmpty()))) {
850
851 PurApAccountingLine accountLine = item.getSourceAccountingLine(0);
852 accountLine.refreshNonUpdateableReferences();
853 return accountLine;
854 }
855
856
857
858
859
860
861
862
863 }
864 }
865 return null;
866
867 }
868
869 @Override
870 public PurApItem getItem(int pos) {
871 OleInvoiceItem item = (OleInvoiceItem) super.getItem(pos);
872 if (item.getInvoice() == null) {
873 item.setInvoice(this);
874 }
875 return item;
876 }
877
878
879
880
881
882
883 public void loadInvoiceDocument() {
884 try {
885 long b1 = System.currentTimeMillis();
886
887 LOG.debug("###########inside OleInvoiceDocument processAfterRetrieve###########");
888
889 if (this.getPaymentMethodId() != null) {
890 OlePaymentMethod olePaymentMethod = SpringContext.getBean(BusinessObjectService.class)
891 .findBySinglePrimaryKey(OlePaymentMethod.class, this.getPaymentMethodId());
892 this.setPaymentMethod(olePaymentMethod);
893 this.setPaymentMethodIdentifier(this.getPaymentMethodId().toString());
894 }
895 if (this.getInvoiceTypeId() != null) {
896 this.setInvoiceTypeHdnId(this.getInvoiceTypeId().toString());
897 }
898 if (this.getInvoiceSubTypeId() != null) {
899 this.setInvoiceSubTypeHdnId(this.getInvoiceSubTypeId().toString());
900 }
901 if (this.getVendorInvoiceAmount() != null) {
902 this.setInvoiceAmount(this.getVendorInvoiceAmount().toString());
903 }
904 if (this.getForeignVendorInvoiceAmount() != null) {
905 this.setForeignInvoiceAmount(this.getForeignVendorInvoiceAmount().toString());
906 }
907 List<BigDecimal> newUnitPriceList = new ArrayList<BigDecimal>();
908 BigDecimal newUnitPrice = new BigDecimal(0);
909 BigDecimal hundred = new BigDecimal(100);
910 List<OleInvoiceItem> item = this.getItems();
911 String titleId = null;
912
913
914
915
916
917
918
919
920
921
922
923
924 String itemDescription = "";
925 BigDecimal exchangeRate = new BigDecimal("0");
926 if (this.getInvoiceCurrencyTypeId() != null) {
927 OleCurrencyType oleCurrencyType = SpringContext.getBean(BusinessObjectService.class)
928 .findBySinglePrimaryKey(OleCurrencyType.class, this.getInvoiceCurrencyTypeId());
929 this.setOleCurrencyType(oleCurrencyType);
930 this.setInvoiceCurrencyType(this.getInvoiceCurrencyTypeId().toString());
931 if ( oleCurrencyType.getCurrencyType().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME) ){
932 currencyTypeIndicator=true;
933 this.setForeignCurrencyFlag(false);
934 } else {
935 currencyTypeIndicator=false;
936 this.setForeignCurrencyFlag(true);
937 }
938 } else {
939 if ( this.getVendorDetail() !=null && this.getVendorDetail().getCurrencyType() != null ){
940 if(this.getVendorDetail().getCurrencyType().getCurrencyType().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)){
941 currencyTypeIndicator=true;
942 this.setForeignCurrencyFlag(false);
943 this.setInvoiceCurrencyType(this.getVendorDetail().getCurrencyType().getCurrencyTypeId().toString());
944 }
945 else{
946 currencyTypeIndicator=false;
947 this.setForeignCurrencyFlag(true);
948 this.setInvoiceCurrencyType(this.getVendorDetail().getCurrencyType().getCurrencyTypeId().toString());
949 }
950 }
951 }
952
953 if (this.getInvoiceCurrencyTypeId() != null && (!currencyTypeIndicator) ){
954 if (StringUtils.isBlank(this.getInvoiceCurrencyExchangeRate())) {
955 exchangeRate = SpringContext.getBean(OleInvoiceService.class).getExchangeRate(this.getInvoiceCurrencyType()).getExchangeRate();
956 this.setInvoiceCurrencyExchangeRate(exchangeRate.toString());
957
958
959 }
960 }
961
962 for (int i = 0; item.size() > i; i++) {
963 OleInvoiceItem items = (OleInvoiceItem) this.getItem(i);
964 if (this.getInvoiceCurrencyTypeId() != null) {
965 items.setItemCurrencyType(oleCurrencyType.getCurrencyType());
966 items.setInvoicedCurrency(oleCurrencyType.getCurrencyType());
967 } else {
968 if (this.getVendorDetail() !=null && this.getVendorDetail().getCurrencyType() != null ){
969 items.setItemCurrencyType(this.getVendorDetail().getCurrencyType().getCurrencyType());
970 items.setInvoicedCurrency(this.getVendorDetail().getCurrencyType().getCurrencyType());
971 }
972 }
973
974 if (this.getInvoiceCurrencyTypeId() != null && (!currencyTypeIndicator) ){
975 if (StringUtils.isNotBlank(this.getInvoiceCurrencyExchangeRate())) {
976 try {
977
978 items.setItemExchangeRate(new KualiDecimal(this.getInvoiceCurrencyExchangeRate()));
979 items.setExchangeRate(this.getInvoiceCurrencyExchangeRate());
980 }
981 catch (NumberFormatException nfe) {
982 throw new RuntimeException("Invalid Exchange Rate", nfe);
983 }
984 } else {
985 items.setItemExchangeRate(new KualiDecimal(exchangeRate));
986 items.setExchangeRate(exchangeRate.toString());
987 }
988 if (items.getItemExchangeRate() != null && items.getItemForeignUnitCost() != null) {
989 items.setItemUnitCostUSD(new KualiDecimal(items.getItemForeignUnitCost().bigDecimalValue().divide(new BigDecimal(items.getExchangeRate()), 4, BigDecimal.ROUND_HALF_UP)));
990 items.setItemUnitPrice(items.getItemForeignUnitCost().bigDecimalValue().divide(new BigDecimal(items.getExchangeRate()), 4, BigDecimal.ROUND_HALF_UP));
991 items.setItemListPrice(items.getItemUnitCostUSD());
992 items.setExtendedPrice(items.calculateExtendedPrice());
993 }
994
995 }
996
997 if (LOG.isDebugEnabled()) {
998 LOG.debug("Title id while retriving ------>" + items.getItemTitleId());
999 }
1000 if (items.getItemTitleId() != null) {
1001 BibInfoRecord bibInfoRecord = items.getBibInfoRecord();
1002
1003 if(bibInfoRecord !=null){
1004 items.setBibUUID(bibInfoRecord.getBibIdStr());
1005 items.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(items.getItemTitleId()));
1006
1007 itemDescription = ((bibInfoRecord.getTitle() != null && !bibInfoRecord.getTitle().isEmpty()) ? bibInfoRecord.getTitle().trim() + ", " : "")
1008 + ((bibInfoRecord.getAuthor() != null && !bibInfoRecord
1009 .getAuthor().isEmpty()) ? bibInfoRecord.getAuthor().trim() + ", "
1010 : "")
1011 + ((bibInfoRecord.getPublisher() != null && !bibInfoRecord
1012 .getPublisher().isEmpty()) ? bibInfoRecord.getPublisher().trim()
1013 + ", " : "")
1014 + ((bibInfoRecord.getIsxn() != null && !bibInfoRecord.getIsxn()
1015 .isEmpty()) ? bibInfoRecord.getIsxn().trim() + ", " : "");
1016 }
1017 if (itemDescription != null && !(itemDescription.equals(""))) {
1018 itemDescription = itemDescription.substring(0, itemDescription.lastIndexOf(","));
1019 StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
1020 itemDescription = stringEscapeUtils.unescapeXml(itemDescription);
1021 items.setItemDescription(itemDescription);
1022 }
1023 HashMap<String, String> queryMap = new HashMap<String, String>();
1024 if (items.getPoItemIdentifier() != null) {
1025 queryMap.put(OLEConstants.OleCopy.PO_ITM_ID, items.getPoItemIdentifier().toString());
1026 List<OLELinkPurapDonor> oleLinkPurapDonorList = (List<OLELinkPurapDonor>) getBusinessObjectService().findMatching(OLELinkPurapDonor.class, queryMap);
1027 if (oleLinkPurapDonorList != null) {
1028 items.setOleDonors(oleLinkPurapDonorList);
1029 oleLinkPurapDonorList.clear();
1030 }
1031 }
1032 }
1033 if ((items.getItemType().isQuantityBasedGeneralLedgerIndicator())) {
1034 if (items.getItemDiscount() == null) {
1035 items.setItemDiscount(KualiDecimal.ZERO);
1036 }
1037
1038 if (items.getItemListPrice() == null) {
1039 items.setItemListPrice(KualiDecimal.ZERO);
1040 }
1041
1042
1043
1044
1045
1046
1047
1048 }
1049
1050
1051
1052
1053
1054 items.setOleOpenQuantity(String.valueOf(items.getPoOutstandingQuantity()));
1055 }
1056 if (this.getVendorHeaderGeneratedIdentifier() != null && this.getVendorDetailAssignedIdentifier() != null) {
1057 this.setVendorId(this.getVendorHeaderGeneratedIdentifier().toString() + "-" + this.getVendorDetailAssignedIdentifier().toString());
1058 }
1059
1060 if (this.getProrateBy() != null) {
1061 this.setProrateQty(this.getProrateBy().equals(OLEConstants.PRORATE_BY_QTY));
1062 this.setProrateManual(this.getProrateBy().equals(OLEConstants.MANUAL_PRORATE));
1063 this.setProrateDollar(this.getProrateBy().equals(OLEConstants.PRORATE_BY_DOLLAR));
1064 this.setNoProrate(this.getProrateBy().equals(OLEConstants.NO_PRORATE));
1065 }
1066 long b2 = System.currentTimeMillis();
1067 long tot = b2-b1;
1068 LOG.info("loadInvoiceDocument"+tot);
1069 } catch (Exception e) {
1070 LOG.error("Exception during processAfterRetrieve in OleInvoiceDocument "+e);
1071 throw new RuntimeException(e);
1072 }
1073
1074 }
1075
1076
1077
1078
1079
1080 @Override
1081 public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
1082 LOG.debug("doRouteStatusChange() started");
1083
1084 super.doRouteStatusChange(statusChangeEvent);
1085 try {
1086
1087 if (this.getDocumentHeader().getWorkflowDocument().isProcessed()) {
1088 if (!InvoiceStatuses.APPDOC_AUTO_APPROVED.equals(getApplicationDocumentStatus())) {
1089
1090 getOleInvoiceService().completePaymentDocument(this);
1091 this.setApplicationDocumentStatus(PurapConstants.InvoiceStatuses.APPDOC_DEPARTMENT_APPROVED);
1092 if (this.getImmediatePaymentIndicator()) {
1093 this.setInvoicePayDate(new java.sql.Date(this.getAccountsPayableApprovalTimestamp().getTime()));
1094 }
1095
1096
1097
1098 populateDocumentForRouting();
1099 getPurapService().saveDocumentNoValidation(this);
1100 SpringContext.getBean(OleInvoiceService.class).createPaymentRequestOrCreditMemoDocument(this);
1101
1102 return;
1103 }
1104 }
1105
1106
1107
1108
1109
1110
1111
1112
1113 else if (this.getDocumentHeader().getWorkflowDocument().isDisapproved()) {
1114
1115
1116 String nodeName = getDocumentHeader().getWorkflowDocument().getCurrentNodeNames().iterator().next();
1117 HashMap<String, String> disApprovedStatusMap = PurapConstants.InvoiceStatuses
1118 .getInvoiceAppDocDisapproveStatuses();
1119
1120
1121 if (ObjectUtils.isNotNull(nodeName)) {
1122 String newStatusCode = disApprovedStatusMap.get(nodeName);
1123
1124 if ((StringUtils.isBlank(newStatusCode))
1125 && ((InvoiceStatuses.APPDOC_INITIATE.equals(getApplicationDocumentStatus())) || (InvoiceStatuses.APPDOC_IN_PROCESS
1126 .equals(getApplicationDocumentStatus())))) {
1127 newStatusCode = InvoiceStatuses.APPDOC_CANCELLED_IN_PROCESS;
1128 }
1129 if (StringUtils.isNotBlank(newStatusCode)) {
1130 getAccountsPayableService().cancelAccountsPayableDocument(this, nodeName);
1131 return;
1132 }
1133 }
1134 logAndThrowRuntimeException("No status found to set for document being disapproved in node '" + nodeName + "'");
1135 }
1136
1137 else if (this.getDocumentHeader().getWorkflowDocument().isCanceled()) {
1138
1139
1140
1141 String nodeName = getDocumentHeader().getWorkflowDocument().getCurrentNodeNames().iterator().next();
1142 HashMap<String, String> disApprovedStatusMap = PurapConstants.InvoiceStatuses
1143 .getInvoiceAppDocDisapproveStatuses();
1144 if (ObjectUtils.isNotNull(nodeName)) {
1145
1146 String cancelledStatusCode = disApprovedStatusMap.get(nodeName);
1147 if (StringUtils.isNotBlank(cancelledStatusCode)) {
1148 this.setApplicationDocumentStatus(cancelledStatusCode);
1149 getPurapService().saveDocumentNoValidation(this);
1150 return;
1151 }
1152 }
1153 logAndThrowRuntimeException("No status found to set for document being canceled in node '" + nodeName
1154 + "'");
1155 }
1156 } catch (Exception e) {
1157 logAndThrowRuntimeException("Error saving routing data while saving document with id " + getDocumentNumber(), e);
1158 }
1159 }
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171 public void appSpecificRouteDocumentToUser(WorkflowDocument workflowDocument, String userNetworkId,
1172 String annotation, String responsibility) throws WorkflowException {
1173 if (ObjectUtils.isNotNull(workflowDocument)) {
1174 String annotationNote = (ObjectUtils.isNull(annotation)) ? "" : annotation;
1175 String responsibilityNote = (ObjectUtils.isNull(responsibility)) ? "" : responsibility;
1176 String currentNodeName = getCurrentRouteNodeName(workflowDocument);
1177 Principal principal = getIdentityManagementService().getPrincipalByPrincipalName(userNetworkId);
1178 workflowDocument.adHocToPrincipal(ActionRequestType.FYI, currentNodeName, annotationNote,
1179 principal.getPrincipalId(), responsibilityNote, true);
1180 }
1181 }
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191 protected String getCurrentRouteNodeName(WorkflowDocument wd) throws WorkflowException {
1192
1193 Set<String> nodeNameSet = wd.getNodeNames();
1194 String[] nodeNames = (String[]) nodeNameSet.toArray();
1195
1196 if ((nodeNames == null) || (nodeNames.length == 0)) {
1197 return null;
1198 } else {
1199 return nodeNames[0];
1200 }
1201 }
1202
1203 public BigDecimal getForeignVendorInvoiceAmount() {
1204 return foreignVendorInvoiceAmount;
1205 }
1206
1207 public void setForeignVendorInvoiceAmount(BigDecimal foreignVendorInvoiceAmount) {
1208 this.foreignVendorInvoiceAmount = foreignVendorInvoiceAmount;
1209 }
1210
1211
1212
1213
1214
1215
1216 public String getBibeditorCreateURL() {
1217 String bibeditorCreateURL = getConfigurationService().getPropertyValueAsString(
1218 OLEConstants.BIBEDITOR_CREATE_URL_KEY);
1219 return bibeditorCreateURL;
1220 }
1221
1222
1223
1224
1225
1226
1227 public String getBibeditorEditURL() {
1228 String bibeditorEditURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_URL_KEY);
1229 return bibeditorEditURL;
1230 }
1231
1232
1233
1234
1235
1236
1237 public String getBibeditorViewURL() {
1238 String bibeditorViewURL = getConfigurationService().getPropertyValueAsString(OLEConstants.DOCSTORE_APP_URL_KEY);
1239 return bibeditorViewURL;
1240 }
1241
1242
1243
1244
1245
1246
1247 public String getMarcXMLFileDirLocation() throws Exception {
1248 String externaleDirectory = getFileProcessingService().getMarcXMLFileDirLocation();
1249 return externaleDirectory;
1250 }
1251
1252 @Override
1253 public void prepareForSave(KualiDocumentEvent event) {
1254
1255
1256 if (event instanceof AttributedContinuePurapEvent) {
1257 SpringContext.getBean(OleInvoiceService.class).populateInvoice(this);
1258 }
1259 if(this.getVendorPaymentTermsCode() != null && this.getVendorPaymentTermsCode().isEmpty()) {
1260 this.setVendorPaymentTermsCode(null);
1261 }
1262 super.prepareForSave(event);
1263 try {
1264 if (this.proformaIndicator && !this.immediatePaymentIndicator) {
1265 this.setImmediatePaymentIndicator(true);
1266 }
1267 LOG.debug("###########Inside OleInvoiceDocument " + "repareForSave###########");
1268 List<OleInvoiceItem> items = new ArrayList<OleInvoiceItem>();
1269 items = this.getItems();
1270 Iterator iterator = items.iterator();
1271 HashMap dataMap = new HashMap();
1272 String titleId;
1273 while (iterator.hasNext()) {
1274 LOG.debug("###########inside prepareForSave item loop###########");
1275 Object object = iterator.next();
1276 if (object instanceof OleInvoiceItem) {
1277 LOG.debug("###########inside prepareForSave ole payment request item###########");
1278 OleInvoiceItem singleItem = (OleInvoiceItem) object;
1279 if (StringUtils.isNotBlank(this.invoiceCurrencyType)) {
1280 this.setInvoiceCurrencyTypeId(new Long(this.getInvoiceCurrencyType()));
1281 String currencyType = SpringContext.getBean(OleInvoiceService.class).getCurrencyType(this.getInvoiceCurrencyType());
1282 if (StringUtils.isNotBlank(currencyType)) {
1283 if(!currencyType.equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) {
1284 if (StringUtils.isNotBlank(this.getInvoiceCurrencyExchangeRate())) {
1285 try {
1286 Double.parseDouble(this.getInvoiceCurrencyExchangeRate());
1287 singleItem.setItemExchangeRate(new KualiDecimal(this.getInvoiceCurrencyExchangeRate()));
1288 singleItem.setExchangeRate(this.getInvoiceCurrencyExchangeRate());
1289 }
1290 catch (NumberFormatException nfe) {
1291 throw new RuntimeException("Invalid Exchange Rate", nfe);
1292 }
1293 } else {
1294 BigDecimal exchangeRate = SpringContext.getBean(OleInvoiceService.class).getExchangeRate(this.getInvoiceCurrencyType()).getExchangeRate();
1295 this.setInvoiceCurrencyExchangeRate(exchangeRate.toString());
1296 singleItem.setItemExchangeRate(new KualiDecimal(exchangeRate));
1297 singleItem.setExchangeRate(exchangeRate.toString());
1298 }
1299 this.setVendorInvoiceAmount(this.getForeignVendorInvoiceAmount() != null ?
1300 new KualiDecimal(this.getForeignVendorInvoiceAmount().divide(new BigDecimal(singleItem.getExchangeRate()), 4, RoundingMode.HALF_UP)) : null);
1301 }
1302 }
1303 }
1304 setItemDescription(singleItem);
1305 Map<String, String> copyCriteria = new HashMap<String, String>();
1306 if (singleItem.getPaidCopies().size() <= 0 && singleItem.getPoItemIdentifier() != null && (this.getPurapDocumentIdentifier() != null && singleItem.getItemIdentifier() != null)) {
1307 copyCriteria.put("poItemId", singleItem.getPoItemIdentifier().toString());
1308 List<OleCopy> copies = (List<OleCopy>) getBusinessObjectService().findMatching(OleCopy.class, copyCriteria);
1309 if (copies.size() > 0) {
1310 List<OLEPaidCopy> paidCopies = new ArrayList<OLEPaidCopy>();
1311 for (OleCopy copy : copies) {
1312 OLEPaidCopy paidCopy = new OLEPaidCopy();
1313 paidCopy.setCopyId(copy.getCopyId());
1314 paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
1315 paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
1316
1317 paidCopies.add(paidCopy);
1318 }
1319 getBusinessObjectService().save(paidCopies);
1320 singleItem.setPaidCopies(paidCopies);
1321 }
1322 }
1323 }
1324 }
1325 } catch (Exception e) {
1326 LOG.error("Exception during prepareForSave() in OleInvoiceDocument", e);
1327 throw new RuntimeException(e);
1328 }
1329 }
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431 public boolean getIsSaved() {
1432 if (this.getDocumentHeader().getWorkflowDocument().isSaved()
1433 || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
1434 return true;
1435 }
1436 return false;
1437 }
1438
1439 private void setItemDescription(OleInvoiceItem singleItem) throws Exception {
1440 if (singleItem.getOleOrderRecord() != null) {
1441 Map<String, ?> bibAssociatedFieldValuesMap = singleItem.getOleOrderRecord().getOleBibRecord().getBibAssociatedFieldsValueMap();
1442 List titleList = (List) bibAssociatedFieldValuesMap.get("Title_search");
1443 String title = titleList != null && !titleList.isEmpty() ? (String) (titleList).get(0) : null;
1444 List authorList = (List) bibAssociatedFieldValuesMap.get("Author_search");
1445 String author = authorList != null && !authorList.isEmpty() ? (String) (authorList).get(0) : null;
1446 List publisherList = (List) bibAssociatedFieldValuesMap.get("Publisher_search");
1447 String publisher = publisherList != null && !publisherList.isEmpty() ? (String) (publisherList).get(0) : null;
1448 List isbnList = (List) bibAssociatedFieldValuesMap.get("020a");
1449 String isbn = isbnList != null && !isbnList.isEmpty() ? (String) (isbnList).get(0) : null;
1450
1451 singleItem.setBibUUID(singleItem.getOleOrderRecord().getOleBibRecord().getBibUUID());
1452 singleItem.setItemDescription(title + "," + author + "," + publisher + "," + isbn);
1453 }
1454 }
1455
1456 public String getProrateBy() {
1457 return prorateBy;
1458 }
1459
1460 public void setProrateBy(String prorateBy) {
1461 this.prorateBy = prorateBy;
1462 }
1463
1464
1465
1466
1467
1468
1469 public boolean isProformaIndicator() {
1470 return proformaIndicator;
1471 }
1472
1473
1474
1475
1476
1477
1478
1479 public void setProformaIndicator(boolean proformaIndicator) {
1480 this.proformaIndicator = proformaIndicator;
1481 }
1482
1483
1484
1485
1486
1487
1488 @Override
1489 protected boolean shouldWaitForReceiving() {
1490
1491 Boolean invReceiveInd = false;
1492
1493 for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) this.getItems()) {
1494 if (invoiceItem.isReceivingDocumentRequiredIndicator()) {
1495 invReceiveInd = true;
1496 break;
1497 }
1498 }
1499
1500
1501 if (invReceiveInd && !this.proformaIndicator) {
1502 return !isReceivingRequirementMet();
1503 }
1504
1505
1506 return false;
1507 }
1508
1509
1510
1511
1512
1513
1514 @Override
1515 public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperationException {
1516 if (nodeName.equals(OLEConstants.HAS_VENDOR_DEPOSIT_ACCOUNT)) {
1517 return hasVendorDepositAccount();
1518 }
1519 if (nodeName.equals(OLEConstants.OleInvoice.HAS_INVOICE_TYPE)) {
1520 return hasInvoiceType();
1521 }
1522 if (nodeName.equals(OLEConstants.OleInvoice.HAS_PREPAID_INVOICE_TYPE)) {
1523 return hasPrepaidInvoiceType();
1524 }
1525 if (nodeName.equals(OLEConstants.OleInvoice.HAS_PAYMENT_METHOD)) {
1526 return hasPaymentMethod();
1527 }
1528 if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) {
1529 return isBudgetReviewRequired();
1530 }
1531 if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) {
1532 return requiresAccountsPayableReviewRouting();
1533 }
1534 if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) {
1535 return shouldWaitForReceiving();
1536 }
1537 if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) {
1538 return isVendorEmployeeOrNonResidentAlien();
1539 }
1540 if (nodeName.equals(OLEConstants.REQUIRES_SEPARATION_OF_DUTIES)) {
1541 return isSeparationOfDutiesReviewRequired();
1542 }
1543
1544 if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) {
1545 return isNotificationRequired();
1546 }
1547 throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\"");
1548 }
1549
1550 private boolean hasInvoiceType() {
1551 if (this.getInvoiceTypeId() != null) {
1552 return true;
1553 }
1554 return false;
1555 }
1556
1557 private boolean hasVendorDepositAccount() {
1558 if (this.getPaymentMethodIdentifier() != null) {
1559 String paymentType = SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(this.getPaymentMethodIdentifier());
1560 if (paymentType.equals("Deposit")) {
1561 return true;
1562 }
1563 }
1564 return false;
1565 }
1566
1567 private boolean hasPrepaidInvoiceType() {
1568 if (this.getInvoiceTypeId() != null) {
1569 Map<String, String> invoiceMap = new HashMap<String, String>();
1570 invoiceMap.put("invoiceTypeId", this.getInvoiceTypeId().toString());
1571 OleInvoiceType invoiceType = this.getBusinessObjectService().findByPrimaryKey(OleInvoiceType.class,
1572 invoiceMap);
1573 if (invoiceType != null &&
1574 invoiceType.getInvoiceType().equals("Prepay") ||
1575 invoiceType.getInvoiceType().equals("Deposit")) {
1576 return true;
1577 }
1578 }
1579 return false;
1580 }
1581
1582 private boolean hasPaymentMethod() {
1583 if (this.getPaymentMethodId() != null) {
1584 return true;
1585 }
1586 return false;
1587 }
1588
1589 public Set<Person> getAllPriorApprovers() throws WorkflowException {
1590 PersonService personService = KimApiServiceLocator.getPersonService();
1591 List<ActionTaken> actionsTaken = getDocumentHeader().getWorkflowDocument().getActionsTaken();
1592 Set<String> principalIds = new HashSet<String>();
1593 Set<Person> persons = new HashSet<Person>();
1594
1595 for (ActionTaken actionTaken : actionsTaken) {
1596 if (KewApiConstants.ACTION_TAKEN_APPROVED_CD.equals(actionTaken.getActionTaken())) {
1597 String principalId = actionTaken.getPrincipalId();
1598 if (!principalIds.contains(principalId)) {
1599 principalIds.add(principalId);
1600 persons.add(personService.getPerson(principalId));
1601 }
1602 }
1603 }
1604 return persons;
1605 }
1606
1607 protected boolean isSeparationOfDutiesReviewRequired() {
1608 try {
1609 Set<Person> priorApprovers = getAllPriorApprovers();
1610
1611
1612 String initiatorPrincipalId = getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
1613 Person initiator = SpringContext.getBean(PersonService.class).getPerson(initiatorPrincipalId);
1614
1615 boolean priorApproverIsInitiator = priorApprovers.contains(initiator);
1616 boolean onlyOneApprover = (priorApprovers.size() == 1);
1617 if (priorApproverIsInitiator && onlyOneApprover) {
1618 return true;
1619 }
1620
1621
1622
1623 if (priorApprovers.size() > 0) {
1624 return false;
1625 }
1626 } catch (WorkflowException we) {
1627 LOG.error("Exception while attempting to retrieve all prior approvers from workflow: " + we);
1628 }
1629 return false;
1630 }
1631
1632 public boolean isBudgetReviewRequired() {
1633
1634 OleInvoiceFundCheckServiceImpl oleInvoiceFundCheckServiceImpl = new OleInvoiceFundCheckServiceImpl();
1635 boolean required = false;
1636 if ((SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(this.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) {
1637 return false;
1638 }
1639
1640 if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().compareTo(getPostingYear()) >= 0) {
1641 List<SourceAccountingLine> sourceAccountingLineList = this.getSourceAccountingLines();
1642 for (SourceAccountingLine accLine : sourceAccountingLineList) {
1643 String chart = accLine.getAccount().getChartOfAccountsCode();
1644 String account = accLine.getAccount().getAccountNumber();
1645 String sfCode = accLine.getAccount().getAccountSufficientFundsCode();
1646 Map<String, Object> key = new HashMap<String, Object>();
1647 key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart);
1648 key.put(OLEPropertyConstants.ACCOUNT_NUMBER, account);
1649 OleSufficientFundCheck oleSufficientFundCheck = businessObjectService.findByPrimaryKey(
1650 OleSufficientFundCheck.class, key);
1651
1652
1653
1654
1655 SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(this);
1656 SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries());
1657
1658 if (oleSufficientFundCheck != null) {
1659 String option = oleSufficientFundCheck.getNotificationOption() != null ? oleSufficientFundCheck
1660 .getNotificationOption() : "";
1661 if (option.equals(OLEPropertyConstants.BUD_REVIEW)) {
1662
1663
1664
1665
1666
1667
1668
1669 required = oleInvoiceFundCheckServiceImpl.hasSufficientFundCheckRequired(accLine);
1670 SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber());
1671
1672 return required;
1673 }
1674 }
1675 }
1676 }
1677 SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber());
1678
1679 return required;
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701 }
1702
1703 private boolean isNotificationRequired() {
1704 OleInvoiceFundCheckServiceImpl oleInvoiceFundCheckServiceImpl = new OleInvoiceFundCheckServiceImpl();
1705 if ((SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(this.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) {
1706 return false;
1707 }
1708 List<SourceAccountingLine> sourceAccountingLineList = this.getSourceAccountingLines();
1709 boolean sufficientFundCheck = false;
1710 for (SourceAccountingLine accLine : sourceAccountingLineList) {
1711 Map searchMap = new HashMap();
1712 String notificationOption = null;
1713 Map<String, Object> key = new HashMap<String, Object>();
1714 String chartCode = accLine.getChartOfAccountsCode();
1715 String accNo = accLine.getAccountNumber();
1716 String objectCd = accLine.getFinancialObjectCode();
1717 key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
1718 key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo);
1719 OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(
1720 OleSufficientFundCheck.class, key);
1721 if (account != null) {
1722 notificationOption = account.getNotificationOption();
1723 }
1724 if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) {
1725 sufficientFundCheck = oleInvoiceFundCheckServiceImpl.hasSufficientFundCheckRequired(accLine);
1726 return sufficientFundCheck;
1727 }
1728 }
1729 return sufficientFundCheck;
1730 }
1731
1732 @Override
1733 protected void populateAccountsForRouting() {
1734
1735
1736 List<SufficientFundsItem> fundsItems = new ArrayList<SufficientFundsItem>();
1737 try {
1738
1739
1740 String nodeName = getFinancialSystemDocumentHeader().getWorkflowDocument().getCurrentNodeNames().iterator()
1741 .next();
1742 if (nodeName != null
1743 && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName
1744 .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) {
1745 if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()
1746 .compareTo(getPostingYear()) >= 0) {
1747
1748 SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(
1749 this);
1750 SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries());
1751
1752 List<GeneralLedgerPendingEntry> pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking();
1753 for (GeneralLedgerPendingEntry glpe : pendingEntries) {
1754 glpe.getChartOfAccountsCode();
1755 }
1756
1757 fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFundsForInvoice(pendingEntries);
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768 }
1769 SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this);
1770 if (accountsForRouting == null) {
1771 accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems()));
1772 }
1773 String documentFiscalYearString = this.getPostingYear().toString();
1774 List<String> fundsItemList = new ArrayList<String>();
1775 for (SufficientFundsItem fundsItem : fundsItems) {
1776 fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode());
1777 }
1778 if (accountsForRouting != null) {
1779 for (Iterator accountsForRoutingIter = accountsForRouting.iterator(); accountsForRoutingIter.hasNext(); ) {
1780 if (!(fundsItemList.contains(((SourceAccountingLine) accountsForRoutingIter.next())
1781 .getChartOfAccountsCode()))) {
1782 accountsForRoutingIter.remove();
1783 }
1784 }
1785
1786
1787 setAccountsForRouting(accountsForRouting);
1788 }
1789
1790
1791
1792 refreshNonUpdateableReferences();
1793 for (SourceAccountingLine sourceLine : getAccountsForRouting()) {
1794 sourceLine.refreshNonUpdateableReferences();
1795 }
1796 } else {
1797 super.populateAccountsForRouting();
1798 }
1799 SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber());
1800 } catch (Exception e) {
1801 logAndThrowRuntimeException("Error in populateAccountsForRouting while submitting document with id "
1802 + getDocumentNumber(), e);
1803 }
1804
1805 }
1806
1807
1808
1809
1810 @Override
1811 public void doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) {
1812
1813 super.doRouteLevelChange(levelChangeEvent);
1814 try {
1815 String newNodeName = levelChangeEvent.getNewNodeName();
1816 List<String> desiredActions = new ArrayList<String>(2);
1817 RoutingReportCriteria.Builder reportCriteria = RoutingReportCriteria.Builder
1818 .createByDocumentIdAndTargetNodeName(getDocumentNumber(), newNodeName);
1819 desiredActions.add(ActionRequestType.APPROVE.getCode());
1820 desiredActions.add(ActionRequestType.FYI.getCode());
1821 desiredActions.add(ActionRequestType.COMPLETE.getCode());
1822 if (KewApiServiceLocator.getWorkflowDocumentActionsService().documentWillHaveAtLeastOneActionRequest(
1823 reportCriteria.build(), desiredActions, false)) {
1824 if (StringUtils.isNotBlank(newNodeName)) {
1825 if (StringUtils.isNotBlank(newNodeName)) {
1826 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE)
1827 || newNodeName.equalsIgnoreCase(PurapWorkflowConstants.FYI_BUDGET)) {
1828 String note = "";
1829 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE)) {
1830 note = OLEConstants.SufficientFundCheck.INV_NOTE;
1831 }
1832 if (newNodeName.equalsIgnoreCase(PurapWorkflowConstants.FYI_BUDGET)) {
1833 note = OLEConstants.SufficientFundCheck.FYI_NOTE;
1834 }
1835 DocumentService documentService = SpringContext.getBean(DocumentService.class);
1836 Note apoNote = documentService.createNoteFromDocument(this, note);
1837 this.addNote(apoNote);
1838 documentService.saveDocumentNotes(this);
1839 }
1840 }
1841 }
1842 }
1843 } catch (Exception e) {
1844 String errorMsg = "Workflow Error found checking actions requests on document with id "
1845 + getDocumentNumber() + ". *** WILL NOT UPDATE PURAP STATUS ***";
1846 LOG.error(errorMsg, e);
1847 }
1848 }
1849
1850 private OleInvoiceDocument invoiceDocumentObject;
1851
1852 public OleInvoiceDocument getInvoiceDocumentObject() {
1853 return invoiceDocumentObject;
1854 }
1855
1856 public void setInvoiceDocumentObject(OleInvoiceDocument invoiceDocumentObject) {
1857 this.invoiceDocumentObject = invoiceDocumentObject;
1858 }
1859
1860
1861 private String invoiceNumber;
1862
1863 private String invoicePaymentClassification;
1864 private String invoiceVendorAmount;
1865 private String invoiceExtractDate;
1866 private String invoiceProcessedDate;
1867 private String invoiceType;
1868 private String invoiceSubType;
1869 private String invoiceBankCode;
1870
1871 private String invoicePayDateCheck;
1872 private String vendorAmount;
1873 private String itemTotal;
1874 private String foreignItemTotal;
1875 private String grantTotal;
1876 private String foreignGrandTotal;
1877
1878 private String invoicedForeignItemTotal;
1879 private String invoicedForeignGrandTotal;
1880
1881 public String getInvoicePayDateCheck() {
1882 return invoicePayDateCheck;
1883 }
1884
1885 public void setInvoicePayDateCheck(String invoicePayDateCheck) {
1886 this.invoicePayDateCheck = invoicePayDateCheck;
1887 }
1888
1889
1890 public String getInvoiceNumber() {
1891 return invoiceNumber;
1892 }
1893
1894 public void setInvoiceNumber(String invoiceNumber) {
1895 this.invoiceNumber = invoiceNumber;
1896 }
1897
1898
1899 public String getInvoicePaymentClassification() {
1900 return invoicePaymentClassification;
1901 }
1902
1903 public void setInvoicePaymentClassification(String invoicePaymentClassification) {
1904 this.invoicePaymentClassification = invoicePaymentClassification;
1905 }
1906
1907 public String getInvoiceVendorAmount() {
1908 return invoiceVendorAmount;
1909 }
1910
1911 public void setInvoiceVendorAmount(String invoiceVendorAmount) {
1912 this.invoiceVendorAmount = invoiceVendorAmount;
1913 }
1914
1915 public String getInvoiceExtractDate() {
1916 return invoiceExtractDate;
1917 }
1918
1919 public void setInvoiceExtractDate(String invoiceExtractDate) {
1920 this.invoiceExtractDate = invoiceExtractDate;
1921 }
1922
1923 public String getInvoiceProcessedDate() {
1924 return invoiceProcessedDate;
1925 }
1926
1927 public void setInvoiceProcessedDate(String invoiceProcessedDate) {
1928 this.invoiceProcessedDate = invoiceProcessedDate;
1929 }
1930
1931 public String getInvoiceBankCode() {
1932 return invoiceBankCode;
1933 }
1934
1935 public void setInvoiceBankCode(String invoiceBankCode) {
1936 this.invoiceBankCode = invoiceBankCode;
1937 }
1938
1939
1940 private String poId;
1941
1942 public String getPoId() {
1943 return poId;
1944 }
1945
1946 public void setPoId(String poId) {
1947 this.poId = poId;
1948 }
1949
1950
1951 public String getInvoiceCostSourceCode() {
1952 return invoiceCostSourceCode;
1953 }
1954
1955 public void setInvoiceCostSourceCode(String invoiceCostSourceCode) {
1956 this.invoiceCostSourceCode = invoiceCostSourceCode;
1957 }
1958
1959 public Integer getVendorHeaderGeneratedIdentifier() {
1960 return vendorHeaderGeneratedIdentifier;
1961 }
1962
1963 public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
1964 this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
1965 }
1966
1967 public List<SummaryAccount> getSummaryAccounts() {
1968 if (summaryAccounts == null) {
1969 refreshAccountSummmary();
1970 }
1971 return summaryAccounts;
1972 }
1973
1974 public void setSummaryAccounts(List<SummaryAccount> summaryAccounts) {
1975 this.summaryAccounts = summaryAccounts;
1976 }
1977
1978 public void clearSummaryAccounts() {
1979 summaryAccounts = new ArrayList<SummaryAccount>();
1980 }
1981
1982
1983
1984
1985
1986 public void refreshAccountSummmary() {
1987 clearSummaryAccounts();
1988 summaryAccounts.addAll(SpringContext.getBean(PurapAccountingService.class).generateSummaryAccounts(this));
1989 }
1990
1991 public boolean isSfcFlag() {
1992 return sfcFlag;
1993 }
1994
1995 public void setSfcFlag(boolean sfcFlag) {
1996 this.sfcFlag = sfcFlag;
1997 }
1998
1999 public String getInvoiceItemTotal() {
2000
2001 BigDecimal addChargeItem = BigDecimal.ZERO;
2002 List<OleInvoiceItem> item = this.getItems();
2003 for (OleInvoiceItem invoiceditem : item) {
2004 if (invoiceditem.getItemType().isAdditionalChargeIndicator() && invoiceditem.getExtendedPrice() != null) {
2005 addChargeItem = addChargeItem.add(invoiceditem.getExtendedPrice().bigDecimalValue());
2006 }
2007 }
2008 return (this.getTotalDollarAmount().subtract(new KualiDecimal(addChargeItem)).toString());
2009
2010
2011
2012 }
2013
2014 public void setInvoiceItemTotal(String invoiceItemTotal) {
2015 this.invoiceItemTotal = invoiceItemTotal;
2016 }
2017
2018 public String getInvoiceForeignItemTotal() {
2019 BigDecimal addChargeItem = BigDecimal.ZERO;
2020 List<OleInvoiceItem> item = this.getItems();
2021 for (OleInvoiceItem invoicedItem : item) {
2022 if (invoicedItem.getItemType().isAdditionalChargeIndicator() && invoicedItem.getItemUnitPrice() != null) {
2023 addChargeItem = addChargeItem.add(invoicedItem.getItemUnitPrice());
2024 }
2025 }
2026 return (this.getTotalDollarAmount().subtract(new KualiDecimal(addChargeItem)).toString());
2027 }
2028
2029 public void setInvoiceForeignItemTotal(String invoiceForeignItemTotal) {
2030 this.invoiceForeignItemTotal = invoiceForeignItemTotal;
2031 }
2032
2033 public String getVendorAmount() {
2034 if (vendorAmount != null && !vendorAmount.isEmpty()) {
2035 return vendorAmount;
2036 } else {
2037 vendorAmount = this.getInvoiceAmount();
2038 if (vendorAmount != null && vendorAmount.contains("-")) {
2039 vendorAmount = vendorAmount.replace("-", "");
2040 vendorAmount = "(" + vendorAmount + ")";
2041 }
2042 return vendorAmount;
2043 }
2044 }
2045
2046 public void setVendorAmount(String vendorAmount) {
2047 this.vendorAmount = vendorAmount;
2048 if (vendorAmount.contains("(") || vendorAmount.contains(")")) {
2049 vendorAmount = vendorAmount.replace("(", "");
2050 vendorAmount = vendorAmount.replace(")", "");
2051 vendorAmount = "-" + vendorAmount;
2052 this.vendorAmount = vendorAmount;
2053 }
2054 if (vendorAmount != null && new KualiDecimal(vendorAmount).isLessThan(KualiDecimal.ZERO)) {
2055 this.setInvoiceAmount(vendorAmount);
2056 vendorAmount = vendorAmount.replace("-", "");
2057 vendorAmount = "(" + vendorAmount + ")";
2058 this.vendorAmount = vendorAmount;
2059 } else {
2060 this.setInvoiceAmount(vendorAmount);
2061 this.vendorAmount = vendorAmount;
2062 }
2063 }
2064
2065 public String getForeignVendorAmount() {
2066 if (foreignVendorAmount != null && !foreignVendorAmount.isEmpty()) {
2067 return foreignVendorAmount;
2068 } else {
2069 foreignVendorAmount = this.getForeignVendorInvoiceAmount() != null ? this.getForeignVendorInvoiceAmount().toString() : null;
2070 if (foreignVendorAmount != null && foreignVendorAmount.contains("-")) {
2071 foreignVendorAmount = foreignVendorAmount.replace("-", "");
2072 foreignVendorAmount = "(" + foreignVendorAmount + ")";
2073 }
2074 return foreignVendorAmount;
2075 }
2076 }
2077
2078 public void setForeignVendorAmount(String foreignVendorAmount) {
2079 this.foreignVendorAmount = foreignVendorAmount;
2080 if (foreignVendorAmount.contains("(") || foreignVendorAmount.contains(")")) {
2081 foreignVendorAmount = foreignVendorAmount.replace("(", "");
2082 foreignVendorAmount = foreignVendorAmount.replace(")", "");
2083 foreignVendorAmount = "-" + foreignVendorAmount;
2084 this.foreignVendorAmount = foreignVendorAmount;
2085 }
2086 if (foreignVendorAmount != null && new KualiDecimal(foreignVendorAmount).isLessThan(KualiDecimal.ZERO)) {
2087 this.setForeignInvoiceAmount(foreignVendorAmount);
2088 foreignVendorAmount = foreignVendorAmount.replace("-", "");
2089 foreignVendorAmount = "(" + foreignVendorAmount + ")";
2090 this.foreignVendorAmount = foreignVendorAmount;
2091 } else {
2092 this.setForeignInvoiceAmount(foreignVendorAmount);
2093 this.foreignVendorAmount = foreignVendorAmount;
2094 }
2095 }
2096
2097 public String getForeignInvoiceAmount() {
2098 return foreignInvoiceAmount;
2099 }
2100
2101 public void setForeignInvoiceAmount(String foreignInvoiceAmount) {
2102 this.foreignInvoiceAmount = foreignInvoiceAmount;
2103 }
2104
2105 public String getInvoiceAmount() {
2106 return invoiceAmount;
2107 }
2108
2109 public void setInvoiceAmount(String invoiceAmount) {
2110 this.invoiceAmount = invoiceAmount;
2111 }
2112
2113 public boolean isBaSfcFlag() {
2114 return baSfcFlag;
2115 }
2116
2117 public void setBaSfcFlag(boolean baSfcFlag) {
2118 this.baSfcFlag = baSfcFlag;
2119 }
2120
2121
2122
2123
2124
2125
2126
2127
2128 protected KualiDecimal getInvoicedTotalWithAllItems(boolean includeBelowTheLine, List<OleInvoiceItem> itemsForTotal) {
2129
2130 BigDecimal total = BigDecimal.ZERO;
2131 for (OleInvoiceItem item : itemsForTotal) {
2132 item.refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
2133 ItemType it = item.getItemType();
2134 if (includeBelowTheLine || it.isLineItemIndicator()) {
2135 BigDecimal totalAmount = item.getTotalAmount().bigDecimalValue();
2136 BigDecimal itemTotal = (totalAmount != null) ? totalAmount : BigDecimal.ZERO;
2137 if (item.isDebitItem()) {
2138 total = total.add(itemTotal);
2139 } else {
2140 total = total.subtract(itemTotal);
2141 }
2142
2143
2144
2145 }
2146 }
2147 return new KualiDecimal(total);
2148 }
2149
2150 protected KualiDecimal getInvoicedForeignTotalWithAllItems(boolean includeBelowTheLine, List<OleInvoiceItem> itemsForTotal) {
2151
2152 KualiDecimal total = new KualiDecimal(BigDecimal.ZERO);
2153 for (OleInvoiceItem item : itemsForTotal) {
2154 item.refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
2155 ItemType it = item.getItemType();
2156 if (includeBelowTheLine || it.isLineItemIndicator()) {
2157 KualiDecimal totalAmount = item.getForeignTotalAmount();
2158 KualiDecimal itemTotal = (totalAmount != null) ? totalAmount : KualiDecimal.ZERO;
2159 if (item.isDebitItem()) {
2160 total = total.add(itemTotal);
2161 } else {
2162 total = total.subtract(itemTotal);
2163 }
2164 }
2165 }
2166 return total;
2167 }
2168
2169 public String getInvoicedItemTotal() {
2170 KualiDecimal total = getInvoicedTotalWithAllItems(false, this.getItems());
2171 if (this.isItemSign()) {
2172 if (total.isLessThan(KualiDecimal.ZERO)) {
2173 total = total;
2174 }
2175 }
2176 return total != null ? total.toString() : "0";
2177 }
2178
2179 public void setInvoicedItemTotal(String invoicedItemTotal) {
2180 this.invoicedItemTotal = invoicedItemTotal;
2181 }
2182
2183 public String getInvoicedForeignItemTotal() {
2184 KualiDecimal foreignItemTotal = getInvoicedForeignTotalWithAllItems(false, this.getItems());
2185
2186
2187
2188
2189
2190 return foreignItemTotal != null ? foreignItemTotal.toString() : "0";
2191 }
2192
2193 public void setInvoicedForeignItemTotal(String invoicedForeignItemTotal) {
2194 this.invoicedForeignItemTotal = invoicedForeignItemTotal;
2195 }
2196
2197 public String getItemTotal() {
2198 if(!this.isDbRetrieval()){
2199 itemTotal = this.getInvoicedItemTotal();
2200 }
2201 if (itemTotal != null && !itemTotal.contains("(")
2202 && new KualiDecimal(itemTotal).isLessThan(KualiDecimal.ZERO)) {
2203 itemTotal = itemTotal.replace("-", "");
2204 itemTotal = "(" + itemTotal + ")";
2205 }
2206 return itemTotal;
2207 }
2208
2209 public void setItemTotal(String itemTotal) {
2210 this.itemTotal = itemTotal;
2211 }
2212
2213 public String getForeignItemTotal() {
2214 if(!this.isDbRetrieval()){
2215 foreignItemTotal = this.getInvoicedForeignItemTotal();
2216 }
2217 if (foreignItemTotal != null && !foreignItemTotal.contains("(")
2218 && new KualiDecimal(foreignItemTotal).isLessThan(KualiDecimal.ZERO)) {
2219 foreignItemTotal = foreignItemTotal.replace("-", "");
2220 foreignItemTotal = "(" + foreignItemTotal + ")";
2221 }
2222 return foreignItemTotal;
2223 }
2224
2225 public void setForeignItemTotal(String foreignItemTotal) {
2226 this.foreignItemTotal = foreignItemTotal;
2227 }
2228
2229 public String getGrantTotal() {
2230 if(!this.isDbRetrieval()){
2231 grantTotal = this.getInvoicedGrandTotal();
2232 }
2233 if (grantTotal != null && !grantTotal.contains("(")
2234 && new KualiDecimal(grantTotal).isLessThan(KualiDecimal.ZERO)) {
2235 grantTotal = grantTotal.replace("-", "");
2236 grantTotal = "(" + grantTotal + ")";
2237 }
2238 return grantTotal;
2239 }
2240
2241 public void setGrantTotal(String grantTotal) {
2242 this.grantTotal = grantTotal;
2243 }
2244
2245 public String getForeignGrandTotal() {
2246 if(!this.isDbRetrieval()){
2247 foreignGrandTotal = this.getInvoicedForeignGrandTotal();
2248 }
2249 if (foreignGrandTotal != null && !foreignGrandTotal.contains("(")
2250 && new KualiDecimal(foreignGrandTotal).isLessThan(KualiDecimal.ZERO)) {
2251 foreignGrandTotal = foreignGrandTotal.replace("-", "");
2252 foreignGrandTotal = "(" + foreignGrandTotal + ")";
2253 }
2254 return foreignGrandTotal;
2255 }
2256
2257 public void setForeignGrandTotal(String foreignGrandTotal) {
2258 this.foreignGrandTotal = foreignGrandTotal;
2259 }
2260
2261 public String getInvoicedGrandTotal() {
2262 KualiDecimal total = getInvoicedTotalWithAllItems(true, this.getItems());
2263
2264
2265
2266
2267
2268 return total != null ? total.toString() : "0";
2269 }
2270
2271 public void setInvoicedGrandTotal(String invoicedGrandTotal) {
2272 this.invoicedGrandTotal = invoicedGrandTotal;
2273 }
2274
2275 public String getInvoicedForeignGrandTotal() {
2276 KualiDecimal total = getInvoicedForeignTotalWithAllItems(true, this.getItems());
2277
2278
2279
2280
2281
2282 for (OleInvoiceItem item : (List<OleInvoiceItem>)this.getItems()) {
2283 if (!item.getItemType().getItemTypeCode().equalsIgnoreCase(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE)
2284 && item.getAdditionalForeignUnitCost() != null) {
2285 total = total.add(new KualiDecimal(item.getAdditionalForeignUnitCost()));
2286 }
2287 else if (!item.getItemType().getItemTypeCode().equalsIgnoreCase(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE)
2288 && item.getItemForeignUnitCost() != null) {
2289 total = total.add(item.getItemForeignUnitCost());
2290 }
2291 }
2292
2293 return total != null ? total.toString() : "0";
2294 }
2295 public void setInvoicedForeignGrandTotal(String invoicedForeignGrandTotal) {
2296 this.invoicedForeignGrandTotal = invoicedForeignGrandTotal;
2297 }
2298
2299 public boolean isValidationFlag() {
2300 return validationFlag;
2301 }
2302
2303 public void setValidationFlag(boolean validationFlag) {
2304 this.validationFlag = validationFlag;
2305 }
2306
2307 public boolean isBlanketApproveValidationFlag() {
2308 return blanketApproveValidationFlag;
2309 }
2310
2311 public void setBlanketApproveValidationFlag(boolean blanketApproveValidationFlag) {
2312 this.blanketApproveValidationFlag = blanketApproveValidationFlag;
2313 }
2314
2315 public String getPurchaseOrderDocumentNums() {
2316 return purchaseOrderDocumentNums;
2317 }
2318
2319 public void setPurchaseOrderDocumentNums(String purchaseOrderDocumentNums) {
2320 this.purchaseOrderDocumentNums = purchaseOrderDocumentNums;
2321 }
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331 public boolean isOverviewFlag() {
2332 return overviewFlag;
2333 }
2334
2335 public void setOverviewFlag(boolean overviewFlag) {
2336 this.overviewFlag = overviewFlag;
2337 }
2338
2339 public boolean isVendorInfoFlag() {
2340 return vendorInfoFlag;
2341 }
2342
2343 public void setVendorInfoFlag(boolean vendorInfoFlag) {
2344 this.vendorInfoFlag = vendorInfoFlag;
2345 }
2346
2347 public boolean isInvoiceInfoFlag() {
2348 return invoiceInfoFlag;
2349 }
2350
2351 public void setInvoiceInfoFlag(boolean invoiceInfoFlag) {
2352 this.invoiceInfoFlag = invoiceInfoFlag;
2353 }
2354
2355 public boolean isProcessItemFlag() {
2356 return processItemFlag;
2357 }
2358
2359 public void setProcessItemFlag(boolean processItemFlag) {
2360 this.processItemFlag = processItemFlag;
2361 }
2362
2363 public boolean isProcessTitlesFlag() {
2364 return processTitlesFlag;
2365 }
2366
2367 public void setProcessTitlesFlag(boolean processTitlesFlag) {
2368 this.processTitlesFlag = processTitlesFlag;
2369 }
2370
2371 public boolean isCurrentItemsFlag() {
2372 return currentItemsFlag;
2373 }
2374
2375 public void setCurrentItemsFlag(boolean currentItemsFlag) {
2376 this.currentItemsFlag = currentItemsFlag;
2377 }
2378
2379 public boolean isAdditionalChargesFlag() {
2380 return additionalChargesFlag;
2381 }
2382
2383 public void setAdditionalChargesFlag(boolean additionalChargesFlag) {
2384 this.additionalChargesFlag = additionalChargesFlag;
2385 }
2386
2387 public boolean isAccountSummaryFlag() {
2388 return accountSummaryFlag;
2389 }
2390
2391 public void setAccountSummaryFlag(boolean accountSummaryFlag) {
2392 this.accountSummaryFlag = accountSummaryFlag;
2393 }
2394
2395 public boolean isNotesAndAttachmentFlag() {
2396 return notesAndAttachmentFlag;
2397 }
2398
2399 public void setNotesAndAttachmentFlag(boolean notesAndAttachmentFlag) {
2400 this.notesAndAttachmentFlag = notesAndAttachmentFlag;
2401 }
2402
2403 public boolean isAdHocRecipientsFlag() {
2404 return adHocRecipientsFlag;
2405 }
2406
2407 public void setAdHocRecipientsFlag(boolean adHocRecipientsFlag) {
2408 this.adHocRecipientsFlag = adHocRecipientsFlag;
2409 }
2410
2411 public boolean isRouteLogFlag() {
2412 return routeLogFlag;
2413 }
2414
2415 public void setRouteLogFlag(boolean routeLogFlag) {
2416 this.routeLogFlag = routeLogFlag;
2417 }
2418
2419 public boolean isRouteLogDisplayFlag() {
2420 return routeLogDisplayFlag;
2421 }
2422
2423 public void setRouteLogDisplayFlag(boolean routeLogDisplayFlag) {
2424 this.routeLogDisplayFlag = routeLogDisplayFlag;
2425 }
2426
2427
2428
2429
2430
2431 @Override
2432 public void toCopy() throws WorkflowException, ValidationException {
2433 super.toCopy();
2434 String[] collapseSections = getOleInvoiceService().getDefaultCollapseSections();
2435 this.setOverviewFlag(getOleInvoiceService().canCollapse(OLEConstants.OVERVIEW_SECTION, collapseSections));
2436 this.setVendorInfoFlag(getOleInvoiceService().canCollapse(OLEConstants.VENDOR_INFO_SECTION, collapseSections));
2437 this.setInvoiceInfoFlag(getOleInvoiceService().canCollapse(OLEConstants.INVOICE_INFO_SECTION, collapseSections));
2438 this.setProcessTitlesFlag(getOleInvoiceService().canCollapse(OLEConstants.PROCESS_TITLES_SECTION, collapseSections));
2439 this.setCurrentItemsFlag(getOleInvoiceService().canCollapse(OLEConstants.CURRENT_ITEM_SECTION, collapseSections));
2440 this.setAdditionalChargesFlag(getOleInvoiceService().canCollapse(OLEConstants.ADDITIONAL_CHARGES_SECTION, collapseSections));
2441 this.setAccountSummaryFlag(getOleInvoiceService().canCollapse(OLEConstants.ACCOUNT_SUMMARY_SECTION, collapseSections));
2442 this.setAdHocRecipientsFlag(getOleInvoiceService().canCollapse(OLEConstants.ADHOC_RECIPIENT_SECTION, collapseSections));
2443 this.setRouteLogFlag(getOleInvoiceService().canCollapse(OLEConstants.ROUTE_LOG_SECTION, collapseSections));
2444 this.setNotesAndAttachmentFlag(getOleInvoiceService().canCollapse(OLEConstants.NOTES_AND_ATTACH_SECTION, collapseSections));
2445
2446 this.setAccountsPayablePurchasingDocumentLinkIdentifier(null);
2447 this.setRelatedViews(null);
2448 this.setInvoiceNumber("");
2449 this.setNoteLine1Text("");
2450
2451 Person currentUser = GlobalVariables.getUserSession().getPerson();
2452 this.setPurapDocumentIdentifier(null);
2453
2454
2455
2456 updateAndSaveAppDocStatus(InvoiceStatuses.APPDOC_INITIATE);
2457 this.setPostingYear(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear());
2458
2459 for (Iterator iter = this.getItems().iterator(); iter.hasNext(); ) {
2460 OleInvoiceItem item = (OleInvoiceItem) iter.next();
2461 item.setPurapDocumentIdentifier(null);
2462 item.setItemIdentifier(null);
2463 if (this.getCloneDebitInvoice().equalsIgnoreCase("true")) {
2464 item.setDebitItem(true);
2465 item.setInvoiceListPrice(item.getItemListPrice().abs().toString());
2466 } else {
2467 item.setDebitItem(false);
2468 item.setInvoiceListPrice(item.getItemListPrice().negated().toString());
2469 }
2470 for (Iterator acctIter = item.getSourceAccountingLines().iterator(); acctIter.hasNext(); ) {
2471 InvoiceAccount account = (InvoiceAccount) acctIter.next();
2472 account.setAccountIdentifier(null);
2473 account.setItemIdentifier(null);
2474 account.setObjectId(null);
2475 account.setVersionNumber(null);
2476 }
2477 item.setPaidCopies(new ArrayList<OLEPaidCopy>());
2478 }
2479 SpringContext.getBean(PurapService.class).addBelowLineItems(this);
2480 this.refreshNonUpdateableReferences();
2481 }
2482
2483
2484
2485
2486
2487
2488
2489 @Override
2490 public boolean getAllowsCopy() {
2491
2492 boolean allowsCopy = true;
2493 return allowsCopy;
2494 }
2495
2496
2497
2498
2499
2500
2501 public boolean isDuplicateFlag() {
2502 return duplicateFlag;
2503 }
2504
2505
2506
2507
2508
2509
2510 public void setDuplicateFlag(boolean duplicateFlag) {
2511 this.duplicateFlag = duplicateFlag;
2512 }
2513
2514 public String getSearchResultInvoiceDate() {
2515 return searchResultInvoiceDate;
2516 }
2517
2518 public void setSearchResultInvoiceDate(String searchResultInvoiceDate) {
2519 this.searchResultInvoiceDate = searchResultInvoiceDate;
2520 }
2521
2522 public String getSearchResultInvoicePayDate() {
2523 return searchResultInvoicePayDate;
2524 }
2525
2526 public void setSearchResultInvoicePayDate(String searchResultInvoicePayDate) {
2527 this.searchResultInvoicePayDate = searchResultInvoicePayDate;
2528 }
2529
2530 public boolean isDuplicateApproveFlag() {
2531 return duplicateApproveFlag;
2532 }
2533
2534 public void setDuplicateApproveFlag(boolean duplicateApproveFlag) {
2535 this.duplicateApproveFlag = duplicateApproveFlag;
2536 }
2537
2538 public String getCloneDebitInvoice() {
2539 return cloneDebitInvoice;
2540 }
2541
2542 public void setCloneDebitInvoice(String cloneDebitInvoice) {
2543 this.cloneDebitInvoice = cloneDebitInvoice;
2544 }
2545
2546 public boolean isCloneFlag() {
2547 return cloneFlag;
2548 }
2549
2550 public void setCloneFlag(boolean cloneFlag) {
2551 this.cloneFlag = cloneFlag;
2552 }
2553
2554 public List<OlePaymentRequestDocument> getPaymentRequestDocuments() {
2555 return paymentRequestDocuments;
2556 }
2557
2558 public void setPaymentRequestDocuments(List<OlePaymentRequestDocument> paymentRequestDocuments) {
2559 this.paymentRequestDocuments = paymentRequestDocuments;
2560 }
2561
2562 public boolean isOffsetAccountIndicator() {
2563 return offsetAccountIndicator;
2564 }
2565
2566 public void setOffsetAccountIndicator(boolean offsetAccountIndicator) {
2567 this.offsetAccountIndicator = offsetAccountIndicator;
2568 }
2569
2570 public boolean isItemSign() {
2571 return itemSign;
2572 }
2573
2574 public void setItemSign(boolean itemSign) {
2575 this.itemSign = itemSign;
2576 }
2577
2578 public boolean isBlanketApproveSubscriptionDateValidationFlag() {
2579 return blanketApproveSubscriptionDateValidationFlag;
2580 }
2581
2582 public void setBlanketApproveSubscriptionDateValidationFlag(boolean blanketApproveSubscriptionDateValidationFlag) {
2583 this.blanketApproveSubscriptionDateValidationFlag = blanketApproveSubscriptionDateValidationFlag;
2584 }
2585
2586 public boolean isSubscriptionDateValidationFlag() {
2587 return subscriptionDateValidationFlag;
2588 }
2589
2590 public void setSubscriptionDateValidationFlag(boolean subscriptionDateValidationFlag) {
2591 this.subscriptionDateValidationFlag = subscriptionDateValidationFlag;
2592 }
2593
2594 public String getVendorLink() {
2595 String oleurl = ConfigContext.getCurrentContextConfig().getProperty("ole.url");
2596 String url = oleurl+ OLEConstants.VENDOR_LINK +vendorHeaderGeneratedIdentifier + "&vendorDetailAssignedIdentifier="
2597 +vendorDetailAssignedIdentifier;
2598 return url;
2599 }
2600
2601 public void setVendorLink(String vendorLink) {
2602 this.vendorLink = vendorLink;
2603 }
2604
2605 public boolean isForeignCurrencyFlag() {
2606 return foreignCurrencyFlag;
2607 }
2608
2609 public void setForeignCurrencyFlag(boolean foreignCurrencyFlag) {
2610 this.foreignCurrencyFlag = foreignCurrencyFlag;
2611 }
2612
2613 public Long getInvoiceCurrencyTypeId() {
2614 return invoiceCurrencyTypeId;
2615 }
2616
2617 public void setInvoiceCurrencyTypeId(Long invoiceCurrencyTypeId) {
2618 this.invoiceCurrencyTypeId = invoiceCurrencyTypeId;
2619 }
2620
2621 public String getInvoiceCurrencyType() {
2622 return invoiceCurrencyType;
2623 }
2624
2625 public void setInvoiceCurrencyType(String invoiceCurrencyType) {
2626 this.invoiceCurrencyType = invoiceCurrencyType;
2627 }
2628
2629 public OleCurrencyType getOleCurrencyType() {
2630 return oleCurrencyType;
2631 }
2632
2633 public void setOleCurrencyType(OleCurrencyType oleCurrencyType) {
2634 this.oleCurrencyType = oleCurrencyType;
2635 }
2636
2637 public boolean isCurrencyOverrideFlag() {
2638 return currencyOverrideFlag;
2639 }
2640
2641 public void setCurrencyOverrideFlag(boolean currencyOverrideFlag) {
2642 this.currencyOverrideFlag = currencyOverrideFlag;
2643 }
2644
2645 public String getCurrencyOverrideMessage() {
2646 return currencyOverrideMessage;
2647 }
2648
2649 public void setCurrencyOverrideMessage(String currencyOverrideMessage) {
2650 this.currencyOverrideMessage = currencyOverrideMessage;
2651 }
2652
2653 public String getInvoiceCurrencyExchangeRate() {
2654 if (invoiceCurrencyExchangeRate != null && !invoiceCurrencyExchangeRate.isEmpty()) {
2655 if (invoiceCurrencyExchangeRate != null && invoiceCurrencyExchangeRate.contains("-")) {
2656 invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate.replace("-", "");
2657 invoiceCurrencyExchangeRate = "(" + invoiceCurrencyExchangeRate + ")";
2658 }
2659 return invoiceCurrencyExchangeRate;
2660 }
2661 return invoiceCurrencyExchangeRate;
2662 }
2663
2664 public void setInvoiceCurrencyExchangeRate(String invoiceCurrencyExchangeRate) {
2665 this.invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate;
2666 if (invoiceCurrencyExchangeRate != null) {
2667 if (invoiceCurrencyExchangeRate.contains("(") || invoiceCurrencyExchangeRate.contains(")")) {
2668 invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate.replace("(", "");
2669 invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate.replace(")", "");
2670 invoiceCurrencyExchangeRate = "-" + invoiceCurrencyExchangeRate;
2671 this.invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate;
2672 }
2673 if (new KualiDecimal(invoiceCurrencyExchangeRate).isLessThan(KualiDecimal.ZERO)) {
2674 invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate.replace("-", "");
2675 invoiceCurrencyExchangeRate = "(" + invoiceCurrencyExchangeRate + ")";
2676 this.invoiceCurrencyExchangeRate = invoiceCurrencyExchangeRate;
2677 }
2678 }
2679 }
2680
2681 public boolean isDbRetrieval() {
2682 return dbRetrieval;
2683 }
2684
2685 public void setDbRetrieval(boolean dbRetrieval) {
2686 this.dbRetrieval = dbRetrieval;
2687 }
2688
2689 public boolean isEnableCurrentItems() {
2690 return enableCurrentItems;
2691 }
2692
2693 public void setEnableCurrentItems(boolean enableCurrentItems) {
2694 this.enableCurrentItems = enableCurrentItems;
2695 }
2696 }