use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkContractsAndGrants.
/**
* This method checks to see if any Contracts and Grants business rules were violated
*
* @return false on rules violation
*/
protected boolean checkContractsAndGrants() {
LOG.info("checkContractsAndGrants called");
boolean success = true;
// Certain C&G fields are required if the Account belongs to the CG Fund Group
success &= checkCgRequiredFields(newAccountGlobal);
// Income Stream account is required based the fund/subfund group set up in income stream parameters
success &= checkCgIncomeStreamRequired(newAccountGlobal);
// check if the new account has a valid responsibility id
if (ObjectUtils.isNotNull(newAccountGlobal.getContractsAndGrantsAccountResponsibilityId())) {
Account tmpAcct = new Account();
tmpAcct.setContractsAndGrantsAccountResponsibilityId(newAccountGlobal.getContractsAndGrantsAccountResponsibilityId());
final boolean hasValidAccountResponsibility = contractsAndGrantsModuleService.hasValidAccountReponsiblityIdIfNotNull(tmpAcct);
if (!hasValidAccountResponsibility) {
success &= hasValidAccountResponsibility;
putFieldError(CUKFSPropertyConstants.CONTRACTS_AND_GRANTS_ACCOUNT_RESPOSIBILITY_ID, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_INVALID_CG_RESPONSIBILITY, new String[] { newAccountGlobal.getContractsAndGrantsAccountResponsibilityId().toString() });
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.Account 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 in relation to the given detail record
*
* @param maintenanceDocument
* @param detail - the account detail we are investigating
* @return false on rules violation
*/
protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument, AccountGlobalDetail detail) {
boolean success = true;
Date newExpDate = newAccountGlobal.getAccountExpirationDate();
Date prevExpDate = null;
// get previous expiration date for possible check later
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)) {
prevExpDate = oldAccountGlobal.getAccountExpirationDate();
}
} catch (WorkflowException ex) {
LOG.warn("Error retrieving maintenance doc for doc #" + maintenanceDocument.getDocumentNumber() + ". This shouldn't happen.", ex);
}
}
// load the object by keys
Account account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Account.class, detail.getPrimaryKeys());
if (ObjectUtils.isNotNull(account)) {
Date oldExpDate = account.getAccountExpirationDate();
// is an edit doc
if (isUpdatedExpirationDateInvalid(account, newAccountGlobal)) {
// we're not interested unless the approver changed the value
if (ObjectUtils.isNull(prevExpDate) || !prevExpDate.equals(newExpDate)) {
if (newAccountGlobal.getClosed() != null && newAccountGlobal.getClosed()) {
/*If the Account is being closed and the date is before today's date, the EXP date can only be today*/
putFieldError(KFSPropertyConstants.ACCOUNT_EXPIRATION_DATE, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
} else {
/*If the Account is not being closed and the date is before today's date, the EXP date can only be today or at a later date*/
putFieldError(KFSPropertyConstants.ACCOUNT_EXPIRATION_DATE, KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
}
success &= false;
}
}
// acct_expiration_dt can not be before acct_effect_dt
Date effectiveDate = null;
if (ObjectUtils.isNotNull(newAccountGlobal.getAccountEffectiveDate())) {
effectiveDate = newAccountGlobal.getAccountEffectiveDate();
} else {
effectiveDate = account.getAccountEffectiveDate();
}
if (ObjectUtils.isNotNull(effectiveDate) && ObjectUtils.isNotNull(newExpDate)) {
if (newExpDate.before(effectiveDate)) {
putFieldError(KFSPropertyConstants.ACCOUNT_EXPIRATION_DATE, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE, new String[] { detail.getAccountNumber() });
success &= false;
}
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class ScrubberValidatorImpl method validateAccount.
/**
* Validates the account of an origin entry
*
* @param originEntry the origin entry to find the account of
* @param workingEntry the copy of the entry to move the account over to if it is valid
* @param universityRunDate the run date of the scrubber process
* @return a Message if the account was invalid, or null if no error was encountered
*/
protected Message validateAccount(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, UniversityDate universityRunDate, AccountingCycleCachingService accountingCycleCachingService) {
LOG.debug("validateAccount() started");
Account originEntryAccount = accountingCycleCachingService.getAccount(originEntry.getChartOfAccountsCode(), originEntry.getAccountNumber());
if (originEntryAccount != null) {
originEntryAccount.setSubFundGroup(accountingCycleCachingService.getSubFundGroup(originEntryAccount.getSubFundGroupCode()));
}
if (originEntryAccount == null) {
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ACCOUNT_NOT_FOUND, originEntry.getChartOfAccountsCode() + "-" + originEntry.getAccountNumber(), Message.TYPE_FATAL);
}
if (parameterService.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, KFSConstants.SystemGroupParameterNames.GL_ANNUAL_CLOSING_DOC_TYPE).equals(originEntry.getFinancialDocumentTypeCode())) {
workingEntry.setAccountNumber(originEntry.getAccountNumber());
return null;
}
if ((originEntryAccount.getAccountExpirationDate() == null) && originEntryAccount.isActive()) {
// account is neither closed nor expired
workingEntry.setAccountNumber(originEntry.getAccountNumber());
return null;
}
Collection<String> continuationAccountBypassOriginationCodes = new ArrayList<String>(parameterService.getParameterValuesAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupRules.CONTINUATION_ACCOUNT_BYPASS_ORIGINATION_CODES));
Collection<String> continuationAccountBypassDocumentTypeCodes = new ArrayList<String>(parameterService.getParameterValuesAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupRules.CONTINUATION_ACCOUNT_BYPASS_DOCUMENT_TYPE_CODES));
// Has an expiration date or is closed
if ((continuationAccountBypassOriginationCodes.contains(originEntry.getFinancialSystemOriginationCode())) && !originEntryAccount.isActive()) {
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ORIGIN_CODE_CANNOT_HAVE_CLOSED_ACCOUNT, originEntryAccount.getChartOfAccountsCode() + "-" + originEntry.getAccountNumber(), Message.TYPE_FATAL);
}
if ((continuationAccountBypassOriginationCodes.contains(originEntry.getFinancialSystemOriginationCode()) || continuationAccountBypassBalanceTypeCodes.contains(originEntry.getFinancialBalanceTypeCode()) || continuationAccountBypassDocumentTypeCodes.contains(originEntry.getFinancialDocumentTypeCode().trim())) && originEntryAccount.isActive()) {
workingEntry.setAccountNumber(originEntry.getAccountNumber());
return null;
}
Calendar today = Calendar.getInstance();
today.setTime(universityRunDate.getUniversityDate());
if (isAccountExpired(originEntryAccount, universityRunDate) || !originEntryAccount.isActive()) {
Message error = continuationAccountLogic(originEntry, workingEntry, universityRunDate, accountingCycleCachingService);
if (error != null) {
return error;
}
}
workingEntry.setAccountNumber(originEntry.getAccountNumber());
return null;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class PurchaseOrderDocument method getAccountsForAwardRouting.
public List<Account> getAccountsForAwardRouting() {
List<Account> accounts = new ArrayList<Account>();
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
for (PurApItem item : (List<PurApItem>) this.getItems()) {
for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
if (isObjectCodeAllowedForAwardRouting(accountingLine, parameterService)) {
if (ObjectUtils.isNull(accountingLine.getAccount())) {
accountingLine.refreshReferenceObject("account");
}
if (accountingLine.getAccount() != null && !accounts.contains(accountingLine.getAccount())) {
accounts.add(accountingLine.getAccount());
}
}
}
}
return accounts;
}
use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.
the class CuLaborBenefitsCalculationServiceImpl method getBenefitRateCategoryCode.
@Override
public String getBenefitRateCategoryCode(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
this.setCostSharingSourceAccountNumber(null);
this.setCostSharingSourceAccountChartOfAccountsCode(null);
this.setCostSharingSourceSubAccountNumber(null);
// make sure the sub accout number is filled in
if (subAccountNumber != null) {
LOG.info("Sub Account Number was filled in. Checking to see if it is a Cost Sharing Sub Account.");
// make sure the system parameter exists
if (SpringContext.getBean(ParameterService.class).parameterExists(KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class, "USE_COST_SHARE_SOURCE_ACCOUNT_BENEFIT_RATE_IND")) {
// parameter exists, determine the value of the parameter
String sysParam2 = SpringContext.getBean(ParameterService.class).getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class, "USE_COST_SHARE_SOURCE_ACCOUNT_BENEFIT_RATE_IND");
LOG.debug("sysParam2: " + sysParam2);
// if sysParam2 == Y then check to see if it's a cost sharing sub account
if (sysParam2.equalsIgnoreCase("Y")) {
// lookup the A21SubAccount to get the cost sharing source account
Map<String, Object> subFieldValues = new HashMap<String, Object>();
subFieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode);
subFieldValues.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, subAccountNumber);
subFieldValues.put(KFSPropertyConstants.SUB_ACCOUNT_TYPE_CODE, "CS");
subFieldValues.put(KFSPropertyConstants.ACCOUNT_NUMBER, accountNumber);
LOG.info("Looking for a cost sharing sub account for sub account number " + subAccountNumber);
if (ObjectUtils.isNull(businessObjectService)) {
this.businessObjectService = SpringContext.getBean(BusinessObjectService.class);
}
// perform the lookup
List<A21SubAccount> subAccountList = (List<A21SubAccount>) businessObjectService.findMatching(A21SubAccount.class, subFieldValues);
// check to see if the lookup returns an empty list
if (subAccountList.size() > 0) {
LOG.info("Found A21 Sub Account. Retrieving source account number for cost sharing.");
accountNumber = subAccountList.get(0).getCostShareSourceAccountNumber();
LOG.debug("Cost Sharing Source Account Number : " + accountNumber);
this.setCostSharingSourceAccountNumber(accountNumber);
this.setCostSharingSourceAccountChartOfAccountsCode(subAccountList.get(0).getCostShareChartOfAccountCode());
this.setCostSharingSourceSubAccountNumber(subAccountList.get(0).getCostShareSourceSubAccountNumber());
} else {
LOG.info(subAccountNumber + " is not a cost sharing account. Using the Labor Benefit Rate Category from the account number.");
}
} else {
LOG.info("Using the Grant Account to determine the labor benefit rate category code.");
}
}
}
LOG.info("Looking up Account {" + chartOfAccountsCode + "," + accountNumber + "}");
// lookup the account from the db based off the account code and the account number
Account account = this.getAccountService().getByPrimaryId(chartOfAccountsCode, accountNumber);
String laborBenefitRateCategoryCode = null;
if (account == null) {
LOG.info("The Account {" + chartOfAccountsCode + "," + accountNumber + "} could not be found.");
} else {
laborBenefitRateCategoryCode = account.getLaborBenefitRateCategoryCode();
}
// make sure the laborBenefitRateCategoryCode is not null or blank
if (StringUtils.isBlank(laborBenefitRateCategoryCode)) {
LOG.info("The Account did not have a Labor Benefit Rate Category Code. Will use the system parameter default.");
// The system parameter does not exist. Using a blank Labor Benefit Rate Category Code
laborBenefitRateCategoryCode = StringUtils.defaultString(SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, LaborConstants.BenefitCalculation.DEFAULT_BENEFIT_RATE_CATEGORY_CODE_PARAMETER));
} else {
LOG.debug("Labor Benefit Rate Category Code for Account " + accountNumber + " is " + laborBenefitRateCategoryCode);
}
return laborBenefitRateCategoryCode;
}
Aggregations