Search in sources :

Example 11 with Message

use of org.kuali.kfs.sys.Message 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;
}
Also used : SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) Account(org.kuali.kfs.coa.businessobject.Account) Message(org.kuali.kfs.sys.Message) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) ScrubberStep(org.kuali.kfs.gl.batch.ScrubberStep)

Example 12 with Message

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

the class CuFileEnterpriseFeederHelperServiceImplTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    fileEnterpriseFeederHelperService = SpringContext.getBean(FileEnterpriseFeederHelperService.class);
    // make sure we have a batch directory
    String batchDirectory = SpringContext.getBean(EnterpriseFeederService.class).getDirectoryName();
    File batchDirectoryFile = new File(batchDirectory);
    batchDirectoryFile.mkdir();
    // copy the data file into place
    File dataFileSrc = new File(DATA_FILE_PATH);
    dataFileDest = new File(batchDirectory + "/SMGROS.data");
    FileUtils.copyFile(dataFileSrc, dataFileDest);
    // copy the recon file into place
    File rerconileSrc = new File(RECON_FILE_PATH);
    reconFileDest = new File(batchDirectory + "/SMGROS.recon");
    FileUtils.copyFile(rerconileSrc, reconFileDest);
    // create .done file
    String doneFileName = batchDirectory + "/SMGROS.done";
    doneFile = new File(doneFileName);
    if (!doneFile.exists()) {
        LOG.info("Creating done file: " + doneFile.getAbsolutePath());
        doneFile.createNewFile();
    }
    statusAndErrors = new EnterpriseFeederStatusAndErrorMessagesWrapper();
    statusAndErrors.setErrorMessages(new ArrayList<Message>());
    statusAndErrors.setFileNames(dataFileDest, reconFileDest, doneFile);
    File enterpriseFeedFile = null;
    String enterpriseFeedFileName = LaborConstants.BatchFileSystem.LABOR_ENTERPRISE_FEED + LaborConstants.BatchFileSystem.EXTENSION;
    enterpriseFeedFile = new File(batchDirectory + File.separator + enterpriseFeedFileName);
    enterpriseFeedPs = null;
    try {
        enterpriseFeedPs = new PrintStream(enterpriseFeedFile);
    } catch (FileNotFoundException e) {
        LOG.error("enterpriseFeedFile doesn't exist " + enterpriseFeedFileName);
        throw new RuntimeException("enterpriseFeedFile doesn't exist " + enterpriseFeedFileName);
    }
    ledgerSummaryReport = new LedgerSummaryReport();
    feederReportData = new EnterpriseFeederReportData();
    errorStatisticsReport = new ReportWriterTextServiceImpl();
}
Also used : EnterpriseFeederStatusAndErrorMessagesWrapper(org.kuali.kfs.gl.service.impl.EnterpriseFeederStatusAndErrorMessagesWrapper) PrintStream(java.io.PrintStream) Message(org.kuali.kfs.sys.Message) EnterpriseFeederReportData(org.kuali.kfs.module.ld.report.EnterpriseFeederReportData) FileNotFoundException(java.io.FileNotFoundException) ReportWriterTextServiceImpl(org.kuali.kfs.sys.service.impl.ReportWriterTextServiceImpl) FileEnterpriseFeederHelperService(org.kuali.kfs.module.ld.batch.service.FileEnterpriseFeederHelperService) EnterpriseFeederService(org.kuali.kfs.module.ld.batch.service.EnterpriseFeederService) LedgerSummaryReport(org.kuali.kfs.gl.report.LedgerSummaryReport) File(java.io.File)

Example 13 with Message

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

the class CuPosterServiceImpl method generateTransactions.

@Override
protected void generateTransactions(ExpenditureTransaction et, IndirectCostRecoveryRateDetail icrRateDetail, KualiDecimal generatedTransactionAmount, Date runDate, PrintStream group, IndirectCostRecoveryGenerationMetadata icrGenerationMetadata) {
    BigDecimal pct = new BigDecimal(icrRateDetail.getAwardIndrCostRcvyRatePct().toString());
    pct = pct.divide(BDONEHUNDRED);
    OriginEntryFull e = new OriginEntryFull();
    e.setTransactionLedgerEntrySequenceNumber(0);
    // means we use the ICR field from the account record, otherwise, use the field in the icrRateDetail
    if (GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(icrRateDetail.getFinancialObjectCode()) || GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(icrRateDetail.getFinancialObjectCode())) {
        e.setFinancialObjectCode(et.getObjectCode());
        e.setFinancialSubObjectCode(et.getSubObjectCode());
    } else {
        e.setFinancialObjectCode(icrRateDetail.getFinancialObjectCode());
        e.setFinancialSubObjectCode(icrRateDetail.getFinancialSubObjectCode());
    }
    if (GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(icrRateDetail.getAccountNumber())) {
        e.setAccountNumber(et.getAccountNumber());
        e.setChartOfAccountsCode(et.getChartOfAccountsCode());
        e.setSubAccountNumber(et.getSubAccountNumber());
    } else if (GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(icrRateDetail.getAccountNumber())) {
        e.setAccountNumber(icrGenerationMetadata.getIndirectCostRecoveryAcctNbr());
        e.setChartOfAccountsCode(icrGenerationMetadata.getIndirectCostRcvyFinCoaCode());
        e.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
    } else {
        e.setAccountNumber(icrRateDetail.getAccountNumber());
        e.setSubAccountNumber(icrRateDetail.getSubAccountNumber());
        e.setChartOfAccountsCode(icrRateDetail.getChartOfAccountsCode());
    // TODO Reporting thing line 1946
    }
    // take care of infinite recursive error case - do not generate entries
    if ((et.getAccountNumber().equals(e.getAccountNumber())) && (et.getChartOfAccountsCode().equals(e.getChartOfAccountsCode())) && (et.getSubAccountNumber().equals(e.getSubAccountNumber())) && (et.getObjectCode().equals(e.getFinancialObjectCode())) && (et.getSubObjectCode().equals(e.getFinancialSubObjectCode()))) {
        List<Message> warnings = new ArrayList<Message>();
        warnings.add(new Message("Infinite recursive encumbrance error " + et.getChartOfAccountsCode() + " " + et.getAccountNumber() + " " + et.getSubAccountNumber() + " " + et.getObjectCode() + " " + et.getSubObjectCode(), Message.TYPE_WARNING));
        reportWriterService.writeError(et, warnings);
        return;
    }
    e.setFinancialDocumentTypeCode(parameterService.getParameterValueAsString(PosterIndirectCostRecoveryEntriesStep.class, KFSConstants.SystemGroupParameterNames.GL_INDIRECT_COST_RECOVERY));
    e.setFinancialSystemOriginationCode(parameterService.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, KFSConstants.SystemGroupParameterNames.GL_ORIGINATION_CODE));
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_STRING);
    /*CUMod - start*/
    StringBuffer docNbr = new StringBuffer(ICR_EDOC_PREFIX);
    docNbr.append(sdf.format(runDate));
    e.setDocumentNumber(docNbr.toString());
    LOG.debug("CuPosterServiceImpl.generateTransactions: setDocumentNumber = '" + docNbr.toString() + "'");
    /*CUMod - stop*/
    if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
        e.setTransactionLedgerEntryDescription(getChargeDescription(pct, et.getObjectCode(), icrGenerationMetadata.getIndirectCostRecoveryTypeCode(), et.getAccountObjectDirectCostAmount().abs()));
    } else {
        e.setTransactionLedgerEntryDescription(getOffsetDescription(pct, et.getAccountObjectDirectCostAmount().abs(), et.getChartOfAccountsCode(), et.getAccountNumber()));
    }
    e.setTransactionDate(new java.sql.Date(runDate.getTime()));
    e.setTransactionDebitCreditCode(icrRateDetail.getTransactionDebitIndicator());
    e.setFinancialBalanceTypeCode(et.getBalanceTypeCode());
    e.setUniversityFiscalYear(et.getUniversityFiscalYear());
    e.setUniversityFiscalPeriodCode(et.getUniversityFiscalAccountingPeriod());
    ObjectCode oc = objectCodeService.getByPrimaryId(e.getUniversityFiscalYear(), e.getChartOfAccountsCode(), e.getFinancialObjectCode());
    if (oc == null) {
        LOG.warn(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OBJECT_CODE_NOT_FOUND_FOR) + e.getUniversityFiscalYear() + "," + e.getChartOfAccountsCode() + "," + e.getFinancialObjectCode());
        // this will be written out the ICR file. Then, when that file attempts to post, the transaction won't validate and will end up in the icr error file
        e.setFinancialObjectCode(icrRateDetail.getFinancialObjectCode());
    } else {
        e.setFinancialObjectTypeCode(oc.getFinancialObjectTypeCode());
    }
    if (generatedTransactionAmount.isNegative()) {
        if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
            e.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        } else {
            e.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        }
        e.setTransactionLedgerEntryAmount(generatedTransactionAmount.negated());
    } else {
        e.setTransactionLedgerEntryAmount(generatedTransactionAmount);
    }
    if (et.getBalanceTypeCode().equals(et.getOption().getExtrnlEncumFinBalanceTypCd()) || et.getBalanceTypeCode().equals(et.getOption().getIntrnlEncumFinBalanceTypCd()) || et.getBalanceTypeCode().equals(et.getOption().getPreencumbranceFinBalTypeCd()) || et.getBalanceTypeCode().equals(et.getOption().getCostShareEncumbranceBalanceTypeCd())) {
        e.setDocumentNumber(parameterService.getParameterValueAsString(PosterIndirectCostRecoveryEntriesStep.class, KFSConstants.SystemGroupParameterNames.GL_INDIRECT_COST_RECOVERY));
    }
    e.setProjectCode(et.getProjectCode());
    if (GeneralLedgerConstants.getDashOrganizationReferenceId().equals(et.getOrganizationReferenceId())) {
        e.setOrganizationReferenceId(null);
    } else {
        e.setOrganizationReferenceId(et.getOrganizationReferenceId());
    }
    // TODO 2031-2039
    try {
        createOutputEntry(e, group);
    } catch (IOException ioe) {
        LOG.error("generateTransactions Stopped: " + ioe.getMessage());
        throw new RuntimeException("generateTransactions Stopped: " + ioe.getMessage(), ioe);
    }
    // Now generate Offset
    e = new OriginEntryFull(e);
    if (KFSConstants.GL_DEBIT_CODE.equals(e.getTransactionDebitCreditCode())) {
        e.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    } else {
        e.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    }
    e.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    String offsetBalanceSheetObjectCodeNumber = determineIcrOffsetBalanceSheetObjectCodeNumber(e, et, icrRateDetail);
    e.setFinancialObjectCode(offsetBalanceSheetObjectCodeNumber);
    ObjectCode balSheetObjectCode = objectCodeService.getByPrimaryId(icrRateDetail.getUniversityFiscalYear(), e.getChartOfAccountsCode(), offsetBalanceSheetObjectCodeNumber);
    if (balSheetObjectCode == null) {
        List<Message> warnings = new ArrayList<Message>();
        warnings.add(new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_INVALID_OFFSET_OBJECT_CODE) + icrRateDetail.getUniversityFiscalYear() + "-" + e.getChartOfAccountsCode() + "-" + offsetBalanceSheetObjectCodeNumber, Message.TYPE_WARNING));
        reportWriterService.writeError(et, warnings);
    } else {
        e.setFinancialObjectTypeCode(balSheetObjectCode.getFinancialObjectTypeCode());
    }
    if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
        e.setTransactionLedgerEntryDescription(getChargeDescription(pct, et.getObjectCode(), icrGenerationMetadata.getIndirectCostRecoveryTypeCode(), et.getAccountObjectDirectCostAmount().abs()));
    } else {
        e.setTransactionLedgerEntryDescription(getOffsetDescription(pct, et.getAccountObjectDirectCostAmount().abs(), et.getChartOfAccountsCode(), et.getAccountNumber()));
    }
    try {
        flexibleOffsetAccountService.updateOffset(e);
    } catch (InvalidFlexibleOffsetException ex) {
        List<Message> warnings = new ArrayList<Message>();
        warnings.add(new Message("FAILED TO GENERATE FLEXIBLE OFFSETS " + ex.getMessage(), Message.TYPE_WARNING));
        reportWriterService.writeError(et, warnings);
        LOG.warn("FAILED TO GENERATE FLEXIBLE OFFSETS FOR EXPENDITURE TRANSACTION " + et.toString(), ex);
    }
    try {
        createOutputEntry(e, group);
    } catch (IOException ioe) {
        LOG.error("generateTransactions Stopped: " + ioe.getMessage());
        throw new RuntimeException("generateTransactions Stopped: " + ioe.getMessage(), ioe);
    }
}
Also used : PosterIndirectCostRecoveryEntriesStep(org.kuali.kfs.gl.batch.PosterIndirectCostRecoveryEntriesStep) Message(org.kuali.kfs.sys.Message) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) InvalidFlexibleOffsetException(org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException) BigDecimal(java.math.BigDecimal) Date(java.sql.Date) ArrayList(java.util.ArrayList) List(java.util.List) SimpleDateFormat(java.text.SimpleDateFormat) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 14 with Message

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

the class CuScrubberProcessImpl method setupEntryWithPotentialContinuation.

/**
 * Helper method for configuring the chart, account and sub-account on the cost-share-source-account entry,
 * using the cost share account's continuation account or descendant (up to a depth of 10) in the
 * event of a closed cost share account.
 *
 * @param costShareSourceAccountEntry The origin entry to configure.
 * @param scrubbedEntryA21SubAccount The A21 sub-account from the original scrubbed origin entry.
 * @return A ScrubberProcessTransactionError if a valid cost share or continuation account could not be found, null otherwise.
 */
protected ScrubberProcessTransactionError setupEntryWithPotentialContinuation(OriginEntryFull costShareSourceAccountEntry, A21SubAccount scrubbedEntryA21SubAccount) {
    Account costShareAccount = accountingCycleCachingService.getAccount(scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber());
    if (ObjectUtils.isNotNull(costShareAccount) && costShareAccount.isClosed()) {
        // Cost share source account is closed; check for a valid continuation account.
        Account continuationAccount = costShareAccount;
        for (int i = 0; i < CONTINUATION_ACCOUNT_DEPTH_LIMIT && ObjectUtils.isNotNull(continuationAccount) && continuationAccount.isClosed(); i++) {
            continuationAccount = accountingCycleCachingService.getAccount(continuationAccount.getContinuationFinChrtOfAcctCd(), continuationAccount.getContinuationAccountNumber());
        }
        if (ObjectUtils.isNull(continuationAccount) || costShareAccount == continuationAccount || continuationAccount.isClosed()) {
            // Could not find a valid Cost Share continuation account; return an error.
            return new ScrubberProcessTransactionError(costShareSourceAccountEntry, new Message(MessageFormat.format(configurationService.getPropertyValueAsString(CUKFSKeyConstants.ERROR_CSACCOUNT_CONTINUATION_ACCOUNT_CLOSED), scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber()), Message.TYPE_FATAL));
        } else {
            // Found a valid Cost Share continuation account, so use it.
            LOG.warn(MessageFormat.format(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CSACCOUNT_CONTINUATION_ACCOUNT_USED), scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber(), continuationAccount.getChartOfAccountsCode(), continuationAccount.getAccountNumber()));
            costShareSourceAccountEntry.setChartOfAccountsCode(continuationAccount.getChartOfAccountsCode());
            costShareSourceAccountEntry.setAccountNumber(continuationAccount.getAccountNumber());
            costShareSourceAccountEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
        }
    } else {
        // Cost Share source account is still open, so use it.
        costShareSourceAccountEntry.setChartOfAccountsCode(scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode());
        costShareSourceAccountEntry.setAccountNumber(scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber());
        costShareSourceAccountEntry.setSubAccountNumber(scrubbedEntryA21SubAccount.getCostShareSourceSubAccountNumber());
    }
    return null;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) Message(org.kuali.kfs.sys.Message) ScrubberProcessTransactionError(org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError)

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