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