Search in sources :

Example 1 with BalanceType

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

the class ScrubberValidatorImpl method validateBalanceType.

/**
 * Validates the balance type 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 validateBalanceType(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateBalanceType() started");
    // balance type IS NOT empty
    String balanceTypeCode = originEntry.getFinancialBalanceTypeCode();
    if (StringUtils.hasText(balanceTypeCode)) {
        BalanceType originEntryBalanceType = accountingCycleCachingService.getBalanceType(originEntry.getFinancialBalanceTypeCode());
        if (originEntryBalanceType == null) {
            // balance type IS NOT valid
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_BALANCE_TYPE_NOT_FOUND, " (" + balanceTypeCode + ")", Message.TYPE_FATAL);
        } else if (!originEntryBalanceType.isActive()) {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_BALANCE_TYPE_NOT_ACTIVE, balanceTypeCode, Message.TYPE_FATAL);
        } else {
            // balance type IS valid
            if (originEntryBalanceType.isFinancialOffsetGenerationIndicator()) {
                // entry IS an offset
                if (originEntry.getTransactionLedgerEntryAmount().isNegative()) {
                    // it's an INVALID non-budget transaction
                    return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_TRANS_CANNOT_BE_NEGATIVE_IF_OFFSET, Message.TYPE_FATAL);
                } else {
                    // it's a VALID non-budget transaction
                    if (!originEntry.isCredit() && !originEntry.isDebit()) {
                        // debit or a credit
                        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DC_INDICATOR_MUST_BE_D_OR_C, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
                    } else {
                        workingEntry.setFinancialBalanceTypeCode(balanceTypeCode);
                    }
                }
            } else {
                // entry IS NOT an offset, means it's a budget transaction
                if (StringUtils.hasText(originEntry.getTransactionDebitCreditCode())) {
                    return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DC_INDICATOR_MUST_BE_EMPTY, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
                } else {
                    if (originEntry.isCredit() || originEntry.isDebit()) {
                        // budget transactions must be neither debit nor credit
                        return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DC_INDICATOR_MUST_BE_NEITHER_D_NOR_C, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
                    } else {
                        // it's a valid budget transaction
                        workingEntry.setFinancialBalanceTypeCode(balanceTypeCode);
                    }
                }
            }
        }
    } else {
        // balance type IS empty. We can't set it if the year isn't set
        SystemOptions workingEntryOption = accountingCycleCachingService.getSystemOptions(workingEntry.getUniversityFiscalYear());
        if (workingEntryOption != null) {
            workingEntry.setFinancialBalanceTypeCode(workingEntryOption.getActualFinancialBalanceTypeCd());
        } else {
            // TODO:- need to change to use MessageBuilder
            return new Message("Unable to set balance type code when year is unknown: " + workingEntry.getUniversityFiscalYear(), Message.TYPE_FATAL);
        }
    }
    return null;
}
Also used : Message(org.kuali.kfs.sys.Message) BalanceType(org.kuali.kfs.coa.businessobject.BalanceType) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions)

Example 2 with BalanceType

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

the class YearEndJournalVoucherForm method populateBalanceTypeListForRendering.

@Override
protected void populateBalanceTypeListForRendering() {
    balanceTypes = new ArrayList<BalanceType>();
    BalanceType balanceTypeAC = SpringContext.getBean(BalanceTypeService.class).getBalanceTypeByCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    balanceTypes.add(balanceTypeAC);
    this.setBalanceTypes(balanceTypes);
    String selectedBalanceTypeCode = KFSConstants.BALANCE_TYPE_ACTUAL;
    setSelectedBalanceType(getPopulatedBalanceTypeInstance(selectedBalanceTypeCode));
    getJournalVoucherDocument().setBalanceTypeCode(selectedBalanceTypeCode);
}
Also used : BalanceTypeService(org.kuali.kfs.coa.service.BalanceTypeService) BalanceType(org.kuali.kfs.coa.businessobject.BalanceType)

Example 3 with BalanceType

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

the class ScrubberValidatorImpl method validateTransactionAmount.

/**
 * Validates the entry's transaction amount
 *
 * @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 validateTransactionAmount(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateTransactionAmount() started");
    KualiDecimal amount = originEntry.getTransactionLedgerEntryAmount();
    BalanceType originEntryBalanceType = accountingCycleCachingService.getBalanceType(originEntry.getFinancialBalanceTypeCode());
    if (originEntryBalanceType == null) {
        // We can't validate the amount without a balance type code
        return null;
    }
    if (originEntryBalanceType.isFinancialOffsetGenerationIndicator()) {
        if (amount.isPositive() || amount.isZero()) {
            workingEntry.setTransactionLedgerEntryAmount(originEntry.getTransactionLedgerEntryAmount());
        } else {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_NEGATIVE_AMOUNT, amount.toString(), Message.TYPE_FATAL);
        }
        if (StringHelper.isEmpty(originEntry.getTransactionDebitCreditCode())) {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DEBIT_CREDIT_INDICATOR_NEITHER_D_NOR_C, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
        }
        if (debitOrCredit.contains(originEntry.getTransactionDebitCreditCode())) {
            workingEntry.setTransactionDebitCreditCode(originEntry.getTransactionDebitCreditCode());
        } else {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DEBIT_CREDIT_INDICATOR_NEITHER_D_NOR_C, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
        }
    } else {
        if ((originEntry.getTransactionDebitCreditCode() == null) || (" ".equals(originEntry.getTransactionDebitCreditCode())) || ("".equals(originEntry.getTransactionDebitCreditCode()))) {
            workingEntry.setTransactionDebitCreditCode(KFSConstants.GL_BUDGET_CODE);
        } else {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_DEBIT_CREDIT_INDICATOR_MUST_BE_SPACE, originEntry.getTransactionDebitCreditCode(), Message.TYPE_FATAL);
        }
    }
    return null;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) BalanceType(org.kuali.kfs.coa.businessobject.BalanceType)

Example 4 with BalanceType

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

Aggregations

BalanceType (org.kuali.kfs.coa.businessobject.BalanceType)4 Message (org.kuali.kfs.sys.Message)2 ArrayList (java.util.ArrayList)1 ObjectType (org.kuali.kfs.coa.businessobject.ObjectType)1 BalanceTypeService (org.kuali.kfs.coa.service.BalanceTypeService)1 OriginationCode (org.kuali.kfs.sys.businessobject.OriginationCode)1 SystemOptions (org.kuali.kfs.sys.businessobject.SystemOptions)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1