Search in sources :

Example 1 with SystemOptions

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateNominalCloseEntry.

/**
 * Generates the nominal close entry for given accounting line.
 *
 * @param document
 * @param postable
 * @param sequenceNumber
 * @param fiscalYear
 * @return the generated general ledger entry
 */
public GeneralLedgerPendingEntry generateNominalCloseEntry(AccountingDocumentBase document, AccountingLine postable, Integer sequenceNumber, Integer fiscalYear) {
    SystemOptions currentYearOptions = optionsService.getCurrentYearOptions();
    List<String> expenseObjectCodeTypes = objectTypeService.getExpenseObjectTypes(fiscalYear);
    String varNetExpenseObjectCode = getParameterService().getParameterValueAsString(NominalActivityClosingStep.class, "NET_EXPENSE_OBJECT_CODE");
    String varNetRevenueObjectCode = getParameterService().getParameterValueAsString(NominalActivityClosingStep.class, "NET_REVENUE_OBJECT_CODE");
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    GeneralLedgerPendingEntry activityEntry = new GeneralLedgerPendingEntry();
    activityEntry.setUniversityFiscalYear(fiscalYear);
    activityEntry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
    activityEntry.setAccountNumber(postable.getAccountNumber());
    activityEntry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
    if (expenseObjectCodeTypes.contains(postable.getObjectCode().getFinancialObjectTypeCode())) {
        activityEntry.setFinancialObjectCode(varNetExpenseObjectCode);
    } else {
        activityEntry.setFinancialObjectCode(varNetRevenueObjectCode);
    }
    activityEntry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
    activityEntry.setFinancialBalanceTypeCode(currentYearOptions.getNominalFinancialBalanceTypeCd());
    activityEntry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
    activityEntry.setUniversityFiscalPeriodCode(KFSConstants.MONTH13);
    activityEntry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    activityEntry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    activityEntry.setDocumentNumber(new StringBuffer(currentYearOptions.getActualFinancialBalanceTypeCd()).append(postable.getAccountNumber()).toString());
    activityEntry.setTransactionLedgerEntrySequenceNumber(sequenceNumber);
    if (expenseObjectCodeTypes.contains(postable.getObjectCode().getFinancialObjectTypeCode())) {
        activityEntry.setTransactionLedgerEntryDescription(createTransactionLedgerEntryDescription(configurationService.getPropertyValueAsString(KFSKeyConstants.MSG_CLOSE_ENTRY_TO_NOMINAL_EXPENSE), postable));
    } else {
        activityEntry.setTransactionLedgerEntryDescription(createTransactionLedgerEntryDescription(configurationService.getPropertyValueAsString(KFSKeyConstants.MSG_CLOSE_ENTRY_TO_NOMINAL_REVENUE), postable));
    }
    activityEntry.setTransactionLedgerEntryAmount(postable.getAmount());
    activityEntry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
    activityEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(postable.getDebitCreditCode()) ? KFSConstants.GL_CREDIT_CODE : KFSConstants.GL_DEBIT_CODE);
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    activityEntry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    activityEntry.setTransactionEntryProcessedTs(transactionTimestamp);
    activityEntry.setOrganizationDocumentNumber(null);
    activityEntry.setProjectCode(StringUtils.isBlank(postable.getProjectCode()) ? KFSConstants.getDashProjectCode() : postable.getProjectCode());
    activityEntry.setOrganizationReferenceId(postable.getOrganizationReferenceId());
    activityEntry.setReferenceFinancialDocumentTypeCode(null);
    activityEntry.setReferenceFinancialSystemOriginationCode(null);
    activityEntry.setReferenceFinancialDocumentNumber(null);
    activityEntry.setFinancialDocumentReversalDate(null);
    activityEntry.setTransactionEncumbranceUpdateCode(null);
    if (postable.getAmount().isNegative()) {
        activityEntry.setTransactionLedgerEntryAmount(postable.getAmount().negated());
    }
    return activityEntry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Timestamp(java.sql.Timestamp)

Example 2 with SystemOptions

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateGeneralForwardOriginEntry.

/**
 * Generates the general forward entry.
 *
 * @param document
 * @param postable
 * @param closingFiscalYear
 * @param sequenceNumber
 * @return the generated glpe
 */
public GeneralLedgerPendingEntry generateGeneralForwardOriginEntry(AccountingDocumentBase document, AccountingLine postable, Integer closingFiscalYear, Integer sequenceNumber) {
    SystemOptions currentYearOptions = optionsService.getCurrentYearOptions();
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    GeneralLedgerPendingEntry entry = new GeneralLedgerPendingEntry();
    entry.setUniversityFiscalYear(closingFiscalYear + 1);
    entry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
    entry.setAccountNumber(postable.getAccountNumber());
    entry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
    entry.setFinancialObjectCode(postable.getFinancialObjectCode());
    entry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(postable.getBalanceTypeCode());
    if (currentYearOptions.getFinObjTypeExpendNotExpCode().equals(postable.getObjectCode().getFinancialObjectTypeCode())) {
        entry.setFinancialObjectTypeCode(currentYearOptions.getFinancialObjectTypeAssetsCd());
    } else {
        entry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
    }
    entry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
    entry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    entry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    entry.setDocumentNumber(new StringBuffer(KFSConstants.BALANCE_TYPE_ACTUAL).append(postable.getAccountNumber()).toString());
    entry.setTransactionLedgerEntrySequenceNumber(sequenceNumber);
    entry.setTransactionLedgerEntryDescription(new StringBuffer("BEG BAL BROUGHT FORWARD FROM ").append(closingFiscalYear).toString());
    String transactionEncumbranceUpdateCode = null;
    transactionEncumbranceUpdateCode = KFSConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD;
    entry.setTransactionEncumbranceUpdateCode(transactionEncumbranceUpdateCode);
    KualiDecimal transactionLedgerEntryAmount = KualiDecimal.ZERO;
    transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(postable.getAmount());
    entry.setTransactionDebitCreditCode(postable.getDebitCreditCode());
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    entry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    entry.setTransactionEntryProcessedTs(transactionTimestamp);
    entry.setOrganizationDocumentNumber(null);
    entry.setProjectCode(StringUtils.isBlank(postable.getProjectCode()) ? KFSConstants.getDashProjectCode() : postable.getProjectCode());
    entry.setOrganizationReferenceId(postable.getOrganizationReferenceId());
    entry.setReferenceFinancialDocumentTypeCode(null);
    entry.setReferenceFinancialSystemOriginationCode(null);
    entry.setReferenceFinancialDocumentNumber(null);
    entry.setFinancialDocumentReversalDate(null);
    if (KFSConstants.BALANCE_TYPE_AUDIT_TRAIL.equals(entry.getFinancialBalanceTypeCode())) {
        entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    }
    if (transactionLedgerEntryAmount.isNegative()) {
        if (KFSConstants.BALANCE_TYPE_ACTUAL.equals(entry.getFinancialBalanceTypeCode())) {
            transactionLedgerEntryAmount = transactionLedgerEntryAmount.negated();
        }
    }
    entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
    return entry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Timestamp(java.sql.Timestamp)

Example 3 with SystemOptions

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateNominalCloseOffset.

/**
 * Generates the nominal close offset
 *
 * @param document
 * @param postable
 * @param sequenceNumber
 * @param fiscalYear
 * @return the generated offset
 */
public GeneralLedgerPendingEntry generateNominalCloseOffset(AccountingDocumentBase document, AccountingLine postable, Integer sequenceNumber, Integer fiscalYear) {
    String varFundBalanceObjectCode = getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FUND_BALANCE_OBJECT_CODE_PARM);
    String varFundBalanceObjectTypeCode = getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FUND_BALANCE_OBJECT_TYPE_PARM);
    SystemOptions currentYearOptions = optionsService.getCurrentYearOptions();
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    String debitCreditCode = postable.getDebitCreditCode();
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry();
    offsetEntry.setUniversityFiscalYear(fiscalYear);
    offsetEntry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
    offsetEntry.setAccountNumber(postable.getAccountNumber());
    // postable.getSubAccountNumber());
    offsetEntry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
    offsetEntry.setFinancialObjectCode(varFundBalanceObjectCode);
    offsetEntry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
    offsetEntry.setFinancialBalanceTypeCode(currentYearOptions.getNominalFinancialBalanceTypeCd());
    offsetEntry.setFinancialObjectTypeCode(varFundBalanceObjectTypeCode);
    offsetEntry.setUniversityFiscalPeriodCode(KFSConstants.MONTH13);
    offsetEntry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    offsetEntry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    offsetEntry.setDocumentNumber(new StringBuffer(currentYearOptions.getActualFinancialBalanceTypeCd()).append(postable.getAccountNumber()).toString());
    offsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceNumber.intValue()));
    offsetEntry.setTransactionLedgerEntryDescription(createTransactionLedgerEntryDescription(configurationService.getPropertyValueAsString(KFSKeyConstants.MSG_CLOSE_ENTRY_TO_FUND_BALANCE), postable));
    offsetEntry.setTransactionLedgerEntryAmount(postable.getAmount());
    offsetEntry.setTransactionDebitCreditCode(debitCreditCode);
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    offsetEntry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    offsetEntry.setTransactionEntryProcessedTs(transactionTimestamp);
    offsetEntry.setOrganizationDocumentNumber(null);
    offsetEntry.setProjectCode(StringUtils.isBlank(postable.getProjectCode()) ? KFSConstants.getDashProjectCode() : postable.getProjectCode());
    offsetEntry.setOrganizationReferenceId(postable.getOrganizationReferenceId());
    offsetEntry.setReferenceFinancialDocumentTypeCode(null);
    offsetEntry.setReferenceFinancialSystemOriginationCode(null);
    offsetEntry.setReferenceFinancialDocumentNumber(null);
    offsetEntry.setFinancialDocumentReversalDate(null);
    offsetEntry.setTransactionEncumbranceUpdateCode(null);
    return offsetEntry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Timestamp(java.sql.Timestamp)

Example 4 with SystemOptions

use of org.kuali.kfs.sys.businessobject.SystemOptions 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 5 with SystemOptions

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

Aggregations

SystemOptions (org.kuali.kfs.sys.businessobject.SystemOptions)9 Timestamp (java.sql.Timestamp)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 Message (org.kuali.kfs.sys.Message)2 CuBalanceDao (edu.cornell.kfs.gl.dataaccess.CuBalanceDao)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)1 BalanceType (org.kuali.kfs.coa.businessobject.BalanceType)1 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)1 ScrubberStep (org.kuali.kfs.gl.batch.ScrubberStep)1 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)1 ScrubberProcessTransactionError (org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError)1 Transaction (org.kuali.kfs.gl.businessobject.Transaction)1 InvalidFlexibleOffsetException (org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException)1 OptionsService (org.kuali.kfs.sys.service.OptionsService)1 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)1 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)1