Search in sources :

Example 1 with IndirectCostRecoveryAccount

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

the class CUAccountMaintainableImpl method getSections.

/**
 * Overridden to force the old maintenance object to include the relevant ICR account sections
 * if the new object has them. This is necessary to work around a section size mismatch issue
 * on certain ACCT maintenance documents.
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument, Maintainable)
 */
@SuppressWarnings("rawtypes")
@Override
public List getSections(org.kuali.kfs.kns.document.MaintenanceDocument document, Maintainable oldMaintainable) {
    // The special handling only applies to the old maintainable.
    if (this == document.getOldMaintainableObject()) {
        Account oldAccount = (Account) getDataObject();
        Account newAccount = (Account) document.getNewMaintainableObject().getDataObject();
        if (oldAccount.getIndirectCostRecoveryAccounts().size() < newAccount.getIndirectCostRecoveryAccounts().size()) {
            // If necessary, add ICR accounts on the old account to match the quantity on the new account.
            List sections;
            List<IndirectCostRecoveryAccount> oldIcrAccounts = oldAccount.getIndirectCostRecoveryAccounts();
            oldAccount.setIndirectCostRecoveryAccounts(new ArrayList<IndirectCostRecoveryAccount>());
            for (IndirectCostRecoveryAccount oldIcrAccount : oldIcrAccounts) {
                oldAccount.getIndirectCostRecoveryAccounts().add((IndirectCostRecoveryAccount) ObjectUtils.deepCopy(oldIcrAccount));
            }
            for (int i = newAccount.getIndirectCostRecoveryAccounts().size() - oldAccount.getIndirectCostRecoveryAccounts().size() - 1; i >= 0; i--) {
                oldAccount.getIndirectCostRecoveryAccounts().add(new IndirectCostRecoveryAccount());
            }
            // Generate the sections using the temporarily-overridden list.
            sections = super.getSections(document, oldMaintainable);
            oldAccount.setIndirectCostRecoveryAccounts(oldIcrAccounts);
            return sections;
        }
    }
    return super.getSections(document, oldMaintainable);
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with IndirectCostRecoveryAccount

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

the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.

// KFSUPGRADE-765 :  Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
    String maintAction = super.getMaintenanceAction();
    boolean retval = false;
    if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
            // We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
            // "new" subAccount for data comparisons
            A21SubAccount newSubAccount = subAccount.getA21SubAccount();
            // "existing" data that would have pre-populated
            Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
            if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
                List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
                List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
                if (CollectionUtils.isEmpty(subAcctIcr)) {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = false;
                    } else {
                        retval = true;
                    }
                } else {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = true;
                    } else {
                        /*
                        	 * the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
                        	 */
                        int activeAcctIcrCount = 0;
                        for (IndirectCostRecoveryAccount acct : acctIcr) {
                            if (acct.isActive()) {
                                activeAcctIcrCount++;
                            }
                        }
                        if (subAcctIcr.size() == activeAcctIcrCount) {
                            retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
                        } else {
                            retval = true;
                        }
                    }
                }
            }
        }
    } else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        // "new" subAccount for data comparisons
        A21SubAccount newSubAccount = subAccount.getA21SubAccount();
        if (ObjectUtils.isNotNull(newSubAccount)) {
            try {
                MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
                A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
                retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
            } catch (Exception e) {
                LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
            }
        }
    }
    return retval;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 3 with IndirectCostRecoveryAccount

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillNotBe100PercentAfterUpdateTwoSameAccounts_Pass.

@Test
public void testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillNotBe100PercentAfterUpdateTwoSameAccounts_Pass() {
    LOG.debug("enter testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdateTwoSameAccounts_Pass");
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_1111111_2222222_98_2_ACTIVE_3333333_100_INACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_3333333_100_ACTIVE_1111111_98_INACTIVE_98_INACTIVE.getAccountGlobalDetail();
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = accountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    List<IndirectCostRecoveryAccount> existing = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccounts(existing);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existing, accountGlobalDetail, accountGlobal);
    assertTrue("Updated Account Global ICR account distribution should have been 100%", result);
}
Also used : IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Example 4 with IndirectCostRecoveryAccount

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdateTwoSameAccounts_Pass.

@Test
public void testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdateTwoSameAccounts_Pass() {
    LOG.debug("enter testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdateTwoSameAccounts_Pass");
    SubAccountGlobal subAccountGlobal = (SubAccountGlobal) SubAccountGlobalFixture.SUB_ACCT_GLOBAL_1111111_2222222_3333333_98_2_ACTIVE_100_INACTIVE.getSubAccountGlobal();
    SubAccountGlobalDetail subAccountGlobalDetail = SubAccountGlobalDetailFixture.SUB_ACCOUNT_GLOBAL_DETAIL_1111111_98_INACTIVE_98_INACTIVE_3333333_100_PERCENT_ACTIVE.getSubAccountGlobalDetail();
    List<IndirectCostRecoveryAccount> existingIcrAccountsOnDetail = new ArrayList<IndirectCostRecoveryAccount>();
    existingIcrAccountsOnDetail.addAll(subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts());
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = subAccountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    logDetailsForIcrAccounts(existingIcrAccountsOnDetail);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existingIcrAccountsOnDetail, subAccountGlobalDetail, subAccountGlobal);
    assertTrue("Updated Sub Account Global ICR account distribution should have been 100%", result);
}
Also used : SubAccountGlobal(edu.cornell.kfs.coa.businessobject.SubAccountGlobal) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with IndirectCostRecoveryAccount

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail.

@Test
public void testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail() {
    LOG.info("enter testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail");
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_1111111_98_ACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_3333333_100_ACTIVE_1111111_98_INACTIVE_2222222_2_INACTIVE.getAccountGlobalDetail();
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = accountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    List<IndirectCostRecoveryAccount> existing = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccounts(existing);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existing, accountGlobalDetail, accountGlobal);
    assertFalse("Updated Account Global ICR account distribution should NOT have been 100%", result);
}
Also used : IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

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