Search in sources :

Example 6 with SubFundGroup

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);
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) SubFundGroupService(org.kuali.kfs.coa.service.SubFundGroupService) Date(java.sql.Date)

Aggregations

SubFundGroup (org.kuali.kfs.coa.businessobject.SubFundGroup)6 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)3 Account (org.kuali.kfs.coa.businessobject.Account)2 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 SubFundGroupService (org.kuali.kfs.coa.service.SubFundGroupService)1 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ContractsAndGrantsBillingAwardAccount (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount)1 CustomerInvoiceDetail (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail)1