Search in sources :

Example 16 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkRemoveIncomeStreamChartAndAccount.

protected boolean checkRemoveIncomeStreamChartAndAccount() {
    boolean success = true;
    if (newAccountGlobal.isRemoveIncomeStreamChartAndAccount() && (StringUtils.isNotBlank(newAccountGlobal.getIncomeStreamFinancialCoaCode()) || StringUtils.isNotBlank(newAccountGlobal.getIncomeStreamAccountNumber()))) {
        success = false;
        putFieldError(KFSPropertyConstants.INCOME_STREAM_CHART_OF_ACCOUNTS_CODE, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_INC_STR_CHART_NOT_EMPTY_AND_REMOVE_INC_STR_CHART_AND_ACCT_CHECKED);
        putFieldError(KFSPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_INC_STR_ACCT_NOT_EMPTY_AND_REMOVE_INC_STR_CHART_AND_ACCT_CHECKED);
    }
    if (newAccountGlobal.isRemoveIncomeStreamChartAndAccount()) {
        for (AccountGlobalDetail accountGlobalDetail : newAccountGlobal.getAccountGlobalDetails()) {
            boolean required = false;
            // if the subFundGroup object is null, we cant test, so exit
            if (ObjectUtils.isNull(accountGlobalDetail.getAccount().getSubFundGroup())) {
                continue;
            }
            // retrieve the subfundcode and fundgroupcode
            String subFundGroupCode = accountGlobalDetail.getAccount().getSubFundGroupCode().trim();
            String fundGroupCode = accountGlobalDetail.getAccount().getSubFundGroup().getFundGroupCode().trim();
            // changed foundation code.  Now, it is using similar 'income stream account' validation rule for 'Account'
            if (isIncomeStreamAccountRequired(fundGroupCode, subFundGroupCode)) {
                required = true;
            }
            // if the income stream account is not required, then we're done
            if (!required) {
                continue;
            }
            if (newAccountGlobal.isRemoveIncomeStreamChartAndAccount()) {
                putFieldError(CUKFSPropertyConstants.REMOVE_INCOME_STREAM_CHART_AND_ACCOUNT, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_REMOVE_INC_STR_CHART_AND_ACCT_CHECKED_WHEN_INC_STR_REQ_FOR_ACCT, new String[] { accountGlobalDetail.getChartOfAccountsCode(), accountGlobalDetail.getAccountNumber() });
            }
        }
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 17 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkContinuationAccount.

/**
 * This method validates that a continuation account is required and that the values provided exist
 *
 * @param document An instance of the maintenance document being validated.
 * @param newExpDate The expiration date assigned to the account being validated for submission.
 * @return True if the continuation account values are valid for the associated account, false otherwise.
 */
protected boolean checkContinuationAccount(MaintenanceDocument document, Date newExpDate) {
    LOG.info("checkContinuationAccount called");
    boolean result = true;
    boolean continuationAccountIsValid = true;
    // make sure both coaCode and accountNumber are filled out
    if (ObjectUtils.isNotNull(newExpDate)) {
        if (!checkEmptyValue(newAccountGlobal.getContinuationAccountNumber())) {
            putFieldError("continuationAccountNumber", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_ACCT_REQD_IF_EXP_DATE_COMPLETED);
            continuationAccountIsValid = false;
        }
        if (!checkEmptyValue(newAccountGlobal.getContinuationFinChrtOfAcctCd())) {
            putFieldError("continuationFinChrtOfAcctCd", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_FINCODE_REQD_IF_EXP_DATE_COMPLETED);
            continuationAccountIsValid = false;
        }
    }
    // if both fields aren't present, then we're done
    if (continuationAccountIsValid && ObjectUtils.isNotNull(newAccountGlobal.getContinuationAccountNumber()) && ObjectUtils.isNotNull(newAccountGlobal.getContinuationFinChrtOfAcctCd())) {
        // do an existence/active test
        DictionaryValidationService dvService = super.getDictionaryValidationService();
        boolean referenceExists = dvService.validateReferenceExists(newAccountGlobal, "continuationAccount");
        if (!referenceExists) {
            putFieldError("continuationAccountNumber", KFSKeyConstants.ERROR_EXISTENCE, "Continuation Account: " + newAccountGlobal.getContinuationFinChrtOfAcctCd() + "-" + newAccountGlobal.getContinuationAccountNumber());
            continuationAccountIsValid = false;
        }
    }
    if (continuationAccountIsValid) {
        result = true;
    } else {
        List<AccountGlobalDetail> gAcctDetails = newAccountGlobal.getAccountGlobalDetails();
        for (AccountGlobalDetail detail : gAcctDetails) {
            if (null != detail.getAccountNumber() && null != newAccountGlobal.getContinuationAccountNumber()) {
                result &= detail.getAccountNumber().equals(newAccountGlobal.getContinuationAccountNumber());
                result &= detail.getChartOfAccountsCode().equals(newAccountGlobal.getContinuationFinChrtOfAcctCd());
            }
        }
    }
    return result;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 18 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method processCustomAddCollectionLineBusinessRules.

/**
 * This method calls checkAccountDetails checkExpirationDate checkOnlyOneChartAddLineErrorWrapper whenever a new
 * {@link AccountGlobalDetail} is added to this global
 *
 * @see org.kuali.kfs.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomAddCollectionLineBusinessRules(org.kuali.kfs.kns.document.MaintenanceDocument,
 *      java.lang.String, org.kuali.kfs.krad.bo.PersistableBusinessObject)
 */
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
    boolean success = super.processCustomAddCollectionLineBusinessRules(document, collectionName, bo);
    // this incoming bo needs to be refreshed because it doesn't have its subobjects setup
    bo.refreshNonUpdateableReferences();
    if (bo instanceof AccountGlobalDetail) {
        AccountGlobalDetail detail = (AccountGlobalDetail) bo;
        success &= checkAccountDetails(detail);
        success &= checkExpirationDate(document, detail);
        success &= checkOnlyOneChartAddLineErrorWrapper(detail, newAccountGlobal.getAccountGlobalDetails());
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 19 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkAllAccountUsers.

/**
 * This method checks to make sure that if the users are filled out (fiscal officer, supervisor, manager) that they are not the
 * same individual Only need to check this if these are new users that override existing users on the {@link Account} object
 *
 * @param doc
 * @param newFiscalOfficer
 * @param newManager
 * @param newSupervisor
 * @return true if the users are either not changed or pass the sub-rules
 */
protected boolean checkAllAccountUsers(AccountGlobal doc, Person newFiscalOfficer, Person newManager, Person newSupervisor) {
    boolean success = true;
    if (LOG.isDebugEnabled()) {
        LOG.debug("newSupervisor: " + newSupervisor);
        LOG.debug("newFiscalOfficer: " + newFiscalOfficer);
        LOG.debug("newManager: " + newManager);
    }
    // non null
    if (newSupervisor != null || newFiscalOfficer != null || newManager != null) {
        // loop over all AccountGlobalDetail records
        int index = 0;
        for (AccountGlobalDetail detail : doc.getAccountGlobalDetails()) {
            success &= checkAccountUsers(detail, newFiscalOfficer, newManager, newSupervisor, index);
            index++;
        }
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 20 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkRemoveContinuationChartAndAccount.

protected boolean checkRemoveContinuationChartAndAccount() {
    boolean success = true;
    if (newAccountGlobal.isRemoveContinuationChartAndAccount() && (StringUtils.isNotBlank(newAccountGlobal.getContinuationFinChrtOfAcctCd()) || StringUtils.isNotBlank(newAccountGlobal.getContinuationAccountNumber()))) {
        success = false;
        putFieldError(KFSPropertyConstants.CONTINUATION_CHART_OF_ACCOUNTS_CODE, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_CNT_CHART_NOT_EMPTY_AND_REMOVE_CNT_CHART_AND_ACCT_CHECKED);
        putFieldError(KFSPropertyConstants.CONTINUATION_ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_CNT_ACCT_NOT_EMPTY_AND_REMOVE_CNT_CHART_AND_ACCT_CHECKED);
    }
    if (newAccountGlobal.isRemoveContinuationChartAndAccount()) {
        // check that expiration date does not exist
        if (newAccountGlobal.isRemoveAccountExpirationDate()) {
        // no problem, we can remove
        } else {
            if (ObjectUtils.isNull(newAccountGlobal.getAccountExpirationDate())) {
                for (AccountGlobalDetail accountGlobalDetail : newAccountGlobal.getAccountGlobalDetails()) {
                    if (ObjectUtils.isNotNull(accountGlobalDetail.getAccount().getAccountExpirationDate())) {
                        putFieldError(CUKFSPropertyConstants.REMOVE_CONTINUATION_CHART_AND_ACCOUNT, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_EXP_DT_AND_REMOVE_CONT_ACCT, new String[] { accountGlobalDetail.getChartOfAccountsCode(), accountGlobalDetail.getAccountNumber() });
                    }
                }
            }
        }
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Aggregations

AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)25 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)8 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)6 Test (org.junit.Test)5 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)4 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)3 HashMap (java.util.HashMap)3 Date (java.sql.Date)2 ArrayList (java.util.ArrayList)2 Account (org.kuali.kfs.coa.businessobject.Account)2 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 GlobalObjectWithIndirectCostRecoveryAccounts (edu.cornell.kfs.coa.businessobject.GlobalObjectWithIndirectCostRecoveryAccounts)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 AccountDelegate (org.kuali.kfs.coa.businessobject.AccountDelegate)1 AccountDelegateGlobalDetail (org.kuali.kfs.coa.businessobject.AccountDelegateGlobalDetail)1 IndirectCostRecoveryRateDetail (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)1 OrganizationService (org.kuali.kfs.coa.service.OrganizationService)1