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;
}
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;
}
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);
}
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()));
}
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()));
}
Aggregations