use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class FinancialSystemSearchableAttribute method getSearchingRows.
@Override
protected List<Row> getSearchingRows(String documentTypeName) {
if (LOG.isDebugEnabled()) {
LOG.debug("getSearchingRows( " + documentTypeName + " )");
if (LOG.isTraceEnabled()) {
LOG.trace("Stack Trace at point of call", new Throwable());
}
}
DataDictionaryService ddService = SpringContext.getBean(DataDictionaryService.class);
List<Row> docSearchRows = super.getSearchingRows(documentTypeName);
// add account number search field when selected document type is COA
if (StringUtils.isNotEmpty(documentTypeName)) {
if (CUKFSConstants.COA_DOCUMENT_TYPE.equalsIgnoreCase(documentTypeName)) {
Field accountField = FieldUtils.getPropertyField(Account.class, KFSPropertyConstants.ACCOUNT_NUMBER, true);
accountField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
accountField.setColumnVisible(true);
docSearchRows.add(new Row(Collections.singletonList(accountField)));
}
}
DocumentEntry entry = ddService.getDataDictionary().getDocumentEntry(documentTypeName);
if (entry != null) {
Class<? extends Document> docClass = entry.getDocumentClass();
if (AccountingDocument.class.isAssignableFrom(docClass)) {
Map<String, AccountingLineGroupDefinition> alGroups = ((FinancialSystemTransactionalDocumentEntry) entry).getAccountingLineGroups();
Class alClass = SourceAccountingLine.class;
if (ObjectUtils.isNotNull(alGroups)) {
if (alGroups.containsKey("source")) {
alClass = alGroups.get("source").getAccountingLineClass();
}
}
BusinessObject alBusinessObject = null;
try {
alBusinessObject = (BusinessObject) alClass.newInstance();
} catch (Exception cnfe) {
throw new RuntimeException("Unable to instantiate accounting line class: " + alClass, cnfe);
}
Field chartField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, true);
chartField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
chartField.setColumnVisible(true);
LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartField, Collections.singletonList(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE));
docSearchRows.add(new Row(Collections.singletonList(chartField)));
Field orgField = FieldUtils.getPropertyField(Organization.class, KFSPropertyConstants.ORGANIZATION_CODE, true);
orgField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
orgField.setColumnVisible(true);
LookupUtils.setFieldQuickfinder(new Account(), KFSPropertyConstants.ORGANIZATION_CODE, orgField, Collections.singletonList(KFSPropertyConstants.ORGANIZATION_CODE));
docSearchRows.add(new Row(Collections.singletonList(orgField)));
Field accountField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.ACCOUNT_NUMBER, true);
accountField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
accountField.setColumnVisible(true);
LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.ACCOUNT_NUMBER, accountField, Collections.singletonList(KFSPropertyConstants.ACCOUNT_NUMBER));
docSearchRows.add(new Row(Collections.singletonList(accountField)));
}
boolean displayedLedgerPostingDoc = false;
if (LaborLedgerPostingDocumentForSearching.class.isAssignableFrom(docClass)) {
Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
docSearchRows.add(new Row(Collections.singletonList(searchField)));
displayedLedgerPostingDoc = true;
}
if (GeneralLedgerPostingDocument.class.isAssignableFrom(docClass) && !displayedLedgerPostingDoc) {
Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
docSearchRows.add(new Row(Collections.singletonList(searchField)));
}
if (AmountTotaling.class.isAssignableFrom(docClass)) {
Field searchField = FieldUtils.getPropertyField(FinancialSystemDocumentHeader.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, true);
searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_FLOAT);
docSearchRows.add(new Row(Collections.singletonList(searchField)));
}
}
Row resultType = createSearchResultDisplayTypeRow();
docSearchRows.add(resultType);
if (LOG.isDebugEnabled()) {
LOG.debug("Returning Rows: " + docSearchRows);
}
return docSearchRows;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class ScrubberValidatorImpl method continuationAccountLogic.
/**
* Called when the account of the origin entry is expired or closed, this validates the continuation account
*
* @param originEntry the origin entry being scrubbed
* @param workingEntry the scrubbed version of the origin entry
* @param universityRunDate the run date of the scrubber (to test against expiration dates)
* @return a Message if an error was encountered, otherwise null
*/
protected Message continuationAccountLogic(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, UniversityDate universityRunDate, AccountingCycleCachingService accountingCycleCachingService) {
Set<String> checkedAccountNumbers = new HashSet<String>();
Account continuationAccount = null;
Account originEntryAccount = accountingCycleCachingService.getAccount(originEntry.getChartOfAccountsCode(), originEntry.getAccountNumber());
String chartCode = originEntryAccount.getContinuationFinChrtOfAcctCd();
String accountNumber = originEntryAccount.getContinuationAccountNumber();
for (int i = 0; i < 10; ++i) {
if (checkedAccountNumbers.contains(chartCode + accountNumber)) {
// Something is really wrong with the data because this account has already been evaluated.
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CIRCULAR_DEPENDENCY_IN_CONTINUATION_ACCOUNT_LOGIC, Message.TYPE_FATAL);
}
if ((chartCode == null) || (accountNumber == null)) {
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CONTINUATION_ACCOUNT_NOT_FOUND, Message.TYPE_FATAL);
}
// Lookup the account
continuationAccount = accountingCycleCachingService.getAccount(chartCode, accountNumber);
if (null == continuationAccount) {
// account not found
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CONTINUATION_ACCOUNT_NOT_FOUND, Message.TYPE_FATAL);
} else {
// the account exists
continuationAccount.setSubFundGroup(accountingCycleCachingService.getSubFundGroup(continuationAccount.getSubFundGroupCode()));
if (continuationAccount.getAccountExpirationDate() == null) {
// No expiration date
workingEntry.setAccountNumber(accountNumber);
workingEntry.setChartOfAccountsCode(chartCode);
// to set subAcount with dashes
continuationAccountIndicator = true;
// workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
// workingEntry.setTransactionLedgerEntryDescription(kualiConfigurationService.getPropertyValueAsString(KFSKeyConstants.MSG_AUTO_FORWARD) + " " + originEntry.getChartOfAccountsCode() + originEntry.getAccountNumber() + originEntry.getTransactionLedgerEntryDescription());
// TODO:- use messageBuilder and KeyConstant - also, length issue!?!??
workingEntry.setTransactionLedgerEntryDescription("AUTO FR " + originEntry.getChartOfAccountsCode() + originEntry.getAccountNumber() + originEntry.getTransactionLedgerEntryDescription());
// FSKD-310 : need to check the account is closed for building message. if not, it is expired.
if (!originEntryAccount.isActive()) {
return MessageBuilder.buildMessage(KFSKeyConstants.MSG_ACCOUNT_CLOSED_TO, chartCode + accountNumber, Message.TYPE_WARNING);
} else {
return MessageBuilder.buildMessage(KFSKeyConstants.MSG_ACCOUNT_EXPIRED_TO, chartCode + accountNumber, Message.TYPE_WARNING);
}
} else {
// the account does have an expiration date.
// This is the only case in which we might go
// on for another iteration of the loop.
checkedAccountNumbers.add(chartCode + accountNumber);
// If the account has expired go around for another iteration.
if (isAccountExpired(continuationAccount, universityRunDate)) {
chartCode = continuationAccount.getContinuationFinChrtOfAcctCd();
accountNumber = continuationAccount.getContinuationAccountNumber();
} else {
workingEntry.setAccountNumber(accountNumber);
workingEntry.setChartOfAccountsCode(chartCode);
// to set subAccount with dashes
continuationAccountIndicator = true;
// workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
// workingEntry.setTransactionLedgerEntryDescription(kualiConfigurationService.getPropertyValueAsString(KFSKeyConstants.MSG_AUTO_FORWARD) + originEntry.getChartOfAccountsCode() + originEntry.getAccountNumber() + originEntry.getTransactionLedgerEntryDescription());
// TODO:- use messageBuilder and KeyConstant - also, length issue!?!??
workingEntry.setTransactionLedgerEntryDescription("AUTO FR " + originEntry.getChartOfAccountsCode() + originEntry.getAccountNumber() + originEntry.getTransactionLedgerEntryDescription());
// FSKD-310 : need to check the account is closed for building message. if not, it is expired.
if (!originEntryAccount.isActive()) {
return MessageBuilder.buildMessage(KFSKeyConstants.MSG_ACCOUNT_CLOSED_TO, chartCode + accountNumber, Message.TYPE_WARNING);
} else {
return MessageBuilder.buildMessage(KFSKeyConstants.MSG_ACCOUNT_EXPIRED_TO, chartCode + accountNumber, Message.TYPE_WARNING);
}
}
}
}
}
// We failed to find a valid continuation account.
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CONTINUATION_ACCOUNT_LIMIT_REACHED, Message.TYPE_FATAL);
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkAccountExtensionProgramCd.
private boolean checkAccountExtensionProgramCd(Account account, String subFundGroupCode, String subFundProg) {
boolean success = true;
if (StringUtils.isBlank(subFundGroupCode)) {
if (StringUtils.isNotBlank(subFundProg)) {
SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, account.getSubFundGroupCode(), CUKFSPropertyConstants.PROGRAM_CODE, subFundProg);
if (subFundProgram == null) {
success = false;
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { subFundProg, account.getSubFundGroupCode(), account.getAccountNumber() });
} else {
if (!subFundProgram.isActive()) {
putFieldError(CUKFSPropertyConstants.PROGRAM_CODE, KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, CUKFSPropertyConstants.PROGRAM_CODE));
success = false;
}
}
}
} else {
AccountExtendedAttribute accountExtension = (AccountExtendedAttribute) account.getExtension();
if (StringUtils.isBlank(subFundProg)) {
if (StringUtils.isBlank(accountExtension.getProgramCode())) {
SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, subFundGroupCode, CUKFSPropertyConstants.PROGRAM_CODE, accountExtension.getProgramCode());
if (subFundProgram != null) {
success = false;
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_CANNOT_BE_BLANK_FOR_GROUP_CODE, new String[] { subFundGroupCode, account.getAccountNumber() });
}
} else {
SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, subFundGroupCode, CUKFSPropertyConstants.PROGRAM_CODE, accountExtension.getProgramCode());
if (subFundProgram == null) {
success = false;
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { accountExtension.getProgramCode(), subFundGroupCode, account.getAccountNumber() });
}
}
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkSubFundGroup.
/**
* This method checks to see if any SubFund Group rules were violated Specifically: if SubFundGroup is empty or not "PFCMR" we
* cannot have a campus code or building code if SubFundGroup is "PFCMR" then campus code and building code "must" be entered
* and be valid codes
*
* @param maintenanceDocument
* @return false on rules violation
*/
protected boolean checkSubFundGroup(AccountGlobalDetail detail) {
LOG.info("checkSubFundGroup called");
boolean success = true;
String subFundGroupCode = newAccountGlobal.getSubFundGroupCode();
Account account = detail.getAccount();
String errorPath = KFSPropertyConstants.ACCOUNT_CHANGE_DETAILS;
if (account.getAccountDescription() != null) {
String campusCode = account.getAccountDescription().getCampusCode();
String buildingCode = account.getAccountDescription().getBuildingCode();
// check if sub fund group code is blank
if (StringUtils.isBlank(subFundGroupCode)) {
// check if campus code and building code are NOT blank
if (StringUtils.isNotBlank(campusCode) || StringUtils.isNotBlank(buildingCode)) {
// if sub_fund_grp_cd is blank, campus code should NOT be entered
if (StringUtils.isNotBlank(campusCode)) {
putFieldError(errorPath, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
success &= false;
}
// if sub_fund_grp_cd is blank, then bldg_cd should NOT be entered
if (StringUtils.isNotBlank(buildingCode)) {
putFieldError(errorPath, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
success &= false;
}
} else {
// if all sub fund group, campus code, building code are all blank return true
return success;
}
} else if (StringUtils.isNotBlank(subFundGroupCode) && ObjectUtils.isNotNull(account.getSubFundGroup())) {
// Attempt to get the right SubFundGroup code to check the following logic with. If the value isn't available, go
// ahead
// and die, as this indicates a mis-configured application, and important business rules wont be implemented without it.
ParameterEvaluator evaluator = /*REFACTORME*/
SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, ACCT_CAPITAL_SUBFUNDGROUP, subFundGroupCode.trim());
if (evaluator.evaluationSucceeds()) {
// if sub_fund_grp_cd is 'PFCMR' then campus_cd must be entered
if (StringUtils.isBlank(campusCode)) {
putFieldError(errorPath, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
success &= false;
}
// if sub_fund_grp_cd is 'PFCMR' then bldg_cd must be entered
if (StringUtils.isBlank(buildingCode)) {
putFieldError(errorPath, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_BUILDING_CD, subFundGroupCode);
success &= false;
}
} else {
// if sub_fund_grp_cd is NOT 'PFCMR', campus code should NOT be entered
if (StringUtils.isNotBlank(campusCode)) {
putFieldError(KFSPropertyConstants.ACCOUNT_DESCRIPTION + "." + KFSPropertyConstants.CAMPUS_CODE, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
success &= false;
}
// if sub_fund_grp_cd is NOT 'PFCMR' then bldg_cd should NOT be entered
if (StringUtils.isNotBlank(buildingCode)) {
putFieldError(KFSPropertyConstants.ACCOUNT_DESCRIPTION + "." + KFSPropertyConstants.BUILDING_CODE, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
success &= false;
}
}
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method isContinuationAccountExpired.
/**
* This method tests whether the continuation account entered (if any) has expired or not.
*
* @param accountGlobals
* @return true if the continuation account has expired
*/
protected boolean isContinuationAccountExpired(AccountGlobal accountGlobals) {
boolean result = false;
String chartCode = accountGlobals.getContinuationFinChrtOfAcctCd();
String accountNumber = accountGlobals.getContinuationAccountNumber();
// cant continue, so exit
if (StringUtils.isBlank(chartCode) || StringUtils.isBlank(accountNumber)) {
return result;
}
// attempt to retrieve the continuation account from the DB
Account continuation = null;
Map<String, String> pkMap = new HashMap<String, String>();
pkMap.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
pkMap.put(KFSPropertyConstants.ACCOUNT_NUMBER, accountNumber);
continuation = super.getBoService().findByPrimaryKey(Account.class, pkMap);
// if the object doesnt exist, then we cant continue, so exit
if (ObjectUtils.isNull(continuation)) {
return result;
}
// at this point, we have a valid continuation account, so we just need to
// know whether its expired or not
result = continuation.isExpired();
return result;
}
Aggregations