use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class GlobalIndirectCostRecoveryAccountsRuleTest method testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass.
@Test
public void testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass() {
LOG.debug("enter testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass");
SubAccountGlobal subAccountGlobal = (SubAccountGlobal) SubAccountGlobalFixture.SUB_ACCT_GLOBAL_3333333_100_ACTIVE_1111111_2222222_98_2_INACTIVE.getSubAccountGlobal();
SubAccountGlobalDetail subAccountGlobalDetail = SubAccountGlobalDetailFixture.SUB_ACCOUNT_GLOBAL_DETAIL_1111111_2222222_98_2.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 AccountGlobalRule method checkICRCollectionExistsWhenUpdatingToCGSubFund.
protected boolean checkICRCollectionExistsWhenUpdatingToCGSubFund(CuAccountGlobal newAccount, String subFundGroupCode) {
boolean success = true;
if (newAccount.getActiveIndirectCostRecoveryAccounts().isEmpty()) {
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_EMPTY_FOR_CG_ACCOUNT, new String[] { subFundGroupCode, accountGlobalDetail.getAccountNumber() });
}
}
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount 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;
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method getActiveUpdatedIcrAccounts.
private List<IndirectCostRecoveryAccount> getActiveUpdatedIcrAccounts(CuAccountGlobal newAccount, AccountGlobalDetail accountGlobalDetail) {
accountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
List<IndirectCostRecoveryAccount> existingICRList = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
List<IndirectCostRecoveryAccount> copyOfExistingICRList = new ArrayList<IndirectCostRecoveryAccount>();
if (existingICRList != null && !existingICRList.isEmpty()) {
for (IndirectCostRecoveryAccount icrAccount : existingICRList) {
copyOfExistingICRList.add(new IndirectCostRecoveryAccount(icrAccount));
}
}
List<IndirectCostRecoveryAccount> updatedICRList = SpringContext.getBean(GlobalObjectWithIndirectCostRecoveryAccountsService.class).buildUpdatedIcrAccounts(newAccount, accountGlobalDetail, copyOfExistingICRList);
List<IndirectCostRecoveryAccount> activeICRList = getActiveICRAccounts(updatedICRList);
return activeICRList;
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class GlobalObjectWithIndirectCostRecoveryAccountsServiceImpl method buildUpdatedIcrAccounts.
public List<IndirectCostRecoveryAccount> buildUpdatedIcrAccounts(GlobalObjectWithIndirectCostRecoveryAccounts globalObjectWithIndirectCostRecoveryAccounts, GlobalBusinessObjectDetailBase globalDetail, List<IndirectCostRecoveryAccount> icrAccounts) {
List<IndirectCostRecoveryAccount> updatedIcrAccounts = new ArrayList<IndirectCostRecoveryAccount>();
Map<Integer, Integer> alreadyUpdatedIndexes = new HashMap<>();
List<IndirectCostRecoveryAccount> addList = new ArrayList<IndirectCostRecoveryAccount>();
List<IndirectCostRecoveryAccountChange> newIndirectCostRecoveryAccounts = globalObjectWithIndirectCostRecoveryAccounts.getIndirectCostRecoveryAccounts();
if (newIndirectCostRecoveryAccounts.size() > 0) {
for (IndirectCostRecoveryAccountChange newICR : newIndirectCostRecoveryAccounts) {
boolean foundMatch = false;
int positionForMatchWithSameActiveIndicator = -1;
int currentPosition = 0;
int maxPosition = icrAccounts.size();
while (noMatchFoundOrSameActiveIndicatorMatchFoundAndStillHaveICRAccountToCheck(currentPosition, maxPosition, foundMatch, positionForMatchWithSameActiveIndicator)) {
if (!alreadyUpdatedIndexes.containsKey(currentPosition)) {
IndirectCostRecoveryAccount existingICR = icrAccounts.get(currentPosition);
if (newICR.matchesICRAccount(existingICR)) {
foundMatch = true;
if (newICR.isActive() == existingICR.isActive()) {
positionForMatchWithSameActiveIndicator = currentPosition;
} else {
existingICR.setActive(newICR.isActive());
alreadyUpdatedIndexes.put(currentPosition, currentPosition);
if (positionForMatchWithSameActiveIndicator != -1) {
positionForMatchWithSameActiveIndicator = -1;
}
}
}
}
currentPosition++;
}
if (foundMatch && positionForMatchWithSameActiveIndicator != -1) {
alreadyUpdatedIndexes.put(positionForMatchWithSameActiveIndicator, positionForMatchWithSameActiveIndicator);
}
if (!foundMatch) {
IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
addList.add(icrAccount);
}
}
updatedIcrAccounts = combineExistingAndNewAccounts(icrAccounts, addList);
} else {
updatedIcrAccounts = icrAccounts;
}
return updatedIcrAccounts;
}
Aggregations