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