Search in sources :

Example 1 with AccountReversionGlobalAccount

use of edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalMaintainableImpl method generateMaintenanceLocks.

/**
 * This implementation locks all account reversions that would be accessed by this global account reversion. It does
 * not lock any AccountReversionDetail objects, as we expect that those will be inaccessible
 *
 * @see org.kuali.kfs.kns.maintenance.KualiGlobalMaintainableImpl#generateMaintenaceLocks()
 */
@Override
public List<MaintenanceLock> generateMaintenanceLocks() {
    List<MaintenanceLock> locks = new ArrayList<MaintenanceLock>();
    AccountReversionGlobal globalAcctRev = (AccountReversionGlobal) this.getBusinessObject();
    if (globalAcctRev.getUniversityFiscalYear() != null && globalAcctRev.getAccountReversionGlobalAccounts() != null && globalAcctRev.getAccountReversionGlobalAccounts().size() > 0) {
        // only generate locks if we're going to have primary keys
        for (AccountReversionGlobalAccount acctRevAcct : globalAcctRev.getAccountReversionGlobalAccounts()) {
            MaintenanceLock maintenanceLock = new MaintenanceLock();
            maintenanceLock.setDocumentNumber(globalAcctRev.getDocumentNumber());
            StringBuffer lockRep = new StringBuffer();
            lockRep.append(AccountReversion.class.getName());
            lockRep.append(KFSConstants.Maintenance.AFTER_CLASS_DELIM);
            lockRep.append("chartOfAccountsCode");
            lockRep.append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
            lockRep.append(acctRevAcct.getChartOfAccountsCode());
            lockRep.append(KFSConstants.Maintenance.AFTER_VALUE_DELIM);
            lockRep.append("universityFiscalYear");
            lockRep.append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
            lockRep.append(globalAcctRev.getUniversityFiscalYear().toString());
            lockRep.append(KFSConstants.Maintenance.AFTER_VALUE_DELIM);
            lockRep.append("accountNumber");
            lockRep.append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
            lockRep.append(acctRevAcct.getAccountNumber());
            lockRep.append(KFSConstants.Maintenance.AFTER_VALUE_DELIM);
            maintenanceLock.setLockingRepresentation(lockRep.toString());
            locks.add(maintenanceLock);
        }
    }
    return locks;
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) AccountReversionGlobal(edu.cornell.kfs.coa.businessobject.AccountReversionGlobal) ArrayList(java.util.ArrayList) MaintenanceLock(org.kuali.kfs.krad.maintenance.MaintenanceLock) AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Example 2 with AccountReversionGlobalAccount

use of edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalRule method checkAccountIsNotAmongAcctRevAccounts.

/**
 * This method checks if a newly added account is already among the accounts already listed. WARNING: only use on add
 * line rules; there's no good way to use this method when testing the entire document.
 *
 * @param globalAcctRev the global Account Reversion to check
 * @param acctRevOrg the newly adding account reversion change account
 * @return true if account should be added as it is not currently in the collection, false if otherwise
 */
public boolean checkAccountIsNotAmongAcctRevAccounts(AccountReversionGlobal globalAcctRev, AccountReversionGlobalAccount acctRevAcct) {
    boolean success = true;
    Iterator<AccountReversionGlobalAccount> iter = globalAcctRev.getAccountReversionGlobalAccounts().iterator();
    while (iter.hasNext() && success) {
        AccountReversionGlobalAccount currAcct = iter.next();
        if (areContainingSameAccounts(currAcct, acctRevAcct)) {
            success = false;
            GlobalVariables.getMessageMap().putError(CUKFSPropertyConstants.ACCT_REVERSION_ACCT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_DUPLICATE_ACCOUNTS, new String[] { acctRevAcct.getChartOfAccountsCode(), acctRevAcct.getAccountNumber() });
        }
    }
    return success;
}
Also used : AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Example 3 with AccountReversionGlobalAccount

use of edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalRule method checkDetailObjectCodeValidity.

/**
 * For each account, tests if the object code in the detail exists in the system and is active
 *
 * @param globalAcctRev the global account reversion to check
 * @param detail the AccountReversionGlobalDetail to check
 * @return true if it is valid, false if otherwise
 */
public boolean checkDetailObjectCodeValidity(AccountReversionGlobal globalAcctRev, AccountReversionGlobalDetail detail) {
    boolean success = true;
    for (AccountReversionGlobalAccount acct : globalAcctRev.getAccountReversionGlobalAccounts()) {
        if (!validObjectCode(globalAcctRev.getUniversityFiscalYear(), acct.getChartOfAccountsCode(), detail.getAccountReversionObjectCode())) {
            success = false;
            GlobalVariables.getMessageMap().putError("accountReversionObjectCode", CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_OBJECT_CODE_INVALID, new String[] { globalAcctRev.getUniversityFiscalYear().toString(), acct.getChartOfAccountsCode(), detail.getAccountReversionObjectCode(), acct.getChartOfAccountsCode(), acct.getAccountNumber() });
        }
    }
    return success;
}
Also used : AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Example 4 with AccountReversionGlobalAccount

use of edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalRule method checkAllAccountReversionsExistOrAllFieldsAreDefined.

/**
 * Checks that either every account reversion on the document references an existing account reversion object,
 * or that all fields have been filled in so that new account reversions can be saved properly.
 * Will skip validation if a fiscal year has not been specified on the document.
 *
 * @param globalAcctRev global Account Reversion to check
 * @return true if all referenced account reversions already exist or all reversion and detail fields are filled in, false otherwise.
 */
public boolean checkAllAccountReversionsExistOrAllFieldsAreDefined(AccountReversionGlobal globalAcctRev) {
    boolean success = true;
    if (globalAcctRev.getUniversityFiscalYear() != null) {
        boolean allAccountReversionsExist = true;
        List<AccountReversionGlobalAccount> globalAccounts = globalAcctRev.getAccountReversionGlobalAccounts();
        for (int i = 0; allAccountReversionsExist && i < globalAccounts.size(); i++) {
            allAccountReversionsExist &= ObjectUtils.isNotNull(accountReversionService.getByPrimaryId(globalAcctRev.getUniversityFiscalYear(), globalAccounts.get(i).getChartOfAccountsCode(), globalAccounts.get(i).getAccountNumber()));
        }
        if (!allAccountReversionsExist) {
            // If new account reversions were specified, make sure all reversion fields are filled. (We know fiscal year is defined at this point.)
            boolean allFieldsFilled = StringUtils.isNotBlank(globalAcctRev.getBudgetReversionChartOfAccountsCode()) && StringUtils.isNotBlank(globalAcctRev.getBudgetReversionAccountNumber()) && globalAcctRev.getCarryForwardByObjectCodeIndicator() != null && StringUtils.isNotBlank(globalAcctRev.getCashReversionFinancialChartOfAccountsCode()) && StringUtils.isNotBlank(globalAcctRev.getCashReversionAccountNumber()) && globalAcctRev.getReversionActiveIndicator() != null;
            if (!allFieldsFilled) {
                GlobalVariables.getMessageMap().putError(GLOBAL_ACCOUNT_FIELDS_SECTION, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_MISSING_FIELDS_FOR_NEW_REVERSION);
                success = false;
            }
            // Also check that reversion details are all filled. (Reversion category code should already be set up by the document initialization.)
            for (AccountReversionGlobalDetail globalDetail : globalAcctRev.getAccountReversionGlobalDetails()) {
                allFieldsFilled &= StringUtils.isNotBlank(globalDetail.getAccountReversionCategoryCode()) && StringUtils.isNotBlank(globalDetail.getAccountReversionCode());
            }
            if (!allFieldsFilled) {
                GlobalVariables.getMessageMap().putError(GLOBAL_DETAIL_FIELDS_SECTION, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_MISSING_FIELDS_FOR_NEW_REVERSION_DETAIL);
                success = false;
            }
        }
    }
    return success;
}
Also used : AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Example 5 with AccountReversionGlobalAccount

use of edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalRule method processCustomAddCollectionLineBusinessRules.

/**
 * This performs rules checks whenever a new {@link AccountReversionGlobalDetail} or {@link AccountReversionGlobalAccount} is added
 * <p>
 * This includes:
 * <ul>
 * <li>{@link AccountReversionGlobalRule#checkDetailObjectCodeValidity(AccountReversionGlobal, AccountReversionGlobalDetail)}</li>
 * <li>{@link AccountReversionGlobalRule#checkDetailObjectReversionCodeValidity(AccountReversionGlobalDetail)}</li>
 * <li>ensure that the chart of accounts code and account number for {@link AccountReversionGlobalAccount} are not empty values</li>
 * <li>{@link AccountReversionGlobalRule#checkAllObjectCodesForValidity(AccountReversionGlobal, AccountReversionGlobalAccount)}</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountChartValidity(AccountReversionGlobalAccount)</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountValidity(AccountReversionGlobalAccount)</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountIsNotAmongAcctRevAccounts(AccountReversionGlobal, AccountReversionGlobalAccount)</li>
 * </ul>
 * @see org.kuali.kfs.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomAddCollectionLineBusinessRules(org.kuali.kfs.kns.document.MaintenanceDocument,
 *      java.lang.String, org.kuali.kfs.kns.bo.PersistableBusinessObject)
 */
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
    boolean success = true;
    AccountReversionGlobal globalAcctRev = (AccountReversionGlobal) ((AccountReversionGlobalMaintainableImpl) document.getNewMaintainableObject()).getBusinessObject();
    if (line instanceof AccountReversionGlobalDetail) {
        AccountReversionGlobalDetail detail = (AccountReversionGlobalDetail) line;
        success &= checkDetailObjectCodeValidity(globalAcctRev, detail);
        success &= checkDetailObjectReversionCodeValidity(detail);
    } else if (line instanceof AccountReversionGlobalAccount) {
        AccountReversionGlobalAccount acct = (AccountReversionGlobalAccount) line;
        if (!checkEmptyValue(acct.getChartOfAccountsCode()) || !checkEmptyValue(acct.getAccountNumber())) {
            // Skip Most validation if chart or account are empty. The default required-field checking will populate the error map accordingly.
            success = false;
        }
        if (success) {
            success &= checkAllObjectCodesForValidity(globalAcctRev, acct);
            success &= checkAccountChartValidity(acct);
            success &= checkAccountValidity(acct);
            success &= checkAccountIsNotAmongAcctRevAccounts(globalAcctRev, acct);
        }
    }
    return success;
}
Also used : AccountReversionGlobal(edu.cornell.kfs.coa.businessobject.AccountReversionGlobal) AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Aggregations

AccountReversionGlobalAccount (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)6 AccountReversionGlobal (edu.cornell.kfs.coa.businessobject.AccountReversionGlobal)2 AccountReversionGlobalDetail (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail)2 AccountReversion (edu.cornell.kfs.coa.businessobject.AccountReversion)1 ArrayList (java.util.ArrayList)1 MaintenanceLock (org.kuali.kfs.krad.maintenance.MaintenanceLock)1