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