use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkICRCollectionDoesNotExistWhenUpdatingToNonCGSubFund.
protected boolean checkICRCollectionDoesNotExistWhenUpdatingToNonCGSubFund(CuAccountGlobal newAccount, String subFundGroupCode) {
boolean success = true;
boolean hasActiveUpdates = !newAccount.getActiveIndirectCostRecoveryAccounts().isEmpty();
if (hasActiveUpdates) {
success = false;
putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_ICR_FIELDS_FILLED_FOR_NON_CG_ACCOUNT, newAccount.getSubFundGroupCode());
} else {
if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && !newAccount.getAccountGlobalDetails().isEmpty()) {
for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
List<IndirectCostRecoveryAccount> activeICRList = getActiveUpdatedIcrAccounts(newAccount, accountGlobalDetail);
if (!activeICRList.isEmpty()) {
success &= false;
putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ICR_NOT_EMPTY_FOR_NON_CG_ACCOUNT, new String[] { subFundGroupCode, accountGlobalDetail.getAccountNumber() });
}
}
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkCloseAccounts.
protected boolean checkCloseAccounts() {
boolean success = true;
LOG.info("checkCloseAccount called");
// check that at least one account is being closed
boolean isBeingClosed = false;
if (ObjectUtils.isNotNull(newAccountGlobal.getAccountGlobalDetails()) && newAccountGlobal.getAccountGlobalDetails().size() > 0) {
for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) {
if (detail.getAccount().isActive() && newAccountGlobal.getClosed() != null && newAccountGlobal.getClosed()) {
isBeingClosed = true;
break;
}
}
}
if (!isBeingClosed) {
return true;
}
if (ObjectUtils.isNotNull(newAccountGlobal.getAccountGlobalDetails()) && newAccountGlobal.getAccountGlobalDetails().size() > 0) {
for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) {
success &= checkCloseAccount(detail);
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG.
private boolean checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG(CuAccountGlobal newAccount) {
boolean result = true;
boolean filledIcrTypeCode = checkEmptyValue(newAccount.getAcctIndirectCostRcvyTypeCd());
boolean filledFinancialIcrSeriesIdentifier = checkEmptyValue(newAccount.getFinancialIcrSeriesIdentifier());
// Validation for financialIcrSeriesIdentifier
if (filledFinancialIcrSeriesIdentifier) {
String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
String icrSeriesId = newAccount.getFinancialIcrSeriesIdentifier();
Map<String, String> pkMap = new HashMap<String, String>();
pkMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
pkMap.put(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrSeriesId);
Collection<IndirectCostRecoveryRateDetail> icrRateDetails = getBoService().findMatching(IndirectCostRecoveryRateDetail.class, pkMap);
if (ObjectUtils.isNull(icrRateDetails) || icrRateDetails.isEmpty()) {
String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(Account.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
result &= false;
} else {
for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
result &= false;
break;
}
}
}
}
if (!filledIcrTypeCode || !filledFinancialIcrSeriesIdentifier) {
if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && newAccount.getAccountGlobalDetails().size() > 0) {
for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
accountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
if (!filledIcrTypeCode) {
result &= checkEmptyBOField(KFSPropertyConstants.ACCT_INDIRECT_COST_RCVY_TYPE_CD, accountGlobalDetail.getAccount().getAcctIndirectCostRcvyTypeCd(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_TYPE_CODE_CANNOT_BE_EMPTY));
}
if (!filledFinancialIcrSeriesIdentifier) {
result &= checkEmptyBOField(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, accountGlobalDetail.getAccount().getFinancialIcrSeriesIdentifier(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_SERIES_IDENTIFIER_CANNOT_BE_EMPTY));
}
}
}
}
return result;
}
use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.
the class CuAccountDelegateGlobal method generateGlobalChangesToPersist.
/**
* @see org.kuali.kfs.krad.document.GlobalBusinessObject#applyGlobalChanges(org.kuali.rice.krad.bo.BusinessObject)
*/
@SuppressWarnings("deprecation")
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
List<AccountDelegate> persistables = new ArrayList();
List<AccountDelegateGlobalDetail> changeDocuments = this.getDelegateGlobals();
List<AccountGlobalDetail> accountDetails = this.getAccountGlobalDetails();
for (AccountDelegateGlobalDetail changeDocument : changeDocuments) {
for (AccountGlobalDetail accountDetail : accountDetails) {
Account account = (Account) boService.findByPrimaryKey(Account.class, accountDetail.getPrimaryKeys());
// the busines rules for this document should have caught this.
if (account == null) {
throw new RuntimeException("Account [" + accountDetail.getChartOfAccountsCode() + "-" + accountDetail.getAccountNumber() + "] was not present in the database. " + "This should never happen under normal circumstances, as an invalid account should have " + "been caught by the Business Rules infrastructure.");
}
// attempt to load the existing Delegate from the DB, if it exists. we do this to avoid
// versionNumber conflicts if we tried to just insert a new record that already existed.
Map pkMap = new HashMap();
// chartOfAccountsCode & accountNumber
pkMap.putAll(accountDetail.getPrimaryKeys());
pkMap.put("financialDocumentTypeCode", changeDocument.getFinancialDocumentTypeCode());
pkMap.put("accountDelegateSystemId", changeDocument.getAccountDelegateUniversalId());
AccountDelegate delegate = (AccountDelegate) boService.findByPrimaryKey(AccountDelegate.class, pkMap);
// so lets populate it with the primary keys
if (delegate == null) {
delegate = new AccountDelegate();
delegate.setChartOfAccountsCode(accountDetail.getChartOfAccountsCode());
delegate.setAccountNumber(accountDetail.getAccountNumber());
delegate.setAccountDelegateSystemId(changeDocument.getAccountDelegateUniversalId());
delegate.setFinancialDocumentTypeCode(changeDocument.getFinancialDocumentTypeCode());
delegate.setActive(true);
} else {
delegate.setActive(true);
}
// APPROVAL FROM AMOUNT
delegate.setFinDocApprovalFromThisAmt(changeDocument.getApprovalFromThisAmount());
// APPROVAL TO AMOUNT
delegate.setFinDocApprovalToThisAmount(changeDocument.getApprovalToThisAmount());
// PRIMARY ROUTING
delegate.setAccountsDelegatePrmrtIndicator(changeDocument.getAccountDelegatePrimaryRoutingIndicator());
// START DATE
if (changeDocument.getAccountDelegateStartDate() != null) {
delegate.setAccountDelegateStartDate(new Date(changeDocument.getAccountDelegateStartDate().getTime()));
}
persistables.add(delegate);
}
}
return new ArrayList<PersistableBusinessObject>(persistables);
}
use of org.kuali.kfs.coa.businessobject.AccountGlobalDetail in project cu-kfs by CU-CommunityApps.
the class CuAccountGlobal method updateAccountValuesOnAccountGlobalDetailWithNewValuesFromAccountGlobalDoc.
private Account updateAccountValuesOnAccountGlobalDetailWithNewValuesFromAccountGlobalDoc(GlobalBusinessObjectDetailBase globalDetail) {
AccountGlobalDetail accountGlobalDetail = (AccountGlobalDetail) globalDetail;
Account account = getBusinessObjectService().findByPrimaryKey(Account.class, accountGlobalDetail.getPrimaryKeys());
if (ObjectUtils.isNotNull(account)) {
updateAccountBasicFields(account);
updateAccountExtendedAttribute(account);
if (ObjectUtils.isNotNull(this.getIndirectCostRecoveryAccounts()) && this.getIndirectCostRecoveryAccounts().size() > 0) {
updateIcrAccounts(globalDetail, account.getIndirectCostRecoveryAccounts());
}
}
return account;
}
Aggregations