Search in sources :

Example 21 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkExpirationDate.

/**
 * This method checks to see if any expiration date field rules were violated Loops through each detail object and calls
 * {@link AccountGlobalRule#checkExpirationDate(MaintenanceDocument, AccountGlobalDetail)}
 *
 * @param maintenanceDocument
 * @return false on rules violation
 */
protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument) {
    LOG.info("checkExpirationDate called");
    boolean success = true;
    Date newExpDate = newAccountGlobal.getAccountExpirationDate();
    // and the approver hasn't changed the value
    if (maintenanceDocument.isNew() && ObjectUtils.isNotNull(newExpDate)) {
        Date oldExpDate = null;
        if (maintenanceDocument.getDocumentHeader().getWorkflowDocument().isApprovalRequested()) {
            try {
                MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(maintenanceDocument.getDocumentNumber());
                AccountGlobal oldAccountGlobal = (AccountGlobal) oldMaintDoc.getDocumentBusinessObject();
                if (ObjectUtils.isNotNull(oldAccountGlobal)) {
                    oldExpDate = oldAccountGlobal.getAccountExpirationDate();
                }
            } catch (WorkflowException ex) {
                LOG.warn("Error retrieving maintenance doc for doc #" + maintenanceDocument.getDocumentNumber() + ". This shouldn't happen.", ex);
            }
        }
        if (ObjectUtils.isNull(oldExpDate) || !oldExpDate.equals(newExpDate)) {
            // KFSUPGRADE-925 check parameter to see if back date is allowed
            Collection<String> fundGroups = SpringContext.getBean(ParameterService.class).getParameterValuesAsString(Account.class, KFSConstants.ChartApcParms.EXPIRATION_DATE_BACKDATING_FUND_GROUPS);
            if (fundGroups == null || (ObjectUtils.isNotNull(newAccountGlobal.getSubFundGroup()) && !fundGroups.contains(newAccountGlobal.getSubFundGroup().getFundGroupCode()))) {
                if (!newExpDate.after(today) && !newExpDate.equals(today)) {
                    putFieldError("accountExpirationDate", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
                    success &= false;
                }
            }
        }
    }
    // a continuation account is required if the expiration date is completed.
    success &= checkContinuationAccount(maintenanceDocument, newExpDate);
    for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) {
        success &= checkExpirationDate(maintenanceDocument, detail);
    }
    return success;
}
Also used : MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) AccountGlobal(org.kuali.kfs.coa.businessobject.AccountGlobal) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) Date(java.sql.Date)

Example 22 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkAccountDetails.

/**
 * This method loops through the list of {@link AccountGlobalDetail}s and passes them off to checkAccountDetails for further
 * rule analysis One rule it does check is checkOnlyOneChartErrorWrapper
 *
 * @param document
 * @param details
 * @return true if the collection of {@link AccountGlobalDetail}s passes the sub-rules
 */
public boolean checkAccountDetails(MaintenanceDocument document, List<AccountGlobalDetail> details) {
    boolean success = true;
    // check if there are any accounts
    if (details.size() == 0) {
        putFieldError(KFSConstants.MAINTENANCE_ADD_PREFIX + KFSPropertyConstants.ACCOUNT_CHANGE_DETAILS + "." + KFSPropertyConstants.ACCOUNT_NUMBER, KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCOUNT_NO_ACCOUNTS);
        success = false;
    } else {
        // check each account
        int index = 0;
        for (AccountGlobalDetail dtl : details) {
            String errorPath = MAINTAINABLE_ERROR_PREFIX + KFSPropertyConstants.ACCOUNT_CHANGE_DETAILS + "[" + index + "]";
            GlobalVariables.getMessageMap().addToErrorPath(errorPath);
            success &= checkAccountDetails(dtl);
            success &= checkAccountExtensions(dtl);
            GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
            index++;
        }
        success &= checkOnlyOneChartErrorWrapper(details);
    }
    return success;
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Example 23 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class GlobalIndirectCostRecoveryAccountsRuleTest method testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass.

@Test
public void testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass() {
    LOG.debug("enter testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Pass");
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_3333333_100_ACTIVE_1111111_2222222_98_2_INACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_1111111_2222222_98_2.getAccountGlobalDetail();
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = accountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    List<IndirectCostRecoveryAccount> existing = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccounts(existing);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existing, accountGlobalDetail, accountGlobal);
    assertTrue("Updated Account Global ICR account distribution should have been 100%", result);
}
Also used : IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Example 24 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class GlobalObjectWithIndirectCostRecoveryAccountsServiceImplTest method testAccountGlobalUpdateIcrAccounts_ReplaceExisting.

@Test
public void testAccountGlobalUpdateIcrAccounts_ReplaceExisting() {
    GlobalObjectWithIndirectCostRecoveryAccounts accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_3333333_100_ACTIVE_1111111_2222222_98_2_INACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_1111111_2222222_98_2.getAccountGlobalDetail();
    assertEquals("The Account Global Detail ICR accounts list should have 2 ICR accounts before update", 2, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts().size());
    globalObjectWithIndirectCostRecoveryAccountsService.updateIcrAccounts(accountGlobal, accountGlobalDetail, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts());
    assertEquals("The Account Global Detail ICR accounts list should have 3 ICR accounts after update", 3, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts().size());
    assertTrue("Updated ICR accounts list should have contained ICR account 1111111 with 98% inactive", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_1111111_98_PERCENT_INACTIVE.getIndirectCostRecoveryAccountChange()));
    assertTrue("Updated ICR accounts list should have contained ICR account 2222222 with 2% inactive", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_2222222_2_PERCENT_INACTIVE.getIndirectCostRecoveryAccountChange()));
    assertTrue("Updated ICR accounts list should have contained ICR account 3333333 with 100% inactive", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_3333333_100_PERCENT_ACTIVE.getIndirectCostRecoveryAccountChange()));
}
Also used : GlobalObjectWithIndirectCostRecoveryAccounts(edu.cornell.kfs.coa.businessobject.GlobalObjectWithIndirectCostRecoveryAccounts) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Example 25 with AccountGlobalDetail

use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.

the class GlobalObjectWithIndirectCostRecoveryAccountsServiceImplTest method testAccountGlobalUpdateIcrAccounts_UpdateExistingWithTwoSameExistingPlusAdd.

@Test
public void testAccountGlobalUpdateIcrAccounts_UpdateExistingWithTwoSameExistingPlusAdd() {
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_1111111_2222222_3333333_98_2_ACTIVE_100_INACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_1111111_98_INACTIVE_98_INACTIVE_3333333_100_PERCENT_ACTIVE.getAccountGlobalDetail();
    assertEquals("The Account Global Detail ICR accounts list should have 3 ICR accounts before update", 3, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts().size());
    globalObjectWithIndirectCostRecoveryAccountsService.updateIcrAccounts(accountGlobal, accountGlobalDetail, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts());
    assertEquals("The Account Global Detail ICR accounts list should have 4 ICR accounts after update", 4, accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts().size());
    assertTrue("Updated ICR accounts list should have contained ICR account 1111111 with 98% inactive", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_1111111_98_PERCENT_INACTIVE.getIndirectCostRecoveryAccountChange()));
    assertTrue("Updated ICR accounts list should have contained ICR account 1111111 with 98% active", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_1111111_98_PERCENT_ACTIVE.getIndirectCostRecoveryAccountChange()));
    assertTrue("Updated ICR accounts list should have contained ICR account 2222222 with 2% active", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_2222222_2_PERCENT_ACTIVE.getIndirectCostRecoveryAccountChange()));
    assertTrue("Updated ICR accounts list should have contained ICR account 3333333 with 100% active", doesListContainIcr(accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts(), IndirectCostRecoveryAccountFixture.ICR_3333333_100_PERCENT_INACTIVE.getIndirectCostRecoveryAccountChange()));
}
Also used : AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Aggregations

AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)25 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)8 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)6 Test (org.junit.Test)5 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)4 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)3 HashMap (java.util.HashMap)3 Date (java.sql.Date)2 ArrayList (java.util.ArrayList)2 Account (org.kuali.kfs.coa.businessobject.Account)2 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 GlobalObjectWithIndirectCostRecoveryAccounts (edu.cornell.kfs.coa.businessobject.GlobalObjectWithIndirectCostRecoveryAccounts)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 AccountDelegate (org.kuali.kfs.coa.businessobject.AccountDelegate)1 AccountDelegateGlobalDetail (org.kuali.kfs.coa.businessobject.AccountDelegateGlobalDetail)1 IndirectCostRecoveryRateDetail (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)1 OrganizationService (org.kuali.kfs.coa.service.OrganizationService)1