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