Search in sources :

Example 6 with Message

use of org.kuali.kfs.sys.Message in project cu-kfs by CU-CommunityApps.

the class CuScrubberProcessImpl method generateCostShareEntries.

/**
 * Overridden to update cost share source account entries so that they will post to the
 * continuation account if the cost share account is closed.
 *
 * @see org.kuali.kfs.gl.batch.service.impl.ScrubberProcessImpl#generateCostShareEntries(
 *         org.kuali.kfs.gl.businessobject.OriginEntryInformation, org.kuali.kfs.gl.service.ScrubberReportData)
 */
@Override
protected ScrubberProcessTransactionError generateCostShareEntries(OriginEntryInformation scrubbedEntry, ScrubberReportData scrubberReport) {
    // 3000-COST-SHARE to 3100-READ-OFSD in the cobol Generate Cost Share Entries
    LOG.debug("generateCostShareEntries() started");
    try {
        OriginEntryFull costShareEntry = OriginEntryFull.copyFromOriginEntryable(scrubbedEntry);
        SystemOptions scrubbedEntryOption = accountingCycleCachingService.getSystemOptions(scrubbedEntry.getUniversityFiscalYear());
        A21SubAccount scrubbedEntryA21SubAccount = accountingCycleCachingService.getA21SubAccount(scrubbedEntry.getChartOfAccountsCode(), scrubbedEntry.getAccountNumber(), scrubbedEntry.getSubAccountNumber());
        costShareEntry.setFinancialObjectCode(parameterService.getParameterValueAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupParameters.COST_SHARE_OBJECT_CODE_PARM_NM));
        costShareEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        costShareEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
        costShareEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
        StringBuffer description = new StringBuffer();
        description.append(costShareDescription);
        description.append(" ").append(scrubbedEntry.getAccountNumber());
        description.append(offsetString);
        costShareEntry.setTransactionLedgerEntryDescription(description.toString());
        costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
        if (scrubCostShareAmount.isPositive()) {
            costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
            costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
        }
        costShareEntry.setTransactionDate(runDate);
        costShareEntry.setOrganizationDocumentNumber(null);
        costShareEntry.setProjectCode(KFSConstants.getDashProjectCode());
        costShareEntry.setOrganizationReferenceId(null);
        costShareEntry.setReferenceFinancialDocumentTypeCode(null);
        costShareEntry.setReferenceFinancialSystemOriginationCode(null);
        costShareEntry.setReferenceFinancialDocumentNumber(null);
        costShareEntry.setFinancialDocumentReversalDate(null);
        costShareEntry.setTransactionEncumbranceUpdateCode(null);
        createOutputEntry(costShareEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareOffsetEntry = new OriginEntryFull(costShareEntry);
        costShareOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
        OffsetDefinition offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
        if (offsetDefinition != null) {
            if (offsetDefinition.getFinancialObject() == null) {
                StringBuffer objectCodeKey = new StringBuffer();
                objectCodeKey.append(offsetDefinition.getUniversityFiscalYear());
                objectCodeKey.append("-").append(offsetDefinition.getChartOfAccountsCode());
                objectCodeKey.append("-").append(offsetDefinition.getFinancialObjectCode());
                Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
                LOG.debug("generateCostShareEntries() Error 1 object not found");
                return new ScrubberProcessTransactionError(costShareEntry, m);
            }
            costShareOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
            costShareOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
            costShareOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
            StringBuffer offsetKey = new StringBuffer("cost share transfer ");
            offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
            offsetKey.append("-");
            offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
            offsetKey.append("-TF-");
            offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
            Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
            LOG.debug("generateCostShareEntries() Error 2 offset not found");
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        costShareOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
        if (costShareEntry.isCredit()) {
            costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        }
        try {
            flexibleOffsetAccountService.updateOffset(costShareOffsetEntry);
        } catch (InvalidFlexibleOffsetException e) {
            Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
            if (LOG.isDebugEnabled()) {
                LOG.debug("generateCostShareEntries() Cost Share Transfer Flexible Offset Error: " + e.getMessage());
            }
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        createOutputEntry(costShareOffsetEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareSourceAccountEntry = new OriginEntryFull(costShareEntry);
        description = new StringBuffer();
        description.append(costShareDescription);
        description.append(" ").append(scrubbedEntry.getAccountNumber());
        description.append(offsetString);
        costShareSourceAccountEntry.setTransactionLedgerEntryDescription(description.toString());
        // CU Customization: If Cost Share account is closed, use its continuation account instead.
        ScrubberProcessTransactionError continuationError = setupEntryWithPotentialContinuation(costShareSourceAccountEntry, scrubbedEntryA21SubAccount);
        if (continuationError != null) {
            return continuationError;
        }
        setCostShareObjectCode(costShareSourceAccountEntry, scrubbedEntry);
        if (StringHelper.isNullOrEmpty(costShareSourceAccountEntry.getSubAccountNumber())) {
            costShareSourceAccountEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
        }
        costShareSourceAccountEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        costShareSourceAccountEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
        costShareSourceAccountEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
        costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
        if (scrubCostShareAmount.isPositive()) {
            costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        } else {
            costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
            costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
        }
        costShareSourceAccountEntry.setTransactionDate(runDate);
        costShareSourceAccountEntry.setOrganizationDocumentNumber(null);
        costShareSourceAccountEntry.setProjectCode(KFSConstants.getDashProjectCode());
        costShareSourceAccountEntry.setOrganizationReferenceId(null);
        costShareSourceAccountEntry.setReferenceFinancialDocumentTypeCode(null);
        costShareSourceAccountEntry.setReferenceFinancialSystemOriginationCode(null);
        costShareSourceAccountEntry.setReferenceFinancialDocumentNumber(null);
        costShareSourceAccountEntry.setFinancialDocumentReversalDate(null);
        costShareSourceAccountEntry.setTransactionEncumbranceUpdateCode(null);
        createOutputEntry(costShareSourceAccountEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareSourceAccountOffsetEntry = new OriginEntryFull(costShareSourceAccountEntry);
        costShareSourceAccountOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
        // Lookup the new offset definition.
        offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
        if (offsetDefinition != null) {
            if (offsetDefinition.getFinancialObject() == null) {
                Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
                StringBuffer objectCodeKey = new StringBuffer();
                objectCodeKey.append(costShareEntry.getUniversityFiscalYear());
                objectCodeKey.append("-").append(scrubbedEntry.getChartOfAccountsCode());
                objectCodeKey.append("-").append(scrubbedEntry.getFinancialObjectCode());
                Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
                LOG.debug("generateCostShareEntries() Error 3 object not found");
                return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
            }
            costShareSourceAccountOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
            costShareSourceAccountOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
            costShareSourceAccountOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
            StringBuffer offsetKey = new StringBuffer("cost share transfer source ");
            offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
            offsetKey.append("-");
            offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
            offsetKey.append("-TF-");
            offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
            Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
            LOG.debug("generateCostShareEntries() Error 4 offset not found");
            return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
        }
        costShareSourceAccountOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
        if (scrubbedEntry.isCredit()) {
            costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        }
        try {
            flexibleOffsetAccountService.updateOffset(costShareSourceAccountOffsetEntry);
        } catch (InvalidFlexibleOffsetException e) {
            Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
            if (LOG.isDebugEnabled()) {
                LOG.debug("generateCostShareEntries() Cost Share Transfer Account Flexible Offset Error: " + e.getMessage());
            }
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        createOutputEntry(costShareSourceAccountOffsetEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        scrubCostShareAmount = KualiDecimal.ZERO;
    } catch (IOException ioe) {
        LOG.error("generateCostShareEntries() Stopped: " + ioe.getMessage());
        throw new RuntimeException("generateCostShareEntries() Stopped: " + ioe.getMessage(), ioe);
    }
    LOG.debug("generateCostShareEntries() successful");
    return null;
}
Also used : Message(org.kuali.kfs.sys.Message) HashMap(java.util.HashMap) IOException(java.io.IOException) InvalidFlexibleOffsetException(org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException) ScrubberStep(org.kuali.kfs.gl.batch.ScrubberStep) Transaction(org.kuali.kfs.gl.businessobject.Transaction) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) List(java.util.List) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull) ScrubberProcessTransactionError(org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 7 with Message

use of org.kuali.kfs.sys.Message in project cu-kfs by CU-CommunityApps.

the class CuScrubberValidatorImpl method validateUniversityFiscalPeriodCode.

@Override
protected Message validateUniversityFiscalPeriodCode(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, UniversityDate universityRunDate, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateUniversityFiscalPeriodCode() started");
    Message retVal = null;
    String periodCode = originEntry.getUniversityFiscalPeriodCode();
    if (!StringUtils.hasText(periodCode)) {
        retVal = updateFiscalAccountingPeriodToCurrent(workingEntry, universityRunDate);
    } else {
        AccountingPeriod originEntryAccountingPeriod = accountingCycleCachingService.getAccountingPeriod(originEntry.getUniversityFiscalYear(), originEntry.getUniversityFiscalPeriodCode());
        if (originEntryAccountingPeriod == null) {
            retVal = MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ACCOUNTING_PERIOD_NOT_FOUND, periodCode, Message.TYPE_FATAL);
        } else if (originEntryAccountingPeriod.getUniversityFiscalPeriodCode().equals(KFSConstants.MONTH13) && !originEntryAccountingPeriod.isOpen()) {
            retVal = updateFiscalAccountingPeriodToCurrent(workingEntry, universityRunDate);
        } else if (!originEntryAccountingPeriod.isActive()) {
            retVal = MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ACCOUNTING_PERIOD_NOT_ACTIVE, periodCode, Message.TYPE_FATAL);
        }
        workingEntry.setUniversityFiscalPeriodCode(periodCode);
    }
    return retVal;
}
Also used : Message(org.kuali.kfs.sys.Message) AccountingPeriod(org.kuali.kfs.coa.businessobject.AccountingPeriod)

Example 8 with Message

use of org.kuali.kfs.sys.Message in project cu-kfs by CU-CommunityApps.

the class ScrubberValidatorImpl method validateOrigination.

/**
 * Validates the origination 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 validateOrigination(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateOrigination() started");
    if (StringUtils.hasText(originEntry.getFinancialSystemOriginationCode())) {
        OriginationCode originEntryOrigination = accountingCycleCachingService.getOriginationCode(originEntry.getFinancialSystemOriginationCode());
        if (originEntryOrigination == null) {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ORIGIN_CODE_NOT_FOUND, originEntry.getFinancialSystemOriginationCode(), Message.TYPE_FATAL);
        }
        if (!originEntryOrigination.isActive()) {
            return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_ORIGIN_CODE_NOT_ACTIVE, originEntry.getFinancialSystemOriginationCode(), Message.TYPE_FATAL);
        }
        workingEntry.setFinancialSystemOriginationCode(originEntry.getFinancialSystemOriginationCode());
    } else {
        return new Message(kualiConfigurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_ORIGIN_CODE_NOT_FOUND) + " (" + originEntry.getFinancialSystemOriginationCode() + ")", Message.TYPE_FATAL);
    }
    return null;
}
Also used : Message(org.kuali.kfs.sys.Message) OriginationCode(org.kuali.kfs.sys.businessobject.OriginationCode)

Example 9 with Message

use of org.kuali.kfs.sys.Message 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 10 with Message

use of org.kuali.kfs.sys.Message in project cu-kfs by CU-CommunityApps.

the class ScrubberValidatorImpl method validateTransaction.

/**
 * Validate a transaction in the scrubber
 *
 * @param originEntry       Input transaction (never changed)
 * @param scrubbedEntry     Output transaction (scrubbed version of input transaction)
 * @param universityRunDate Date of scrubber run
 * @return List of Message objects based for warnings or errors that happened when validating the transaction
 * @see org.kuali.module.gl.service.ScrubberValidator#validateTransaction(org.kuali.module.gl.bo.OriginEntry, org.kuali.module.gl.bo.OriginEntry, org.kuali.module.gl.bo.UniversityDate, boolean)
 */
@Override
public List<Message> validateTransaction(OriginEntryInformation originEntry, OriginEntryInformation scrubbedEntry, UniversityDate universityRunDate, boolean laborIndicator, AccountingCycleCachingService accountingCycleCachingService) {
    LOG.debug("validateTransaction() started");
    continuationAccountIndicator = false;
    List<Message> errors = new ArrayList<Message>();
    count++;
    if (count % 1000 == 0) {
        LOG.info(count + " " + originEntry.getLine());
    }
    // less than 32 part.
    if ((originEntry.getDocumentNumber() != null) && (originEntry.getDocumentNumber().indexOf("~") > -1)) {
        String d = originEntry.getDocumentNumber();
        scrubbedEntry.setDocumentNumber(d.replaceAll("~", " "));
        errors.add(new Message("** INVALID CHARACTER EDITED", Message.TYPE_WARNING));
    }
    if ((originEntry.getTransactionLedgerEntryDescription() != null) && (originEntry.getTransactionLedgerEntryDescription().indexOf("~") > -1)) {
        String d = originEntry.getTransactionLedgerEntryDescription();
        scrubbedEntry.setTransactionLedgerEntryDescription(d.replaceAll("~", " "));
        errors.add(new Message("** INVALID CHARACTER EDITED", Message.TYPE_WARNING));
    }
    if ((originEntry.getOrganizationDocumentNumber() != null) && (originEntry.getOrganizationDocumentNumber().indexOf("~") > -1)) {
        String d = originEntry.getOrganizationDocumentNumber();
        scrubbedEntry.setOrganizationDocumentNumber(d.replaceAll("~", " "));
        errors.add(new Message("** INVALID CHARACTER EDITED", Message.TYPE_WARNING));
    }
    if ((originEntry.getOrganizationReferenceId() != null) && (originEntry.getOrganizationReferenceId().indexOf("~") > -1)) {
        String d = originEntry.getOrganizationReferenceId();
        scrubbedEntry.setOrganizationReferenceId(d.replaceAll("~", " "));
        errors.add(new Message("** INVALID CHARACTER EDITED", Message.TYPE_WARNING));
    }
    if ((originEntry.getReferenceFinancialDocumentNumber() != null) && (originEntry.getReferenceFinancialDocumentNumber().indexOf("~") > -1)) {
        String d = originEntry.getReferenceFinancialDocumentNumber();
        scrubbedEntry.setReferenceFinancialDocumentNumber(d.replaceAll("~", " "));
        errors.add(new Message("** INVALID CHARACTER EDITED", Message.TYPE_WARNING));
    }
    // It's important that this check come before the checks for object, sub-object and accountingPeriod
    // because this validation method will set the fiscal year and reload those three objects if the fiscal
    // year was invalid. This will also set originEntry.getOption and workingEntry.getOption. So, it's
    // probably a good idea to validate the fiscal year first thing.
    Message err = validateFiscalYear(originEntry, scrubbedEntry, universityRunDate, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateUniversityFiscalPeriodCode(originEntry, scrubbedEntry, universityRunDate, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateBalanceType(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateTransactionDate(originEntry, scrubbedEntry, universityRunDate, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateTransactionAmount(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateChart(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    // Labor Scrubber doesn't validate Account here.
    if (!laborIndicator) {
        err = validateAccount(originEntry, scrubbedEntry, universityRunDate, accountingCycleCachingService);
        if (err != null) {
            errors.add(err);
        }
    }
    // Labor Scrubber doesn't validate SubAccount here
    if (!laborIndicator) {
        err = validateSubAccount(originEntry, scrubbedEntry, accountingCycleCachingService);
        if (err != null) {
            errors.add(err);
        }
    }
    err = validateProjectCode(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateDocumentType(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateOrigination(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateReferenceOrigination(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateDocumentNumber(originEntry, scrubbedEntry);
    if (err != null) {
        errors.add(err);
    }
    err = validateObjectCode(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    // If object code is invalid, we can't check the object type
    if (err == null) {
        err = validateObjectType(originEntry, scrubbedEntry, accountingCycleCachingService);
        if (err != null) {
            errors.add(err);
        }
    }
    err = validateSubObjectCode(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    // return messages could be multiple from validateReferenceFields
    List<Message> referenceErrors = new ArrayList<Message>();
    referenceErrors = validateReferenceDocumentFields(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (referenceErrors != null) {
        errors.addAll(referenceErrors);
    }
    err = validateReversalDate(originEntry, scrubbedEntry, accountingCycleCachingService);
    if (err != null) {
        errors.add(err);
    }
    err = validateDescription(originEntry);
    if (err != null) {
        errors.add(err);
    }
    return errors;
}
Also used : Message(org.kuali.kfs.sys.Message) ArrayList(java.util.ArrayList)

Aggregations

Message (org.kuali.kfs.sys.Message)14 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 Account (org.kuali.kfs.coa.businessobject.Account)4 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 PrintStream (java.io.PrintStream)2 List (java.util.List)2 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)2 BalanceType (org.kuali.kfs.coa.businessobject.BalanceType)2 ScrubberStep (org.kuali.kfs.gl.batch.ScrubberStep)2 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)2 ScrubberProcessTransactionError (org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError)2 LedgerSummaryReport (org.kuali.kfs.gl.report.LedgerSummaryReport)2 EnterpriseFeederStatusAndErrorMessagesWrapper (org.kuali.kfs.gl.service.impl.EnterpriseFeederStatusAndErrorMessagesWrapper)2 EnterpriseFeederReportData (org.kuali.kfs.module.ld.report.EnterpriseFeederReportData)2 OriginationCode (org.kuali.kfs.sys.businessobject.OriginationCode)2 SystemOptions (org.kuali.kfs.sys.businessobject.SystemOptions)2 InvalidFlexibleOffsetException (org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException)2 BufferedReader (java.io.BufferedReader)1