Search in sources :

Example 1 with ObjectCode

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

the class ScrubberValidatorImpl method validateObjectType.

/**
 * Assuming that the object code has been validated first, validates the object type of the entry
 *
 * @param originEntry  the origin entry being scrubbed
 * @param workingEntry the scrubbed version of the origin entry
 * @return a Message if an error was encountered, otherwise null
 * @see org.kuali.module.gl.service.ScrubberValidator#validateObjectType(org.kuali.module.gl.bo.OriginEntryFull,
 * org.kuali.module.gl.bo.OriginEntryFull)
 */
protected Message validateObjectType(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateObjectType() started");
    // grab bypass origin codes from parameters
    Set<String> objectTypeBypassOriginationCodes = new HashSet<String>(parameterService.getParameterValuesAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupRules.OBJECT_TYPE_BYPASS_ORIGINATIONS));
    // for incoming transaction based on the object code - want to do this before validation checks
    if ((!objectTypeBypassOriginationCodes.contains(originEntry.getFinancialSystemOriginationCode())) || (!StringUtils.hasText(originEntry.getFinancialObjectTypeCode()))) {
        ObjectCode workingEntryFinancialObject = accountingCycleCachingService.getObjectCode(workingEntry.getUniversityFiscalYear(), workingEntry.getChartOfAccountsCode(), workingEntry.getFinancialObjectCode());
        workingEntry.setFinancialObjectTypeCode(workingEntryFinancialObject.getFinancialObjectTypeCode());
    } else {
        workingEntry.setFinancialObjectTypeCode(originEntry.getFinancialObjectTypeCode());
    }
    ObjectType workingEntryObjectType = accountingCycleCachingService.getObjectType(workingEntry.getFinancialObjectTypeCode());
    if (workingEntryObjectType == null) {
        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_OBJECT_TYPE_NOT_FOUND, originEntry.getFinancialObjectTypeCode(), Message.TYPE_FATAL);
    }
    if (!workingEntryObjectType.isActive()) {
        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_OBJECT_TYPE_NOT_ACTIVE, originEntry.getFinancialObjectTypeCode(), Message.TYPE_FATAL);
    }
    return null;
}
Also used : ObjectType(org.kuali.kfs.coa.businessobject.ObjectType) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode) ScrubberStep(org.kuali.kfs.gl.batch.ScrubberStep) HashSet(java.util.HashSet)

Example 2 with ObjectCode

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

the class ScrubberValidatorImpl method validateObjectCode.

/**
 * Validates the object code of the origin entry
 *
 * @param originEntry  the origin entry being scrubbed
 * @param workingEntry the scrubbed version of the origin entry
 * @return a Message if an error was encountered, otherwise null
 */
protected Message validateObjectCode(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateObjectCode() started");
    if (!StringUtils.hasText(originEntry.getFinancialObjectCode())) {
        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_OBJECT_CODE_EMPTY, Message.TYPE_FATAL);
    }
    // We're checking the object code based on the year & chart from the working entry.
    workingEntry.setFinancialObjectCode(originEntry.getFinancialObjectCode());
    // the fiscal year can be blank in originEntry, but we're assuming that the year attribute is populated by the validate year
    // method
    ObjectCode workingEntryFinancialObject = accountingCycleCachingService.getObjectCode(workingEntry.getUniversityFiscalYear(), workingEntry.getChartOfAccountsCode(), workingEntry.getFinancialObjectCode());
    if (workingEntryFinancialObject == null) {
        String objectCodeString = workingEntry.getUniversityFiscalYear() + "-" + workingEntry.getChartOfAccountsCode() + "-" + workingEntry.getFinancialObjectCode();
        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_OBJECT_CODE_NOT_FOUND, objectCodeString, Message.TYPE_FATAL);
    }
    if (!workingEntryFinancialObject.isActive()) {
        String objectCodeString = workingEntry.getUniversityFiscalYear() + "-" + workingEntry.getChartOfAccountsCode() + "-" + workingEntry.getFinancialObjectCode();
        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_OBJECT_CODE_NOT_ACTIVE, objectCodeString, Message.TYPE_FATAL);
    }
    return null;
}
Also used : ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode)

Example 3 with ObjectCode

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

the class AccountingLineRuleHelperServiceImpl method getAccountingLineValidationErrors.

@Override
public List<AccountingLineValidationError> getAccountingLineValidationErrors(AccountingLine accountingLine, boolean useShortMessages) {
    List<AccountingLineValidationError> validationErrors = new ArrayList<>();
    // CORNELL FIX:
    if (ObjectUtils.isNull(accountingLine)) {
        return validationErrors;
    }
    // get the accounting line sequence string to identify which line has error.
    String accountIdentifyingPropertyName = getAccountIdentifyingPropertyName(accountingLine);
    // retrieve accounting line objects to validate
    Chart chart = accountingLine.getChart();
    Account account = accountingLine.getAccount();
    ObjectCode objectCode = accountingLine.getObjectCode();
    validationErrors.addAll(getChartValidationErrors(chart, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, accountIdentifyingPropertyName, useShortMessages));
    validationErrors.addAll(getAccountValidationErrors(account, KFSPropertyConstants.ACCOUNT_NUMBER, accountIdentifyingPropertyName, useShortMessages));
    // sub account is not required
    if (StringUtils.isNotBlank(accountingLine.getSubAccountNumber()) && !accountingLine.getSubAccountNumber().equals(KFSConstants.getDashSubAccountNumber())) {
        SubAccount subAccount = accountingLine.getSubAccount();
        validationErrors.addAll(getSubAccountValidationErrors(subAccount, KFSPropertyConstants.SUB_ACCOUNT_NUMBER, accountIdentifyingPropertyName, useShortMessages));
    }
    validationErrors.addAll(getObjectCodeValidationErrors(objectCode, KFSPropertyConstants.FINANCIAL_OBJECT_CODE, accountIdentifyingPropertyName, useShortMessages));
    // sub object is not required
    if (StringUtils.isNotBlank(accountingLine.getFinancialSubObjectCode())) {
        SubObjectCode subObjectCode = accountingLine.getSubObjectCode();
        validationErrors.addAll(getSubObjectCodeValidationErrors(subObjectCode, KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, accountIdentifyingPropertyName, useShortMessages));
    }
    // project code is not required
    if (StringUtils.isNotBlank(accountingLine.getProjectCode())) {
        ProjectCode projectCode = accountingLine.getProject();
        validationErrors.addAll(getProjectCodeValidationErrors(projectCode, KFSConstants.PROJECT_CODE_PROPERTY_NAME, accountIdentifyingPropertyName, useShortMessages));
    }
    if (StringUtils.isNotBlank(accountingLine.getReferenceOriginCode())) {
        OriginationCode referenceOrigin = accountingLine.getReferenceOrigin();
        validationErrors.addAll(getReferenceOriginCodeValidationErrors(accountIdentifyingPropertyName, referenceOrigin, useShortMessages));
    }
    if (StringUtils.isNotBlank(accountingLine.getReferenceTypeCode())) {
        DocumentType referenceType = accountingLine.getReferenceFinancialSystemDocumentType();
        validationErrors.addAll(getReferenceTypeCodeValidationErrors(accountingLine.getReferenceTypeCode(), referenceType, accountIdentifyingPropertyName, useShortMessages));
    }
    return validationErrors;
}
Also used : SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) Account(org.kuali.kfs.coa.businessobject.Account) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode) OriginationCode(org.kuali.kfs.sys.businessobject.OriginationCode) ArrayList(java.util.ArrayList) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) DocumentType(org.kuali.kfs.kew.doctype.bo.DocumentType) ProjectCode(org.kuali.kfs.coa.businessobject.ProjectCode) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode) Chart(org.kuali.kfs.coa.businessobject.Chart) AccountingLineOverride(org.kuali.kfs.sys.businessobject.AccountingLineOverride)

Example 4 with ObjectCode

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

the class AccountingLineRuleHelperServiceImpl method hasObjectBudgetRequiredOverrides.

public boolean hasObjectBudgetRequiredOverrides(AccountingLine line, String overrideCode) {
    boolean retVal = true;
    ObjectCode objectCode = line.getObjectCode();
    AccountingLineOverride override = AccountingLineOverride.valueOf(overrideCode);
    Account account = line.getAccount();
    if (AccountingLineOverride.needsObjectBudgetOverride(account, objectCode) && !override.hasComponent(AccountingLineOverride.COMPONENT.NON_BUDGETED_OBJECT)) {
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_PRESENCE_NON_BUDGETED_OBJECT_CODE, account.getAccountNumber(), objectCode.getFinancialObjectCode());
        retVal = false;
    }
    return retVal;
}
Also used : SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) Account(org.kuali.kfs.coa.businessobject.Account) AccountingLineOverride(org.kuali.kfs.sys.businessobject.AccountingLineOverride) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode)

Example 5 with ObjectCode

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

the class AccountVerificationWebServiceImpl method isValidObjectCode.

public boolean isValidObjectCode(String chartOfAccountsCode, String objectCodeParm) throws Exception {
    boolean isValidObjectCode = false;
    ObjectCode objectCode = SpringContext.getBean(ObjectCodeService.class).getByPrimaryIdForCurrentYear(chartOfAccountsCode, objectCodeParm);
    if (objectCode == null || objectCode.toString().isEmpty() || (!objectCode.isActive())) {
        isValidObjectCode = false;
    } else {
        isValidObjectCode = true;
    }
    return isValidObjectCode;
}
Also used : SubObjectCodeService(org.kuali.kfs.coa.service.SubObjectCodeService) ObjectCodeService(org.kuali.kfs.coa.service.ObjectCodeService) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode)

Aggregations

ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)30 SubObjectCode (org.kuali.kfs.coa.businessobject.SubObjectCode)9 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 ArrayList (java.util.ArrayList)4 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)4 HashMap (java.util.HashMap)3 ObjectCodeService (org.kuali.kfs.coa.service.ObjectCodeService)3 FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)3 AssetObjectCode (org.kuali.kfs.module.cam.businessobject.AssetObjectCode)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 PaymentMethodChart (edu.cornell.kfs.fp.businessobject.PaymentMethodChart)2 Date (java.sql.Date)2 Timestamp (java.sql.Timestamp)2 Account (org.kuali.kfs.coa.businessobject.Account)2 ObjectType (org.kuali.kfs.coa.businessobject.ObjectType)2 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)2 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)2 SubObjectCodeService (org.kuali.kfs.coa.service.SubObjectCodeService)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 AccountingLineOverride (org.kuali.kfs.sys.businessobject.AccountingLineOverride)2