Search in sources :

Example 1 with ObjectType

use of org.kuali.kfs.coa.businessobject.ObjectType 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 ObjectType

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

the class ScrubberValidatorImpl method validateReferenceDocumentFields.

/**
 * If the encumbrance update code = R, ref doc number must exist, ref doc type must be valid and ref origin code must be valid.
 * If encumbrance update code is not R, and ref doc number is empty, make sure ref doc number, ref doc type and ref origin code
 * are null. If encumbrance update code is not R and the ref doc number has a value, ref doc type must be valid and ref origin
 * code must be valid.
 *
 * @param originEntry      the origin entry to check
 * @param workingEntryInfo the copy of the entry to move valid data into
 * @return a Message if an error was encountered, otherwise null
 */
protected List<Message> validateReferenceDocumentFields(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateReferenceDocument() started");
    // 3148 of cobol
    List<Message> errors = new ArrayList();
    boolean numberNullIndicator = !StringUtils.hasText(originEntry.getReferenceFinancialDocumentNumber());
    boolean typeCodeNullIndicator = !StringUtils.hasText(originEntry.getReferenceFinancialDocumentTypeCode());
    boolean originCodeNullIndicator = !StringUtils.hasText(originEntry.getReferenceFinancialSystemOriginationCode());
    // TODO:- do we need this?
    boolean editReference = true;
    if (numberNullIndicator) {
        workingEntry.setReferenceFinancialDocumentNumber(null);
        workingEntry.setReferenceFinancialDocumentTypeCode(null);
        workingEntry.setReferenceFinancialSystemOriginationCode(null);
        if (KFSConstants.ENCUMB_UPDT_REFERENCE_DOCUMENT_CD.equals(originEntry.getTransactionEncumbranceUpdateCode())) {
            errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_REF_DOC_NOT_BE_SPACE, Message.TYPE_FATAL));
        }
    } else {
        workingEntry.setReferenceFinancialDocumentNumber(originEntry.getReferenceFinancialDocumentNumber());
        if (!typeCodeNullIndicator) {
            if (accountingCycleCachingService.isCurrentActiveAccountingDocumentType(originEntry.getReferenceFinancialDocumentTypeCode())) {
                workingEntry.setReferenceFinancialDocumentTypeCode(originEntry.getReferenceFinancialDocumentTypeCode());
            } else {
                errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_REFERENCE_DOCUMENT_TYPE_NOT_FOUND, originEntry.getReferenceFinancialDocumentTypeCode(), Message.TYPE_FATAL));
            }
        } else {
            errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_REFERENCE_FIELDS, " " + KFSPropertyConstants.REFERENCE_FIN_DOCUMENT_TYPE_CODE + " is missing.", Message.TYPE_FATAL));
        }
        if (!originCodeNullIndicator) {
            // Validate reference origin code
            OriginationCode oc = accountingCycleCachingService.getOriginationCode(originEntry.getFinancialSystemOriginationCode());
            if (oc != null) {
                workingEntry.setReferenceFinancialSystemOriginationCode(originEntry.getReferenceFinancialSystemOriginationCode());
            } else {
                errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_REFERENCE_ORIGINATION_CODE_NOT_FOUND, " (" + originEntry.getReferenceFinancialSystemOriginationCode() + ")", Message.TYPE_FATAL));
            }
        } else {
            errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_REFERENCE_FIELDS, " " + KFSPropertyConstants.REFERENCE_FINANCIAL_SYSTEM_ORIGINATION_CODE + " is missing.", Message.TYPE_FATAL));
        }
    }
    BalanceType workingEntryBalanceType = accountingCycleCachingService.getBalanceType(workingEntry.getFinancialBalanceTypeCode());
    ObjectType workingEntryObjectType = accountingCycleCachingService.getObjectType(workingEntry.getFinancialObjectTypeCode());
    if (workingEntryBalanceType == null || workingEntryObjectType == null) {
        // It would be nice if we could still validate the entry, but we can't.
        return errors;
    }
    if (workingEntryBalanceType.isFinBalanceTypeEncumIndicator() && !workingEntryObjectType.isFundBalanceIndicator()) {
        if (// KFSMI-5565 : Allow blank/null for encumbrance update code, since it is the same as "N" during processing and should not be an error
        org.apache.commons.lang.StringUtils.isBlank(originEntry.getTransactionEncumbranceUpdateCode()) || KFSConstants.ENCUMB_UPDT_DOCUMENT_CD.equals(originEntry.getTransactionEncumbranceUpdateCode()) || KFSConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD.equals(originEntry.getTransactionEncumbranceUpdateCode()) || KFSConstants.ENCUMB_UPDT_REFERENCE_DOCUMENT_CD.equals(originEntry.getTransactionEncumbranceUpdateCode())) {
            workingEntry.setTransactionEncumbranceUpdateCode(originEntry.getTransactionEncumbranceUpdateCode());
        } else {
            errors.add(MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ENC_UPDATE_CODE_NOT_DRN, " (" + originEntry.getTransactionEncumbranceUpdateCode() + ")", Message.TYPE_FATAL));
        }
    } else {
        workingEntry.setTransactionEncumbranceUpdateCode(null);
    }
    return errors;
}
Also used : ObjectType(org.kuali.kfs.coa.businessobject.ObjectType) Message(org.kuali.kfs.sys.Message) OriginationCode(org.kuali.kfs.sys.businessobject.OriginationCode) ArrayList(java.util.ArrayList) BalanceType(org.kuali.kfs.coa.businessobject.BalanceType)

Example 3 with ObjectType

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

the class AdvanceDepositServiceImpl method getObjectCodeType.

protected String getObjectCodeType(String chart, String objectCode) {
    Map<String, String> keys = new HashMap<String, String>();
    keys.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart);
    keys.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, objectCode);
    ObjectCode objectCodeInfo = businessObjectService.findByPrimaryKey(ObjectCode.class, keys);
    objectCodeInfo.refreshReferenceObject(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE);
    ObjectType objectType = objectCodeInfo.getFinancialObjectType();
    String objectTypeCode = objectType.getBasicAccountingCategoryCode();
    return objectTypeCode;
}
Also used : ObjectType(org.kuali.kfs.coa.businessobject.ObjectType) HashMap(java.util.HashMap) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 4 with ObjectType

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

the class ContractsGrantsInvoiceCreateDocumentServiceImpl method retrieveExpenseObjectTypes.

/**
 * Retrieve expense object types by the basic accounting category for expenses
 */
@Override
public Collection<String> retrieveExpenseObjectTypes() {
    List<String> objectTypeCodes = new ArrayList<>();
    Map<String, Object> fieldValues = new HashMap<>();
    fieldValues.put(KFSPropertyConstants.BASIC_ACCOUNTING_CATEGORY_CODE, KFSConstants.BasicAccountingCategoryCodes.EXPENSES);
    final Collection<ObjectType> objectTypes = getBusinessObjectService().findMatching(ObjectType.class, fieldValues);
    for (ObjectType objectType : objectTypes) {
        objectTypeCodes.add(objectType.getCode());
    }
    return objectTypeCodes;
}
Also used : ObjectType(org.kuali.kfs.coa.businessobject.ObjectType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

ObjectType (org.kuali.kfs.coa.businessobject.ObjectType)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)2 HashSet (java.util.HashSet)1 BalanceType (org.kuali.kfs.coa.businessobject.BalanceType)1 SubObjectCode (org.kuali.kfs.coa.businessobject.SubObjectCode)1 ScrubberStep (org.kuali.kfs.gl.batch.ScrubberStep)1 Message (org.kuali.kfs.sys.Message)1 OriginationCode (org.kuali.kfs.sys.businessobject.OriginationCode)1