use of org.kuali.kfs.coa.businessobject.SubFundGroup in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method isUpdatedExpirationDateInvalid.
/**
* This method checks to see if the updated expiration is not a valid one Only gets checked for specific {@link SubFundGroup}s
*
* @param oldAccount
* @param newAccountGlobal
* @return true if date has changed and is invalid
*/
protected boolean isUpdatedExpirationDateInvalid(Account oldAccount, AccountGlobal newAccountGlobal) {
Date oldExpDate = oldAccount.getAccountExpirationDate();
Date newExpDate = newAccountGlobal.getAccountExpirationDate();
// When updating an account expiration date, the date must be today or later
boolean expDateHasChanged = false;
// if the old version of the account had no expiration date, and the new one has a date
if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) {
expDateHasChanged = true;
} else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) {
// if there was an old and a new expDate, but they're different
if (!oldExpDate.equals(newExpDate)) {
expDateHasChanged = true;
}
}
// if the expiration date hasn't changed, we're not interested
if (!expDateHasChanged) {
return false;
}
// if a subFundGroup isn't present, we cannot continue the testing
SubFundGroup subFundGroup = newAccountGlobal.getSubFundGroup();
if (ObjectUtils.isNull(subFundGroup)) {
return false;
}
// if the account is part of the CG fund group, then this rule does not apply, so we're done
if (SpringContext.getBean(SubFundGroupService.class).isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) {
return false;
}
// at this point, we know its not a CG fund group, so we must apply the rule
// KFSUPGRADE-925
Collection<String> fundGroups = SpringContext.getBean(ParameterService.class).getParameterValuesAsString(Account.class, COAParameterConstants.EXPIRATION_DATE_BACKDATING_FUND_GROUPS);
if (fundGroups != null && !ObjectUtils.isNull(newAccountGlobal.getSubFundGroup()) && fundGroups.contains(newAccountGlobal.getSubFundGroup().getFundGroupCode())) {
return false;
}
// expirationDate must be today or later than today (cannot be before today)
return newExpDate.before(today);
}
Aggregations