From 0a91fe7eab95ecf46e4f0d0999ebeef39e036002 Mon Sep 17 00:00:00 2001 From: NSSuresh11 Date: Fri, 16 Jun 2017 13:30:09 +0530 Subject: [PATCH] OLE-8532 : Sufficient funds check giving unexpected warnings --- .../purap/document/InvoiceDocument.java | 4 +- .../document/PaymentRequestDocument.java | 4 +- .../purap/document/PurchaseOrderDocument.java | 18 ++- .../purap/document/RequisitionDocument.java | 2 +- .../web/struts/OlePurchaseOrderAction.java | 3 +- .../web/struts/OleRequisitionAction.java | 7 +- .../controller/OLEInvoiceController.java | 131 ++++++++------- .../select/document/OleInvoiceDocument.java | 18 +-- .../document/OlePaymentRequestDocument.java | 33 ++-- .../OlePurchaseOrderAmendmentDocument.java | 34 ++-- .../document/OlePurchaseOrderDocument.java | 16 +- .../document/OleRequisitionDocument.java | 61 +++---- .../document/OleVendorCreditMemoDocument.java | 4 +- .../OleRequisitionDocumentService.java | 8 +- .../impl/OleInvoiceFundCheckServiceImpl.java | 5 +- .../OleRequisitionDocumentServiceImpl.java | 149 +++++++++++++++++- .../OlePurchaseOrderDocumentPreRules.java | 3 +- .../impl/OleRequisitionDocumentPreRules.java | 3 +- 18 files changed, 340 insertions(+), 163 deletions(-) diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/InvoiceDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/InvoiceDocument.java index 46ef7b127f..106f3a5d54 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/InvoiceDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/InvoiceDocument.java @@ -1188,10 +1188,10 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { return requiresAccountsPayableReviewRouting(); } - if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { + else if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { return shouldWaitForReceiving(); } - if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { + else if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { return isVendorEmployeeOrNonResidentAlien(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PaymentRequestDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PaymentRequestDocument.java index 69402f839c..945add978a 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PaymentRequestDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PaymentRequestDocument.java @@ -1174,10 +1174,10 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { return requiresAccountsPayableReviewRouting(); } - if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { + else if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { return shouldWaitForReceiving(); } - if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { + else if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { return isVendorEmployeeOrNonResidentAlien(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PurchaseOrderDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PurchaseOrderDocument.java index 65c106776c..5e1f96179c 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PurchaseOrderDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/PurchaseOrderDocument.java @@ -1633,7 +1633,8 @@ protected boolean isObjectCodeAllowedForAwardRouting(PurApAccountingLine account protected boolean isBudgetReviewRequired() { // if document's fiscal year is less than or equal to the current fiscal year - if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().compareTo(getPostingYear()) >= 0) { + int fiscalYear = SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear(); + if (new Integer(fiscalYear).compareTo(getPostingYear()) >= 0) { List sourceAccountingLineList = this.getSourceAccountingLines(); boolean sufficientFundCheck = false; @@ -1653,15 +1654,22 @@ protected boolean isBudgetReviewRequired() { } if (notificationOption != null && (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW) )) { + OleRequisitionDocumentService oleRequisitionDocumentService = (OleRequisitionDocumentService) SpringContext + .getBean("oleRequisitionDocumentService"); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine,notificationOption,fiscalYear); + if (sufficientFundCheck) { + return true; + } + // get list of sufficientfundItems // delete and recreate the GL entries for this document so they do not get included in the SF check // This is *NOT* ideal. The SF service needs to be updated to allow it to provide the current // document number so that it can be exlcuded from pending entry checks. - List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); + // List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); // dumb loop to just force OJB to load the objects. Otherwise, the proxy object above // only gets resolved *after* the delete below and no SF check happens. - for (GeneralLedgerPendingEntry glpe : pendingEntries) { + /* for (GeneralLedgerPendingEntry glpe : pendingEntries) { glpe.getChartOfAccountsCode(); } SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber()); @@ -1670,7 +1678,7 @@ protected boolean isBudgetReviewRequired() { SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); if (fundsItems.size() > 0) { return true; - } + }*/ } /*Commented for jira OLE-2359 * for (SufficientFundsItem fundsItem : fundsItems) { @@ -1705,7 +1713,7 @@ private boolean isNotificationRequired() { notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine,notificationOption,SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return sufficientFundCheck; } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/RequisitionDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/RequisitionDocument.java index 74a7fa6bd8..2c0294aafa 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/RequisitionDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/RequisitionDocument.java @@ -115,7 +115,7 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(PurapWorkflowConstants.HAS_ACCOUNTING_LINES)) { return !isMissingAccountingLines(); } - if (nodeName.equals(PurapWorkflowConstants.AMOUNT_REQUIRES_SEPARATION_OF_DUTIES_REVIEW_SPLIT)) { + else if (nodeName.equals(PurapWorkflowConstants.AMOUNT_REQUIRES_SEPARATION_OF_DUTIES_REVIEW_SPLIT)) { return isSeparationOfDutiesReviewRequired(); } return super.answerSplitNodeQuestion(nodeName); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OlePurchaseOrderAction.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OlePurchaseOrderAction.java index 6c1fdc2e7c..55e571c8ca 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OlePurchaseOrderAction.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OlePurchaseOrderAction.java @@ -59,6 +59,7 @@ import org.kuali.ole.sys.businessobject.SourceAccountingLine; import org.kuali.ole.sys.context.SpringContext; import org.kuali.ole.sys.document.validation.event.AddAccountingLineEvent; +import org.kuali.ole.sys.service.UniversityDateService; import org.kuali.ole.vnd.VendorConstants; import org.kuali.ole.vnd.businessobject.*; import org.kuali.ole.vnd.document.service.VendorService; @@ -283,7 +284,7 @@ public ActionForward calculate(ActionMapping mapping, ActionForm form, HttpServl notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.BLOCK_USE)) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { GlobalVariables.getMessageMap().putError( OLEConstants.SufficientFundCheck.ERROR_MSG_FOR_INSUFF_FUND, RiceKeyConstants.ERROR_CUSTOM, diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OleRequisitionAction.java b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OleRequisitionAction.java index ebc106f430..63a653745d 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OleRequisitionAction.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/module/purap/document/web/struts/OleRequisitionAction.java @@ -61,6 +61,7 @@ import org.kuali.ole.sys.businessobject.SourceAccountingLine; import org.kuali.ole.sys.context.SpringContext; import org.kuali.ole.sys.document.validation.event.AddAccountingLineEvent; +import org.kuali.ole.sys.service.UniversityDateService; import org.kuali.ole.vnd.VendorConstants; import org.kuali.ole.vnd.businessobject.*; import org.kuali.ole.vnd.document.service.VendorService; @@ -271,7 +272,7 @@ public ActionForward calculate(ActionMapping mapping, ActionForm form, HttpServl notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.BLOCK_USE)) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { GlobalVariables.getMessageMap().putError( OLEConstants.SufficientFundCheck.ERROR_MSG_FOR_INSUFF_FUND, RiceKeyConstants.ERROR_CUSTOM, @@ -1172,7 +1173,7 @@ public boolean isBudgetReviewRequired(OleRequisitionDocument document) { } if (notificationOption != null && (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW))) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnBlanketApproveRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnBlanketApproveRequisition(accLine,notificationOption,SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return sufficientFundCheck; } @@ -1410,4 +1411,4 @@ protected ActionForward performQuestionWithInputAgainBecauseOfErrors(ActionMappi return performQuestion(mapping, form, request, response, questionId, questionText, questionType, caller, context, true, reason, errorKey, errorPropertyName, errorParameter); }*/ -} \ No newline at end of file +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/controller/OLEInvoiceController.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/controller/OLEInvoiceController.java index 9e56df4f50..f0ff3913fe 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/controller/OLEInvoiceController.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/controller/OLEInvoiceController.java @@ -751,14 +751,14 @@ public ModelAndView save(@ModelAttribute("KualiForm") DocumentFormBase form, Bin throw new RuntimeException(e); } } - if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { + /* if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { if (oleInvoiceDocument.getSourceAccountingLines().size() > 0) { fundCheckFlag = oleInvoiceFundCheckService.isBudgetReviewRequired(oleInvoiceDocument); if (fundCheckFlag) { return getUIFModelAndView(form); } } - } + }*/ List olePurchaseOrderDocumentList = oleInvoiceDocument.getPurchaseOrderDocuments(); for (OlePurchaseOrderDocument olePurchaseOrderDocument : olePurchaseOrderDocumentList) { List olePurchaseOrderLineForInvoiceList = getOleInvoiceItemService().getOlePurchaseOrderLineForInvoice(olePurchaseOrderDocument); @@ -859,14 +859,14 @@ public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, Bi /* Added for Grand total*/ oleInvoiceDocument.setGrandTotal(oleInvoiceDocument.getGrandTotal()); } - if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { + /*if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { if (oleInvoiceDocument.getSourceAccountingLines().size() > 0) { fundCheckFlag = oleInvoiceFundCheckService.isBudgetReviewRequired(oleInvoiceDocument); if (fundCheckFlag) { return getUIFModelAndView(form); } } - } + }*/ String subscriptionValidationMessage = getInvoiceService().createSubscriptionDateOverlapQuestionText(oleInvoiceDocument); if (!subscriptionValidationMessage.isEmpty() && subscriptionValidationMessage != null){ oleInvoiceForm.setSubscriptionDateValidationMessage(subscriptionValidationMessage); @@ -882,35 +882,42 @@ public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, Bi } if(oleInvoiceDocument.getSourceAccountingLines().size() > 0) { if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { - List sourceAccountingLineList = oleInvoiceDocument.getSourceAccountingLines(); - for (SourceAccountingLine accLine : sourceAccountingLineList) { - Map searchMap = new HashMap(); - String notificationOption = null; - boolean sufficientFundCheck; - Map key = new HashMap(); - String chartCode = accLine.getChartOfAccountsCode(); - String accNo = accLine.getAccountNumber(); - String objectCd = accLine.getFinancialObjectCode(); - key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode); - key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo); - OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey( - OleSufficientFundCheck.class, key); - if (account != null) { - notificationOption = account.getNotificationOption(); - } - if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { - if (oleInvoiceDocument.getPaymentMethodIdentifier() != null && (SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(oleInvoiceDocument.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) { - sufficientFundCheck = false; - } else { - sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); + if (oleInvoiceDocument.getPaymentMethodIdentifier() != null && (SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(oleInvoiceDocument.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) { + } else { + List sourceAccountingLineList = oleInvoiceDocument.getSourceAccountingLines(); + for (SourceAccountingLine accLine : sourceAccountingLineList) { + Map searchMap = new HashMap(); + String notificationOption = null; + boolean sufficientFundCheck; + Map key = new HashMap(); + String chartCode = accLine.getChartOfAccountsCode(); + String accNo = accLine.getAccountNumber(); + String objectCd = accLine.getFinancialObjectCode(); + key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode); + key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo); + OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey( + OleSufficientFundCheck.class, key); + if (account != null) { + notificationOption = account.getNotificationOption(); } - oleInvoiceDocument.setSfcFlag(sufficientFundCheck); - if (sufficientFundCheck) { - oleInvoiceForm.setSubscriptionDateValidationMessage(null); - oleInvoiceDocument.setSubscriptionDateValidationFlag(false); + if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.BLOCK_USE)) { + sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); + if (sufficientFundCheck) { + GlobalVariables.getMessageMap().putError( + OLEConstants.SufficientFundCheck.ERROR_MSG_FOR_INSUFF_FUND, RiceKeyConstants.ERROR_CUSTOM, + OLEConstants.SufficientFundCheck.INSUFF_FUND_INV + accLine.getAccountNumber()); + return getUIFModelAndView(oleInvoiceForm); + } + } else if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { + sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); oleInvoiceDocument.setSfcFlag(sufficientFundCheck); - oleInvoiceForm.setSfcFailRouteMsg(OLEConstants.INV_INSUFF_FUND + accLine.getAccountNumber()); - return getUIFModelAndView(oleInvoiceForm); + if (sufficientFundCheck) { + oleInvoiceForm.setSubscriptionDateValidationMessage(null); + oleInvoiceDocument.setSubscriptionDateValidationFlag(false); + oleInvoiceDocument.setSfcFlag(sufficientFundCheck); + oleInvoiceForm.setSfcFailRouteMsg(OLEConstants.INV_INSUFF_FUND + accLine.getAccountNumber()); + return getUIFModelAndView(oleInvoiceForm); + } } } } @@ -1092,7 +1099,7 @@ public ModelAndView blanketApprove(@ModelAttribute("KualiForm") DocumentFormBase oleInvoiceDocument.setAmountExceedsForBlanketApprove(true); return getUIFModelAndView(form); } - boolean fundCheckFlag = false; + /*boolean fundCheckFlag = false; if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { if (oleInvoiceDocument.getSourceAccountingLines().size() > 0) { fundCheckFlag = oleInvoiceFundCheckService.isBudgetReviewRequired(oleInvoiceDocument); @@ -1100,7 +1107,7 @@ public ModelAndView blanketApprove(@ModelAttribute("KualiForm") DocumentFormBase return getUIFModelAndView(form); } } - } + }*/ String subscriptionValidationMessage = getInvoiceService().createSubscriptionDateOverlapQuestionText(oleInvoiceDocument); if (!subscriptionValidationMessage.isEmpty() && subscriptionValidationMessage != null){ oleInvoiceForm.setSubscriptionValidationMessage(subscriptionValidationMessage); @@ -1113,34 +1120,40 @@ public ModelAndView blanketApprove(@ModelAttribute("KualiForm") DocumentFormBase oleInvoiceDocument.setBlanketApproveValidationFlag(true); } } - if(oleInvoiceDocument.getSourceAccountingLines().size() > 0) { + if (oleInvoiceDocument.getSourceAccountingLines().size() > 0) { if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { - List sourceAccountingLineList = oleInvoiceDocument.getSourceAccountingLines(); - for (SourceAccountingLine accLine : sourceAccountingLineList) { - Map searchMap = new HashMap(); - String notificationOption = null; - boolean sufficientFundCheck; - Map key = new HashMap(); - String chartCode = accLine.getChartOfAccountsCode(); - String accNo = accLine.getAccountNumber(); - String objectCd = accLine.getFinancialObjectCode(); - key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode); - key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo); - OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey( - OleSufficientFundCheck.class, key); - if (account != null) { - notificationOption = account.getNotificationOption(); - } - if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { - if (oleInvoiceDocument.getPaymentMethodIdentifier() != null && (SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(oleInvoiceDocument.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) { - sufficientFundCheck = false; - } else { - sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); + if (oleInvoiceDocument.getPaymentMethodIdentifier() != null && (SpringContext.getBean(OleInvoiceService.class).getPaymentMethodType(oleInvoiceDocument.getPaymentMethodIdentifier())).equals(OLEConstants.DEPOSIT)) { + } else { + List sourceAccountingLineList = oleInvoiceDocument.getSourceAccountingLines(); + for (SourceAccountingLine accLine : sourceAccountingLineList) { + Map searchMap = new HashMap(); + String notificationOption = null; + boolean sufficientFundCheck; + Map key = new HashMap(); + String chartCode = accLine.getChartOfAccountsCode(); + String accNo = accLine.getAccountNumber(); + key.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode); + key.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo); + OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey( + OleSufficientFundCheck.class, key); + if (account != null) { + notificationOption = account.getNotificationOption(); } - if (sufficientFundCheck) { - oleInvoiceDocument.setBaSfcFlag(sufficientFundCheck); - oleInvoiceForm.setSfcFailApproveMsg(OLEConstants.INV_INSUFF_FUND + accLine.getAccountNumber()); - return getUIFModelAndView(oleInvoiceForm); + if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.BLOCK_USE)) { + sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); + if (sufficientFundCheck) { + GlobalVariables.getMessageMap().putError( + OLEConstants.SufficientFundCheck.ERROR_MSG_FOR_INSUFF_FUND, RiceKeyConstants.ERROR_CUSTOM, + OLEConstants.SufficientFundCheck.INSUFF_FUND_INV + accLine.getAccountNumber()); + return getUIFModelAndView(oleInvoiceForm); + } + } else if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { + sufficientFundCheck = oleInvoiceFundCheckService.hasSufficientFundCheckRequired(accLine); + if (sufficientFundCheck) { + oleInvoiceDocument.setBaSfcFlag(sufficientFundCheck); + oleInvoiceForm.setSfcFailApproveMsg(OLEConstants.INV_INSUFF_FUND + accLine.getAccountNumber()); + return getUIFModelAndView(oleInvoiceForm); + } } } } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleInvoiceDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleInvoiceDocument.java index 9c815792a3..0f05c6f61d 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleInvoiceDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleInvoiceDocument.java @@ -1790,7 +1790,7 @@ protected void populateAccountsForRouting() { if (nodeName != null && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) { - if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() + /*if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() .compareTo(getPostingYear()) >= 0) { SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( @@ -1804,32 +1804,32 @@ protected void populateAccountsForRouting() { fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFundsForInvoice(pendingEntries); -/* +*//* SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( this); SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFundsForInvoice( pendingEntries); -*/ +*//* - } + }*/ SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this); if (accountsForRouting == null) { accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems())); } - String documentFiscalYearString = this.getPostingYear().toString(); + /*String documentFiscalYearString = this.getPostingYear().toString(); List fundsItemList = new ArrayList(); for (SufficientFundsItem fundsItem : fundsItems) { fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode()); - } + }*/ if (accountsForRouting != null) { - for (Iterator accountsForRoutingIter = accountsForRouting.iterator(); accountsForRoutingIter.hasNext(); ) { + /*for (Iterator accountsForRoutingIter = accountsForRouting.iterator(); accountsForRoutingIter.hasNext(); ) { if (!(fundsItemList.contains(((SourceAccountingLine) accountsForRoutingIter.next()) .getChartOfAccountsCode()))) { accountsForRoutingIter.remove(); } - } + }*/ /* SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber());*/ setAccountsForRouting(accountsForRouting); @@ -2869,4 +2869,4 @@ public KualiDecimal getTotalDollarAmount(boolean includeInactive, boolean includ } return total; } -} \ No newline at end of file +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePaymentRequestDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePaymentRequestDocument.java index 1e68fb558b..dc1a1cfecc 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePaymentRequestDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePaymentRequestDocument.java @@ -1097,32 +1097,32 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(OLEConstants.HAS_VENDOR_DEPOSIT_ACCOUNT)) { return hasVendorDepositAccount(); } - if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_INVOICE_TYPE)) { + else if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_INVOICE_TYPE)) { return hasInvoiceType(); } - if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PREPAID_INVOICE_TYPE)) { + else if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PREPAID_INVOICE_TYPE)) { return hasPrepaidInvoiceType(); } - if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PAYMENT_METHOD)) { + else if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PAYMENT_METHOD)) { return hasPaymentMethod(); } - if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { + else if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { return isBudgetReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { + else if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { return requiresAccountsPayableReviewRouting(); } - if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { + else if (nodeName.equals(PurapWorkflowConstants.PURCHASE_WAS_RECEIVED)) { return shouldWaitForReceiving(); } - if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { + else if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { return isVendorEmployeeOrNonResidentAlien(); } - if (nodeName.equals(OLEConstants.REQUIRES_SEPARATION_OF_DUTIES)) { + else if (nodeName.equals(OLEConstants.REQUIRES_SEPARATION_OF_DUTIES)) { return isSeparationOfDutiesReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { + else if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { return isNotificationRequired(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); @@ -1218,7 +1218,7 @@ public boolean isBudgetReviewRequired() { return false; } // if document's fiscal year is less than or equal to the current fiscal year - if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { + else if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().compareTo(getPostingYear()) >= 0) { List sourceAccountingLineList = this.getSourceAccountingLines(); for (SourceAccountingLine accLine : sourceAccountingLineList) { @@ -1271,7 +1271,10 @@ private boolean isNotificationRequired() { .getBean("oleRequisitionDocumentService"); List sourceAccountingLineList = this.getSourceAccountingLines(); boolean sufficientFundCheck = false; - if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { + if((SpringContext.getBean(OlePaymentRequestService.class).getPaymentMethod(this.getPaymentMethodId())).equals(OLEConstants.DEPOSIT)) { + return false; + } + else if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { for (SourceAccountingLine accLine : sourceAccountingLineList) { Map searchMap = new HashMap(); String notificationOption = null; @@ -1315,7 +1318,7 @@ protected void populateAccountsForRouting() { if (nodeName != null && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) { - if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() + /*if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() .compareTo(getPostingYear()) >= 0) { List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); for (GeneralLedgerPendingEntry glpe : pendingEntries) { @@ -1327,10 +1330,10 @@ protected void populateAccountsForRouting() { // SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( // this); // SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); - } + }*/ SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this); accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems())); - String documentFiscalYearString = this.getPostingYear().toString(); + /*String documentFiscalYearString = this.getPostingYear().toString(); List fundsItemList = new ArrayList(); List accountsList = new ArrayList(); for (SufficientFundsItem fundsItem : fundsItems) { @@ -1341,7 +1344,7 @@ protected void populateAccountsForRouting() { .getChartOfAccountsCode()))) { accountsForRoutingIter.remove(); } - } + }*/ setAccountsForRouting(accountsForRouting); // need to refresh to get the references for the searchable attributes (ie status) and for invoking route levels (ie // account diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderAmendmentDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderAmendmentDocument.java index f0b7091516..600f72fb19 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderAmendmentDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderAmendmentDocument.java @@ -523,20 +523,20 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(PurapWorkflowConstants.HAS_NEW_UNORDERED_ITEMS)) { return isNewUnorderedItem(); } - if (nodeName.equals(PurapWorkflowConstants.CONTRACT_MANAGEMENT_REVIEW_REQUIRED)) { + else if (nodeName.equals(PurapWorkflowConstants.CONTRACT_MANAGEMENT_REVIEW_REQUIRED)) { return isContractManagementReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.AWARD_REVIEW_REQUIRED)) { + else if (nodeName.equals(PurapWorkflowConstants.AWARD_REVIEW_REQUIRED)) { return isAwardReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { + else if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { return isBudgetReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { + else if (nodeName.equals(PurapWorkflowConstants.VENDOR_IS_EMPLOYEE_OR_NON_RESIDENT_ALIEN)) { return isVendorEmployeeOrNonResidentAlien(); } - if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { + else if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { return isNotificationRequired(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); @@ -636,25 +636,25 @@ protected void populateAccountsForRouting() { .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) { if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() .compareTo(getPostingYear()) >= 0) { - List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); - for (GeneralLedgerPendingEntry glpe : pendingEntries) { + // List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); + /*for (GeneralLedgerPendingEntry glpe : pendingEntries) { glpe.getChartOfAccountsCode(); - } - SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber()); + }*/ + /*SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber()); fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFunds( - pendingEntries); - SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( - this); - SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); + pendingEntries);*/ + // SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( + // this); + // SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); } SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this); accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems())); - String documentFiscalYearString = this.getPostingYear().toString(); + /*String documentFiscalYearString = this.getPostingYear().toString(); List fundsItemList = new ArrayList(); List accountsList = new ArrayList(); for (SufficientFundsItem fundsItem : fundsItems) { fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode()); - } + }*/ setAccountsForRouting(accountsForRouting); refreshNonUpdateableReferences(); for (SourceAccountingLine sourceLine : getAccountsForRouting()) { @@ -692,7 +692,7 @@ protected boolean isBudgetReviewRequired() { } if (notificationOption != null && (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW))) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return true; } @@ -721,7 +721,7 @@ private boolean isNotificationRequired() { notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return true; } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderDocument.java index 2607e3fa01..0806c3d677 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OlePurchaseOrderDocument.java @@ -740,19 +740,19 @@ protected void populateAccountsForRouting() { if (nodeName != null && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) { - if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().compareTo(getPostingYear()) >= 0) { + /*if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().compareTo(getPostingYear()) >= 0) { List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); - for (GeneralLedgerPendingEntry glpe : pendingEntries) { + *//*for (GeneralLedgerPendingEntry glpe : pendingEntries) { glpe.getChartOfAccountsCode(); - } + }*//* SpringContext.getBean(GeneralLedgerPendingEntryService.class).delete(getDocumentNumber()); fundsItems = SpringContext.getBean(SufficientFundsService.class).checkSufficientFunds(pendingEntries); - SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(this); - SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); - } + // SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(this); + // SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); + }*/ SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this); accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems())); - List fundsItemList = new ArrayList(); + /*List fundsItemList = new ArrayList(); for (SufficientFundsItem fundsItem : fundsItems) { fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode()); } @@ -760,7 +760,7 @@ protected void populateAccountsForRouting() { if (!(fundsItemList.contains(((SourceAccountingLine) accountsForRoutingIter.next()).getChartOfAccountsCode()))) { accountsForRoutingIter.remove(); } - } + }*/ setAccountsForRouting(accountsForRouting); // need to refresh to get the references for the searchable attributes (ie status) and for invoking route levels (ie account // objects) -hjs diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleRequisitionDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleRequisitionDocument.java index 34fe7ec9d3..4e292cf7b3 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleRequisitionDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleRequisitionDocument.java @@ -152,7 +152,7 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat /*if (nodeName.equals(PurapWorkflowConstants.HAS_LICENSE_REQUEST)) { return isLicenseRequested(); }*/ - if (nodeName.equals(PurapWorkflowConstants.AMOUNT_REQUIRES_SEPARATION_OF_DUTIES_REVIEW_SPLIT)) { + else if (nodeName.equals(PurapWorkflowConstants.AMOUNT_REQUIRES_SEPARATION_OF_DUTIES_REVIEW_SPLIT)) { return isSeparationOfDutiesReviewRequired(); /* * Modified as per review comments for OLE-24 Methods are commented as Notification is not implemented currently To revisit @@ -165,28 +165,33 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat * (nodeName.equals(PurapWorkflowConstants.DUPLICATE_RECORD_CHECK)) return isDuplicateRecord(); if * (nodeName.equals(PurapWorkflowConstants.NEW_VENDOR_CHECK)) return isNewVendor(); */ - if (nodeName.equals(PurapWorkflowConstants.YBP_ORDERS)) { - return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM); + else if (nodeName.equals(PurapWorkflowConstants.YBP_ORDERS)) { + return true; + //return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM); } - if (nodeName.equals(PurapWorkflowConstants.STANDING_ORDERS)) { - return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_STANDING); + else if (nodeName.equals(PurapWorkflowConstants.STANDING_ORDERS)) { + return true; + //return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_STANDING); } - if (nodeName.equals(PurapWorkflowConstants.SUBSCRIPTION_ORDERS)) { - return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_SUBSCRIPTION); + else if (nodeName.equals(PurapWorkflowConstants.SUBSCRIPTION_ORDERS)) { + return true; + //return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_SUBSCRIPTION); } - if (nodeName.equals(PurapWorkflowConstants.APPROVAL_ORDERS)) { - return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_APPROVAL); + else if (nodeName.equals(PurapWorkflowConstants.APPROVAL_ORDERS)) { + return true; + //return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_APPROVAL); } - if (nodeName.equals(PurapWorkflowConstants.HAS_VENDOR)) { + else if (nodeName.equals(PurapWorkflowConstants.HAS_VENDOR)) { return isMissingVendor(); } - if (nodeName.equals(PurapWorkflowConstants.HAS_FIRMFIXED_WITH_LR)) { - return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM); + else if (nodeName.equals(PurapWorkflowConstants.HAS_FIRMFIXED_WITH_LR)) { + return true; + //return isRequiredOrderType(this.getPurchaseOrderTypeId(), PurapConstants.ORDER_TYPE_FIRM); } - if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { + else if (nodeName.equals(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED)) { return isBudgetReviewRequired(); } - if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { + else if (nodeName.equals(PurapWorkflowConstants.NOTIFY_BUDGET_REVIEW)) { return isNotificationRequired(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); @@ -453,12 +458,14 @@ public void prepareForSave() { while (iterator.hasNext()) { LOG.debug("###########inside prepareForSave ole requisition item###########"); OleRequisitionItem singleItem = (OleRequisitionItem) iterator.next(); - KRADServiceLocator.getBusinessObjectService().delete(singleItem.getDeletedCopiesList()); - setItemDetailWhilePrepareForSave(singleItem); - setDocumentHeaderDescription(singleItem); - //Creatbib method is executed when the order is through Preorderservice - if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_WEBFORM)) { - createBib(singleItem); + if(singleItem.getItemTypeCode().equals(org.kuali.ole.OLEConstants.ITM_TYP_CODE)) { + KRADServiceLocator.getBusinessObjectService().delete(singleItem.getDeletedCopiesList()); + setItemDetailWhilePrepareForSave(singleItem); + setDocumentHeaderDescription(singleItem); + //Creatbib method is executed when the order is through Preorderservice + if (this.getRequisitionSourceCode().equalsIgnoreCase(OleSelectConstant.REQUISITON_SRC_TYPE_WEBFORM)) { + createBib(singleItem); + } } } } catch (DocStoreConnectionException dsce) { @@ -1071,7 +1078,7 @@ public boolean isBudgetReviewRequired() { } if (notificationOption != null && (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW))) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return sufficientFundCheck; } @@ -1099,7 +1106,7 @@ private boolean isNotificationRequired() { notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) { - sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine); + sufficientFundCheck = oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()); if (sufficientFundCheck) { return sufficientFundCheck; } @@ -1118,7 +1125,7 @@ protected void populateAccountsForRouting() { if (nodeName != null && (nodeName.equalsIgnoreCase(PurapWorkflowConstants.BUDGET_NODE) || nodeName .equalsIgnoreCase(PurapWorkflowConstants.BUDGET_REVIEW_REQUIRED))) { - if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() + /* if (SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear() .compareTo(getPostingYear()) >= 0) { List pendingEntries = getPendingLedgerEntriesForSufficientFundsChecking(); for (GeneralLedgerPendingEntry glpe : pendingEntries) { @@ -1130,13 +1137,13 @@ protected void populateAccountsForRouting() { SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries( this); SpringContext.getBean(BusinessObjectService.class).save(getGeneralLedgerPendingEntries()); - } + }*/ SpringContext.getBean(PurapAccountingService.class).updateAccountAmounts(this); accountsForRouting = (SpringContext.getBean(PurapAccountingService.class).generateSummary(getItems())); - List fundsItemList = new ArrayList(); + /* List fundsItemList = new ArrayList(); for (SufficientFundsItem fundsItem : fundsItems) { fundsItemList.add(fundsItem.getAccount().getChartOfAccountsCode()); - } + }*/ setAccountsForRouting(accountsForRouting); refreshNonUpdateableReferences(); for (SourceAccountingLine sourceLine : getAccountsForRouting()) { @@ -1175,4 +1182,4 @@ public String getParameter(String name) { Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey); return parameter != null ? parameter.getValue() : null; } -} \ No newline at end of file +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleVendorCreditMemoDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleVendorCreditMemoDocument.java index b7f6bb5e9e..9a47d894fd 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleVendorCreditMemoDocument.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/OleVendorCreditMemoDocument.java @@ -390,10 +390,10 @@ public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperat if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_INVOICE_TYPE)) { return hasInvoiceType(); } - if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PREPAID_INVOICE_TYPE)) { + else if (nodeName.equals(OLEConstants.OlePaymentRequest.HAS_PREPAID_INVOICE_TYPE)) { return hasPrepaidInvoiceType(); } - if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { + else if (nodeName.equals(PurapWorkflowConstants.REQUIRES_IMAGE_ATTACHMENT)) { return requiresAccountsPayableReviewRouting(); } throw new UnsupportedOperationException("Cannot answer split question for this node you call \"" + nodeName + "\""); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/OleRequisitionDocumentService.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/OleRequisitionDocumentService.java index 67e6cb766d..983b608203 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/OleRequisitionDocumentService.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/OleRequisitionDocumentService.java @@ -19,9 +19,13 @@ public interface OleRequisitionDocumentService { - public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine); + // public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine); - public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine); + public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine, String notificationOption,int currentFiscalYear); + + // public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine); + + public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine, String notificationOption,int currentFiscalYear); public String getParameter(String key); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleInvoiceFundCheckServiceImpl.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleInvoiceFundCheckServiceImpl.java index bfbf78b02e..7b8b3fe92b 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleInvoiceFundCheckServiceImpl.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleInvoiceFundCheckServiceImpl.java @@ -63,7 +63,6 @@ public class OleInvoiceFundCheckServiceImpl implements OleInvoiceFundCheckServic @Override public boolean hasSufficientFundCheckRequired(SourceAccountingLine accLine) { boolean hasSufficientFundRequired = false; - if (SpringContext.getBean(OleInvoiceService.class).getParameterBoolean(OLEConstants.CoreModuleNamespaces.SELECT, OLEConstants.OperationType.SELECT, PurapParameterConstants.ALLOW_INVOICE_SUFF_FUND_CHECK)) { Map searchMap = new HashMap(); Map key = new HashMap(); String chartCode = accLine.getChartOfAccountsCode(); @@ -149,9 +148,7 @@ public boolean hasSufficientFundCheckRequired(SourceAccountingLine accLine) { } } } - } return hasSufficientFundRequired; - } private String getFundCode(String chartCode, String accountNumber) { @@ -566,4 +563,4 @@ public void setOleSelectDocumentService(OleSelectDocumentService oleSelectDocume this.oleSelectDocumentService = oleSelectDocumentService; } -} \ No newline at end of file +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleRequisitionDocumentServiceImpl.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleRequisitionDocumentServiceImpl.java index d4bd602938..ad107d8644 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleRequisitionDocumentServiceImpl.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/service/impl/OleRequisitionDocumentServiceImpl.java @@ -59,7 +59,8 @@ public class OleRequisitionDocumentServiceImpl implements OleRequisitionDocument protected ConfigurationService kualiConfigurationService; private OleSelectDocumentService oleSelectDocumentService; private BusinessObjectService businessObjectService; - @Override + + /*@Override public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine) { boolean hasSufficientFundRequired = false; String chartCode = accLine.getChartOfAccountsCode(); @@ -141,6 +142,89 @@ public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine) { } return hasSufficientFundRequired; } +*/ + public boolean hasSufficientFundsOnRequisition(SourceAccountingLine accLine, String notificationOption,int currentFiscalYear) { + boolean hasSufficientFundRequired = false; + String chartCode = accLine.getChartOfAccountsCode(); + String accNo = accLine.getAccountNumber(); + //UniversityDateService universityDateService = SpringContext.getBean(UniversityDateService.class); + //int currentFiscalYear = universityDateService.getCurrentUniversityDate().getUniversityFiscalYear(); + String objectCd = accLine.getFinancialObjectCode(); + String fundCodeType = getFundCode(chartCode, accNo); + // KualiDecimal budgetAllocation = KualiDecimal.ZERO; + KualiDecimal fundBalanceAmt = KualiDecimal.ZERO; + KualiDecimal glPendingAmt = KualiDecimal.ZERO; + /*Map fundKey = new HashMap(); + String notificationOption = null; + fundKey.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode); + fundKey.put(OLEPropertyConstants.ACCOUNT_NUMBER, accNo); + OleSufficientFundCheck account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey( + OleSufficientFundCheck.class, fundKey); + if (account != null) { + notificationOption = account.getNotificationOption(); + }*/ + + if (fundCodeType != null && fundCodeType.equals(OLEConstants.ACCOUNT_FUND_CODE)) { + + if (notificationOption.equals(OLEPropertyConstants.BLOCK_USE) + || notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { + // budgetAllocation = getBudgetAllocationForAccount(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForAccount(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForAccount(chartCode, accNo, currentFiscalYear); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + } else if (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW) + || notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) { + // budgetAllocation = getBudgetAllocationForAccount(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForAccount(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForAccount(chartCode, accNo, currentFiscalYear); + fundBalanceAmt = fundBalanceAmt.subtract(accLine.getAmount()); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + } + + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + glPendingAmt = getGLPendingAmtForAccount(chartCode, accNo, currentFiscalYear); + fundBalanceAmt = fundBalanceAmt.subtract(glPendingAmt); + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + hasSufficientFundRequired = false; + + } + } + + } else if (fundCodeType != null && fundCodeType.equals(OLEConstants.OBJECT_FUND_CODE)) { + if (notificationOption.equals(OLEPropertyConstants.BLOCK_USE) + || notificationOption.equals(OLEPropertyConstants.WARNING_MSG)) { + // budgetAllocation = getBudgetAllocationForObject(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForObject(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForObject(chartCode, accNo, objectCd, currentFiscalYear); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + } else if (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW) + || notificationOption.equals(OLEPropertyConstants.NOTIFICATION)) { + // budgetAllocation = getBudgetAllocationForObject(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForObject(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForObject(chartCode, accNo, objectCd, currentFiscalYear); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + // encumbranceAmt = encumbranceAmt.subtract(accLine.getAmount()); + } + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + glPendingAmt = getGLPendingAmtForObject(chartCode, accNo, objectCd, currentFiscalYear); + fundBalanceAmt = fundBalanceAmt.subtract(glPendingAmt); + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + hasSufficientFundRequired = false; + + } + } + } + return hasSufficientFundRequired; + } + private String getFundCode(String chartCode, String accountNumber) { Map accountMap = new HashMap(); @@ -528,8 +612,65 @@ private KualiDecimal getEncumbranceForObject(String chartCode, String accountNum */ + public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine, String notificationOption,int currentFiscalYear) { + + boolean hasSufficientFundRequired = false; + String chartCode = accLine.getChartOfAccountsCode(); + String accNo = accLine.getAccountNumber(); + String objectCd = accLine.getFinancialObjectCode(); + String fundCodeType = getFundCode(chartCode, accNo); + // KualiDecimal budgetAllocation = KualiDecimal.ZERO; + KualiDecimal fundBalanceAmt = KualiDecimal.ZERO; + KualiDecimal glPendingAmt = KualiDecimal.ZERO; + + if (fundCodeType != null && fundCodeType.equals(OLEConstants.ACCOUNT_FUND_CODE)) { + + if (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW)) { + // budgetAllocation = getBudgetAllocationForAccount(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForAccount(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForAccount(chartCode, accNo, currentFiscalYear); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + } + + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + glPendingAmt = getGLPendingAmtForAccount(chartCode, accNo, currentFiscalYear); + fundBalanceAmt = fundBalanceAmt.subtract(glPendingAmt); + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + hasSufficientFundRequired = false; + + } + } + + } else if (fundCodeType != null && fundCodeType.equals(OLEConstants.OBJECT_FUND_CODE)) { + if (notificationOption.equals(OLEPropertyConstants.BUD_REVIEW)) { + // budgetAllocation = getBudgetAllocationForObject(chartCode, accNo, objectCd); + // encumbranceAmt = getEncumbranceForObject(chartCode, accNo, objectCd); + fundBalanceAmt = getFundBalanceForObject(chartCode, accNo, objectCd,currentFiscalYear); + // budgetAllocation = budgetAllocation.subtract(encumbranceAmt); + } + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + glPendingAmt = getGLPendingAmtForObject(chartCode, accNo, objectCd, currentFiscalYear); + fundBalanceAmt = fundBalanceAmt.subtract(glPendingAmt); + if (accLine.getAmount().isGreaterThan(fundBalanceAmt)) { + hasSufficientFundRequired = true; + } else { + hasSufficientFundRequired = false; + + } + } + } + return hasSufficientFundRequired; + } - public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine) { + + + /*public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLine accLine) { boolean hasSufficientFundRequired = false; String chartCode = accLine.getChartOfAccountsCode(); String accNo = accLine.getAccountNumber(); @@ -593,7 +734,7 @@ public boolean hasSufficientFundsOnBlanketApproveRequisition(SourceAccountingLin } } return hasSufficientFundRequired; - } + }*/ /* public KualiDecimal getBudgetAdjustmentIncreaseForObject(String chartCode, String accountNo, @@ -725,4 +866,4 @@ public BusinessObjectService getBusinessObjectService() { return businessObjectService; } -} \ No newline at end of file +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OlePurchaseOrderDocumentPreRules.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OlePurchaseOrderDocumentPreRules.java index 84a9ee346f..b60ceef8d2 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OlePurchaseOrderDocumentPreRules.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OlePurchaseOrderDocumentPreRules.java @@ -26,6 +26,7 @@ import org.kuali.ole.sys.OLEPropertyConstants; import org.kuali.ole.sys.businessobject.SourceAccountingLine; import org.kuali.ole.sys.context.SpringContext; +import org.kuali.ole.sys.service.UniversityDateService; import org.kuali.rice.core.api.config.property.ConfigurationService; import org.kuali.rice.krad.document.Document; import org.kuali.rice.krad.service.BusinessObjectService; @@ -75,7 +76,7 @@ public boolean doPrompts(Document document) { notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG) - && oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine)) { + && oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear())) { accountNumbers.append(accLine.getAccountNumber()); } } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OleRequisitionDocumentPreRules.java b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OleRequisitionDocumentPreRules.java index 0277922584..4223aee6a5 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OleRequisitionDocumentPreRules.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/select/document/validation/impl/OleRequisitionDocumentPreRules.java @@ -25,6 +25,7 @@ import org.kuali.ole.sys.OLEPropertyConstants; import org.kuali.ole.sys.businessobject.SourceAccountingLine; import org.kuali.ole.sys.context.SpringContext; +import org.kuali.ole.sys.service.UniversityDateService; import org.kuali.rice.core.api.config.property.ConfigurationService; import org.kuali.rice.krad.document.Document; import org.kuali.rice.krad.service.BusinessObjectService; @@ -73,7 +74,7 @@ public boolean doPrompts(Document document) { notificationOption = account.getNotificationOption(); } if (notificationOption != null && notificationOption.equals(OLEPropertyConstants.WARNING_MSG) - && oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine)) { + && oleRequisitionDocumentService.hasSufficientFundsOnRequisition(accLine, notificationOption, SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear())) { accountNumbers.append(accLine.getAccountNumber()); } }