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