Search in sources :

Example 6 with AccountGlobalDetail

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

the class AccountGlobalRule method checkICRCollectionDoesNotExistWhenUpdatingToNonCGSubFund.

protected boolean checkICRCollectionDoesNotExistWhenUpdatingToNonCGSubFund(CuAccountGlobal newAccount, String subFundGroupCode) {
    boolean success = true;
    boolean hasActiveUpdates = !newAccount.getActiveIndirectCostRecoveryAccounts().isEmpty();
    if (hasActiveUpdates) {
        success = false;
        putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_ICR_FIELDS_FILLED_FOR_NON_CG_ACCOUNT, newAccount.getSubFundGroupCode());
    } else {
        if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && !newAccount.getAccountGlobalDetails().isEmpty()) {
            for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
                List<IndirectCostRecoveryAccount> activeICRList = getActiveUpdatedIcrAccounts(newAccount, accountGlobalDetail);
                if (!activeICRList.isEmpty()) {
                    success &= false;
                    putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ICR_NOT_EMPTY_FOR_NON_CG_ACCOUNT, new String[] { subFundGroupCode, accountGlobalDetail.getAccountNumber() });
                }
            }
        }
    }
    return success;
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 7 with AccountGlobalDetail

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

the class AccountGlobalRule method checkCloseAccounts.

protected boolean checkCloseAccounts() {
    boolean success = true;
    LOG.info("checkCloseAccount called");
    // check that at least one account is being closed
    boolean isBeingClosed = false;
    if (ObjectUtils.isNotNull(newAccountGlobal.getAccountGlobalDetails()) && newAccountGlobal.getAccountGlobalDetails().size() > 0) {
        for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) {
            if (detail.getAccount().isActive() && newAccountGlobal.getClosed() != null && newAccountGlobal.getClosed()) {
                isBeingClosed = true;
                break;
            }
        }
    }
    if (!isBeingClosed) {
        return true;
    }
    if (ObjectUtils.isNotNull(newAccountGlobal.getAccountGlobalDetails()) && newAccountGlobal.getAccountGlobalDetails().size() > 0) {
        for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) {
            success &= checkCloseAccount(detail);
        }
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 8 with AccountGlobalDetail

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

the class AccountGlobalRule method checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG.

private boolean checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG(CuAccountGlobal newAccount) {
    boolean result = true;
    boolean filledIcrTypeCode = checkEmptyValue(newAccount.getAcctIndirectCostRcvyTypeCd());
    boolean filledFinancialIcrSeriesIdentifier = checkEmptyValue(newAccount.getFinancialIcrSeriesIdentifier());
    // Validation for financialIcrSeriesIdentifier
    if (filledFinancialIcrSeriesIdentifier) {
        String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
        String icrSeriesId = newAccount.getFinancialIcrSeriesIdentifier();
        Map<String, String> pkMap = new HashMap<String, String>();
        pkMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
        pkMap.put(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrSeriesId);
        Collection<IndirectCostRecoveryRateDetail> icrRateDetails = getBoService().findMatching(IndirectCostRecoveryRateDetail.class, pkMap);
        if (ObjectUtils.isNull(icrRateDetails) || icrRateDetails.isEmpty()) {
            String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(Account.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
            putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
            result &= false;
        } else {
            for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
                if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
                    putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
                    result &= false;
                    break;
                }
            }
        }
    }
    if (!filledIcrTypeCode || !filledFinancialIcrSeriesIdentifier) {
        if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && newAccount.getAccountGlobalDetails().size() > 0) {
            for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
                accountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
                if (!filledIcrTypeCode) {
                    result &= checkEmptyBOField(KFSPropertyConstants.ACCT_INDIRECT_COST_RCVY_TYPE_CD, accountGlobalDetail.getAccount().getAcctIndirectCostRcvyTypeCd(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_TYPE_CODE_CANNOT_BE_EMPTY));
                }
                if (!filledFinancialIcrSeriesIdentifier) {
                    result &= checkEmptyBOField(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, accountGlobalDetail.getAccount().getFinancialIcrSeriesIdentifier(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_SERIES_IDENTIFIER_CANNOT_BE_EMPTY));
                }
            }
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) IndirectCostRecoveryRateDetail(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 9 with AccountGlobalDetail

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

the class CuAccountDelegateGlobal method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.krad.document.GlobalBusinessObject#applyGlobalChanges(org.kuali.rice.krad.bo.BusinessObject)
 */
@SuppressWarnings("deprecation")
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
    List<AccountDelegate> persistables = new ArrayList();
    List<AccountDelegateGlobalDetail> changeDocuments = this.getDelegateGlobals();
    List<AccountGlobalDetail> accountDetails = this.getAccountGlobalDetails();
    for (AccountDelegateGlobalDetail changeDocument : changeDocuments) {
        for (AccountGlobalDetail accountDetail : accountDetails) {
            Account account = (Account) boService.findByPrimaryKey(Account.class, accountDetail.getPrimaryKeys());
            // the busines rules for this document should have caught this.
            if (account == null) {
                throw new RuntimeException("Account [" + accountDetail.getChartOfAccountsCode() + "-" + accountDetail.getAccountNumber() + "] was not present in the database. " + "This should never happen under normal circumstances, as an invalid account should have " + "been caught by the Business Rules infrastructure.");
            }
            // attempt to load the existing Delegate from the DB, if it exists. we do this to avoid
            // versionNumber conflicts if we tried to just insert a new record that already existed.
            Map pkMap = new HashMap();
            // chartOfAccountsCode & accountNumber
            pkMap.putAll(accountDetail.getPrimaryKeys());
            pkMap.put("financialDocumentTypeCode", changeDocument.getFinancialDocumentTypeCode());
            pkMap.put("accountDelegateSystemId", changeDocument.getAccountDelegateUniversalId());
            AccountDelegate delegate = (AccountDelegate) boService.findByPrimaryKey(AccountDelegate.class, pkMap);
            // so lets populate it with the primary keys
            if (delegate == null) {
                delegate = new AccountDelegate();
                delegate.setChartOfAccountsCode(accountDetail.getChartOfAccountsCode());
                delegate.setAccountNumber(accountDetail.getAccountNumber());
                delegate.setAccountDelegateSystemId(changeDocument.getAccountDelegateUniversalId());
                delegate.setFinancialDocumentTypeCode(changeDocument.getFinancialDocumentTypeCode());
                delegate.setActive(true);
            } else {
                delegate.setActive(true);
            }
            // APPROVAL FROM AMOUNT
            delegate.setFinDocApprovalFromThisAmt(changeDocument.getApprovalFromThisAmount());
            // APPROVAL TO AMOUNT
            delegate.setFinDocApprovalToThisAmount(changeDocument.getApprovalToThisAmount());
            // PRIMARY ROUTING
            delegate.setAccountsDelegatePrmrtIndicator(changeDocument.getAccountDelegatePrimaryRoutingIndicator());
            // START DATE
            if (changeDocument.getAccountDelegateStartDate() != null) {
                delegate.setAccountDelegateStartDate(new Date(changeDocument.getAccountDelegateStartDate().getTime()));
            }
            persistables.add(delegate);
        }
    }
    return new ArrayList<PersistableBusinessObject>(persistables);
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AccountDelegateGlobalDetail(org.kuali.kfs.coa.businessobject.AccountDelegateGlobalDetail) HashMap(java.util.HashMap) AccountDelegate(org.kuali.kfs.coa.businessobject.AccountDelegate) ArrayList(java.util.ArrayList) Date(java.sql.Date) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with AccountGlobalDetail

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

the class CuAccountGlobal method updateAccountValuesOnAccountGlobalDetailWithNewValuesFromAccountGlobalDoc.

private Account updateAccountValuesOnAccountGlobalDetailWithNewValuesFromAccountGlobalDoc(GlobalBusinessObjectDetailBase globalDetail) {
    AccountGlobalDetail accountGlobalDetail = (AccountGlobalDetail) globalDetail;
    Account account = getBusinessObjectService().findByPrimaryKey(Account.class, accountGlobalDetail.getPrimaryKeys());
    if (ObjectUtils.isNotNull(account)) {
        updateAccountBasicFields(account);
        updateAccountExtendedAttribute(account);
        if (ObjectUtils.isNotNull(this.getIndirectCostRecoveryAccounts()) && this.getIndirectCostRecoveryAccounts().size() > 0) {
            updateIcrAccounts(globalDetail, account.getIndirectCostRecoveryAccounts());
        }
    }
    return account;
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) 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