Search in sources :

Example 11 with IndirectCostRecoveryAccount

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

the class CuSubAccountPreRules method copyICRFromAccount.

@SuppressWarnings("deprecation")
protected void copyICRFromAccount(MaintenanceDocument document) {
    Person user = GlobalVariables.getUserSession().getPerson();
    // get a new instance of MaintenanceDocumentAuthorizations for this context
    MaintenanceDocumentRestrictions auths = SpringContext.getBean(BusinessObjectAuthorizationService.class).getMaintenanceDocumentRestrictions(document, user);
    // don't need to copy if the user does not have the authority to edit the fields
    if (!auths.getFieldRestriction("a21SubAccount.financialIcrSeriesIdentifier").isReadOnly()) {
        // only need to do this of the account sub type is EX
        A21SubAccount a21SubAccount = newSubAccount.getA21SubAccount();
        Account account = newSubAccount.getAccount();
        if (KFSConstants.SubAccountType.EXPENSE.equals(a21SubAccount.getSubAccountTypeCode())) {
            if (ObjectUtils.isNull(account) || StringUtils.isBlank(account.getAccountNumber())) {
                account = getAccountService().getByPrimaryId(newSubAccount.getChartOfAccountsCode(), newSubAccount.getAccountNumber());
            }
            if (ObjectUtils.isNotNull(account)) {
                if (a21SubAccount.getA21ActiveIndirectCostRecoveryAccounts().isEmpty()) {
                    for (IndirectCostRecoveryAccount icrAccount : account.getActiveIndirectCostRecoveryAccounts()) {
                        A21IndirectCostRecoveryAccount copyAccount = A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount);
                        copyAccount.setNewCollectionRecord(true);
                        a21SubAccount.getA21IndirectCostRecoveryAccounts().add(copyAccount);
                    }
                }
                if (StringUtils.isBlank(a21SubAccount.getFinancialIcrSeriesIdentifier())) {
                    a21SubAccount.setFinancialIcrSeriesIdentifier(account.getFinancialIcrSeriesIdentifier());
                }
                if (StringUtils.isBlank(a21SubAccount.getIndirectCostRecoveryTypeCode())) {
                    a21SubAccount.setIndirectCostRecoveryTypeCode(account.getAcctIndirectCostRcvyTypeCd());
                }
            }
        }
    }
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) MaintenanceDocumentRestrictions(org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) BusinessObjectAuthorizationService(org.kuali.kfs.kns.service.BusinessObjectAuthorizationService) Person(org.kuali.rice.kim.api.identity.Person) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 12 with IndirectCostRecoveryAccount

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

the class GlobalIndirectCostRecoveryAccountsRule method buildCurrentActiveICRAccountsAfterICRUpdates.

protected List<IndirectCostRecoveryAccount> buildCurrentActiveICRAccountsAfterICRUpdates(List<IndirectCostRecoveryAccountChange> icrUpdates, List<IndirectCostRecoveryAccount> existingIcrAccounts, GlobalBusinessObjectDetailBase globalDetail, GlobalObjectWithIndirectCostRecoveryAccounts globalObjectWithIndirectCostRecoveryAccounts) {
    List<IndirectCostRecoveryAccount> currentActiveIndirectCostRecoveryAccountList = new ArrayList<IndirectCostRecoveryAccount>();
    List<IndirectCostRecoveryAccount> existingICRsToBeUpdated = new ArrayList<IndirectCostRecoveryAccount>();
    List<IndirectCostRecoveryAccount> icrAccountsNotUpdated = new ArrayList<IndirectCostRecoveryAccount>();
    for (IndirectCostRecoveryAccount icrAccount : existingIcrAccounts) {
        icrAccountsNotUpdated.add(icrAccount);
    }
    List<IndirectCostRecoveryAccount> icrAccountsToBeUpdatedToActive = new ArrayList<IndirectCostRecoveryAccount>();
    List<IndirectCostRecoveryAccount> icrAccountsToBeAddedAsActive = new ArrayList<IndirectCostRecoveryAccount>();
    if (icrUpdates.size() > 0) {
        // for each new icr on account global doc search for a matching icr on account to be updated
        for (IndirectCostRecoveryAccountChange newICR : icrUpdates) {
            boolean foundMatch = false;
            existingICRsToBeUpdated.clear();
            for (IndirectCostRecoveryAccount icrAccount : icrAccountsNotUpdated) {
                existingICRsToBeUpdated.add(icrAccount);
            }
            IndirectCostRecoveryAccount matchingICRAccountWithSameActiveIndicator = null;
            int currentPosition = 0;
            int maxPosition = existingICRsToBeUpdated.size();
            while (noMatchFoundOrSameActiveIndicatorMatchFoundAndStillHaveICRAccountsToCheck(currentPosition, maxPosition, foundMatch, matchingICRAccountWithSameActiveIndicator)) {
                IndirectCostRecoveryAccount existingICR = existingICRsToBeUpdated.get(currentPosition);
                if (newICR.matchesICRAccount(existingICR)) {
                    foundMatch = true;
                    if (newICR.isActive() == existingICR.isActive()) {
                        // both have the same active indicator, save in
                        // a temp and keep looking
                        matchingICRAccountWithSameActiveIndicator = existingICR;
                    } else {
                        // done stop looking
                        if (newICR.isActive()) {
                            // add to update active
                            IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
                            icrAccountsToBeUpdatedToActive.add(icrAccount);
                        }
                        icrAccountsNotUpdated.remove(existingICR);
                        if (ObjectUtils.isNotNull(matchingICRAccountWithSameActiveIndicator)) {
                            matchingICRAccountWithSameActiveIndicator = null;
                        }
                    }
                }
                currentPosition++;
            }
            if (foundMatch && ObjectUtils.isNotNull(matchingICRAccountWithSameActiveIndicator)) {
                // done stop looking
                if (matchingICRAccountWithSameActiveIndicator.isActive()) {
                    // add to update active
                    IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
                    icrAccountsToBeUpdatedToActive.add(icrAccount);
                }
                icrAccountsNotUpdated.remove(matchingICRAccountWithSameActiveIndicator);
            }
            if (!foundMatch) {
                // done stop looking
                if (newICR.isActive()) {
                    // add to update active
                    IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
                    icrAccountsToBeAddedAsActive.add(icrAccount);
                }
            }
        }
        if (icrAccountsToBeUpdatedToActive.size() > 0) {
            for (IndirectCostRecoveryAccount icrAccount : icrAccountsToBeUpdatedToActive) {
                currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
            }
        }
        if (icrAccountsToBeAddedAsActive.size() > 0) {
            for (IndirectCostRecoveryAccount icrAccount : icrAccountsToBeAddedAsActive) {
                currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
            }
        }
        if (ObjectUtils.isNotNull(icrAccountsNotUpdated) && !icrAccountsNotUpdated.isEmpty()) {
            for (IndirectCostRecoveryAccount icrAccount : icrAccountsNotUpdated) {
                if (icrAccount.isActive()) {
                    currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
                }
            }
        }
    }
    return currentActiveIndirectCostRecoveryAccountList;
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) ArrayList(java.util.ArrayList)

Example 13 with IndirectCostRecoveryAccount

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

the class GlobalIndirectCostRecoveryAccountsRule method computeTotalDistribution.

protected BigDecimal computeTotalDistribution(List<IndirectCostRecoveryAccount> currentActiveIndirectCostRecoveryAccountList) {
    LOG.info("Enter computeTotalDistribution");
    BigDecimal totalDistribution = BigDecimal.ZERO;
    if (ObjectUtils.isNotNull(currentActiveIndirectCostRecoveryAccountList) && (currentActiveIndirectCostRecoveryAccountList.size() > 0)) {
        for (IndirectCostRecoveryAccount icra : currentActiveIndirectCostRecoveryAccountList) {
            totalDistribution = totalDistribution.add(icra.getAccountLinePercent());
            LOG.info("ICR account " + icra.getIndirectCostRecoveryFinCoaCode() + "-" + icra.getIndirectCostRecoveryAccountNumber() + " line percent: " + icra.getAccountLinePercent() + " active " + icra.isActive());
        }
    }
    return totalDistribution;
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) BigDecimal(java.math.BigDecimal)

Example 14 with IndirectCostRecoveryAccount

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

the class SubAccountGlobal method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.krad.bo.GlobalBusinessObject#generateGlobalChangesToPersist()
 */
@Override
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    List<PersistableBusinessObject> changesToPersist = new ArrayList<PersistableBusinessObject>();
    this.refreshReferenceObject(KFSPropertyConstants.A21_SUB_ACCOUNT);
    for (SubAccountGlobalDetail subAccountGlobalDetail : subAccountGlobalDetails) {
        subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
        SubAccount subAccount = subAccountGlobalDetail.getSubAccount();
        if (inactivate) {
            subAccount.setActive(false);
        }
        if (StringUtils.isNotBlank(subAccountName)) {
            subAccount.setSubAccountName(subAccountName);
        }
        if (a21SubAccount.offCampusCode) {
            subAccount.getA21SubAccount().setOffCampusCode(true);
        }
        if (StringUtils.isNotBlank(financialReportChartCode)) {
            subAccount.setFinancialReportChartCode(financialReportChartCode);
        }
        if (StringUtils.isNotBlank(finReportOrganizationCode)) {
            subAccount.setFinReportOrganizationCode(finReportOrganizationCode);
        }
        if (StringUtils.isNotBlank(financialReportingCode)) {
            subAccount.setFinancialReportingCode(financialReportingCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.indirectCostRecoveryTypeCode)) {
            subAccount.getA21SubAccount().setIndirectCostRecoveryTypeCode(a21SubAccount.indirectCostRecoveryTypeCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.financialIcrSeriesIdentifier)) {
            subAccount.getA21SubAccount().setFinancialIcrSeriesIdentifier(a21SubAccount.financialIcrSeriesIdentifier);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareChartOfAccountCode)) {
            subAccount.getA21SubAccount().setCostShareChartOfAccountCode(a21SubAccount.costShareChartOfAccountCode);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareSourceAccountNumber)) {
            subAccount.getA21SubAccount().setCostShareSourceAccountNumber(a21SubAccount.costShareSourceAccountNumber);
        }
        if (StringUtils.isNotBlank(a21SubAccount.costShareSourceSubAccountNumber)) {
            subAccount.getA21SubAccount().setCostShareSourceSubAccountNumber(a21SubAccount.costShareSourceSubAccountNumber);
        }
        List<IndirectCostRecoveryAccount> icrAccounts = new ArrayList<IndirectCostRecoveryAccount>();
        for (IndirectCostRecoveryAccount icrAccount : subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts()) {
            icrAccounts.add(icrAccount);
        }
        updateIcrAccounts(subAccountGlobalDetail, icrAccounts);
        changesToPersist.add(subAccount);
    }
    return changesToPersist;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount)

Example 15 with IndirectCostRecoveryAccount

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

the class SubAccountGlobal method updateGlobalDetailICRAccountCollection.

@Override
public void updateGlobalDetailICRAccountCollection(GlobalBusinessObjectDetailBase globalDetail, List<IndirectCostRecoveryAccount> updatedIcrAccounts) {
    SubAccountGlobalDetail subAccountGlobalDetail = (SubAccountGlobalDetail) globalDetail;
    List<A21IndirectCostRecoveryAccount> updatedA21IcrAccounts = new ArrayList<A21IndirectCostRecoveryAccount>();
    for (IndirectCostRecoveryAccount icrAccount : updatedIcrAccounts) {
        updatedA21IcrAccounts.add(A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount));
    }
    subAccountGlobalDetail.getSubAccount().getA21SubAccount().setA21IndirectCostRecoveryAccounts(updatedA21IcrAccounts);
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList)

Aggregations

IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)20 ArrayList (java.util.ArrayList)11 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)8 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)7 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)6 Test (org.junit.Test)6 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)5 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)3 SubAccountGlobal (edu.cornell.kfs.coa.businessobject.SubAccountGlobal)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Account (org.kuali.kfs.coa.businessobject.Account)3 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)2 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)2 GlobalBusinessObjectDetailBase (org.kuali.kfs.krad.bo.GlobalBusinessObjectDetailBase)2 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)1 GlobalObjectWithIndirectCostRecoveryAccountsService (edu.cornell.kfs.coa.service.GlobalObjectWithIndirectCostRecoveryAccountsService)1 BigDecimal (java.math.BigDecimal)1 MaintenanceDocumentRestrictions (org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions)1 BusinessObjectAuthorizationService (org.kuali.kfs.kns.service.BusinessObjectAuthorizationService)1