use of edu.cornell.kfs.coa.businessobject.SubAccountGlobal in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobalRule method checkCgIcrRules.
/**
* This checks that if the ICR information is entered that it is valid for this fiscal year and that all of its fields are valid
* as well (such as account)
*
* @return true if the ICR information is filled in and it is valid
*/
protected boolean checkCgIcrRules(String subAccountTypeCode, SubAccountGlobalDetail subAccountGlobalDetail) {
SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
A21SubAccountChange a21 = newSubAccountGlobal.getA21SubAccount();
if (ObjectUtils.isNull(a21)) {
return true;
}
boolean success = true;
// existence check for Financial Series ID
if (StringUtils.isNotEmpty(a21.getFinancialIcrSeriesIdentifier())) {
String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
String icrSeriesId = a21.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(A21SubAccount.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
success = false;
} else {
for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
success = false;
break;
}
}
}
}
// existence check for ICR Account
for (IndirectCostRecoveryAccountChange account : newSubAccountGlobal.getActiveIndirectCostRecoveryAccounts()) {
if (StringUtils.isNotBlank(account.getIndirectCostRecoveryAccountNumber()) && StringUtils.isNotBlank(account.getIndirectCostRecoveryFinCoaCode())) {
if (ObjectUtils.isNull(account.getIndirectCostRecoveryAccount())) {
putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_EXISTENCE, "ICR Account: " + account.getIndirectCostRecoveryFinCoaCode() + "-" + account.getIndirectCostRecoveryAccountNumber());
success = false;
break;
}
}
}
// The cost sharing fields must be empty if the sub-account type code is for ICR
if (checkCgCostSharingIsEmpty(subAccountGlobalDetail) == false) {
putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_COST_SHARE_SECTION_INVALID, subAccountTypeCode);
success &= false;
}
return success;
}
use of edu.cornell.kfs.coa.businessobject.SubAccountGlobal in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobalRule method checkSubAccountDetails.
/**
* Checks that at least one sub account is entered.
*
* @return true if at least one sub account entered, false otherwise
*/
public boolean checkSubAccountDetails() {
boolean success = true;
SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
List<SubAccountGlobalDetail> details = newSubAccountGlobal.getSubAccountGlobalDetails();
// check if there are any accounts
if (details.size() == 0) {
putFieldError(KFSConstants.MAINTENANCE_ADD_PREFIX + CUKFSPropertyConstants.SUB_ACCOUNT_GLBL_CHANGE_DETAILS + "." + KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_SUS_ACCOUNT_NO_SUB_ACCOUNTS);
success = false;
}
return success;
}
use of edu.cornell.kfs.coa.businessobject.SubAccountGlobal in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobalRule method checkCgRules.
/**
* Checks CG rules.
*
* @param document
* @return true if valid, false otherwise
*/
protected boolean checkCgRules(MaintenanceDocument document) {
boolean success = true;
SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
List<SubAccountGlobalDetail> subAccountGlobalDetails = newSubAccountGlobal.getSubAccountGlobalDetails();
for (SubAccountGlobalDetail subAccountGlobalDetail : subAccountGlobalDetails) {
success &= checkCgRules(newSubAccountGlobal, subAccountGlobalDetail);
}
return success;
}
use of edu.cornell.kfs.coa.businessobject.SubAccountGlobal in project cu-kfs by CU-CommunityApps.
the class GlobalIndirectCostRecoveryAccountsRuleTest method testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail.
@Test
public void testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail() {
LOG.debug("enter testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail");
SubAccountGlobal subAccountGlobal = (SubAccountGlobal) SubAccountGlobalFixture.SUB_ACCT_GLOBAL_1111111_2222222_98_2.getSubAccountGlobal();
SubAccountGlobalDetail subAccountGlobalDetail = SubAccountGlobalDetailFixture.SUB_ACCOUNT_GLOBAL_DETAIL_3333333_100_INACTIVATE.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);
assertFalse("Updated Sub Account Global ICR account distribution should NOT have been 100%", result);
}
Aggregations