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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations