Search in sources :

Example 16 with GeneralLedgerPendingEntry

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

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFeeAssessmentEntries.

/**
 * Generates the GL entries to charge the department for the foreign draft and credit the Wire Charge
 * Fee Account as specified by system parameters.
 *
 * @param document Document into which to add the generated GL Entries.
 */
protected boolean generateFeeAssessmentEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntry templatePendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, boolean reverseEntries) {
    LOG.debug("generateForeignDraftChargeEntries started");
    PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(templatePendingEntry.getChartOfAccountsCode(), new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
    if (pmc == null) {
        LOG.warn("No Applicable PaymentMethodChart found for chart: " + templatePendingEntry.getChartOfAccountsCode() + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
        return false;
    }
    // Get all the parameters which control these entries
    String feeIncomeChartCode = pmc.getFeeIncomeChartOfAccountsCode();
    String feeIncomeAccountNumber = pmc.getFeeIncomeAccountNumber();
    String feeExpenseObjectCode = pmc.getFeeExpenseFinancialObjectCode();
    String feeIncomeObjectCode = pmc.getFeeIncomeFinancialObjectCode();
    KualiDecimal feeAmount = pmc.getFeeAmount();
    // skip creation if the fee has been set to zero
    if (!KualiDecimal.ZERO.equals(feeAmount)) {
        // grab the explicit entry for the first accounting line and adjust for the foreign draft fee
        GeneralLedgerPendingEntry chargeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        chargeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        // change the object code (expense to the department)
        chargeEntry.setFinancialObjectCode(feeExpenseObjectCode);
        chargeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        chargeEntry.setTransactionLedgerEntryDescription(StringUtils.left("Automatic debit for " + pm.getPaymentMethodName() + " fee", 40));
        chargeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        // retrieve object type
        ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(chargeEntry.getChartOfAccountsCode(), chargeEntry.getFinancialObjectCode());
        if (objectCode == null) {
            LOG.fatal("Specified offset object code: " + chargeEntry.getChartOfAccountsCode() + "-" + chargeEntry.getFinancialObjectCode() + " does not exist - failed to generate foreign draft fee entries", new RuntimeException());
            return false;
        }
        chargeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        // Set the amount from the parameter
        chargeEntry.setTransactionLedgerEntryAmount(feeAmount);
        chargeEntry.setTransactionDebitCreditCode(reverseEntries ? GL_CREDIT_CODE : GL_DEBIT_CODE);
        document.addPendingEntry(chargeEntry);
        sequenceHelper.increment();
        // handle the offset entry
        GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(chargeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), chargeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
        // Now, create the income entry in the AP Foreign draft fee account
        GeneralLedgerPendingEntry feeIncomeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        feeIncomeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        feeIncomeEntry.setChartOfAccountsCode(feeIncomeChartCode);
        feeIncomeEntry.setAccountNumber(feeIncomeAccountNumber);
        feeIncomeEntry.setFinancialObjectCode(feeIncomeObjectCode);
        feeIncomeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        feeIncomeEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
        feeIncomeEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
        // retrieve object type
        objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(feeIncomeChartCode, feeIncomeObjectCode);
        if (objectCode == null) {
            LOG.fatal("Specified income object code: " + feeIncomeChartCode + "-" + feeIncomeObjectCode + " does not exist - failed to generate foreign draft income entries", new RuntimeException());
            return false;
        }
        feeIncomeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        feeIncomeEntry.setTransactionLedgerEntryAmount(feeAmount);
        feeIncomeEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        feeIncomeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        document.addPendingEntry(feeIncomeEntry);
        sequenceHelper.increment();
        // create the offset entry
        offsetEntry = new GeneralLedgerPendingEntry(feeIncomeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), feeIncomeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
    }
    return true;
}
Also used : PaymentMethodChart(edu.cornell.kfs.fp.businessobject.PaymentMethodChart) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 17 with GeneralLedgerPendingEntry

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateYearEndGeneralLedgerPendingEntries.

/**
 * @see edu.cornell.kfs.fp.document.service.YearEndGeneralLedgerPendingEntriesService#generateYearEndGeneralLedgerPendingEntries(org.kuali.kfs.sys.document.AccountingDocumentBase, java.lang.String, java.util.List, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.util.Collection)
 */
@Override
public boolean generateYearEndGeneralLedgerPendingEntries(AccountingDocumentBase document, String documentTypeCode, List<AccountingLine> accountingLines, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Collection<String> closingCharts) {
    Integer fiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
    List<String> nominalActivityObjectTypeCodes = objectTypeService.getNominalActivityClosingAllowedObjectTypes(fiscalYear);
    List<String> balanceForwardObjectTypeCodes = objectTypeService.getGeneralForwardBalanceObjectTypes(fiscalYear);
    List<String> expenseObjectCodeTypes = objectTypeService.getExpenseObjectTypes(fiscalYear);
    List<String> incomeObjectCodeTypes = objectTypeService.getBasicIncomeObjectTypes(fiscalYear);
    Map<String, AccountingLine> incomeAccounts = new HashMap<String, AccountingLine>();
    Map<String, AccountingLine> expenseAccounts = new HashMap<String, AccountingLine>();
    List<AccountingLine> bbAccounts = new ArrayList<AccountingLine>();
    Map<String, AccountingLine> accountCredit = new HashMap<String, AccountingLine>();
    Map<String, AccountingLine> accountDebit = new HashMap<String, AccountingLine>();
    for (AccountingLine accountingLine : accountingLines) {
        if (ObjectUtils.isNull(closingCharts) || closingCharts.isEmpty()) {
        // do nothing
        } else {
            if (closingCharts.contains(accountingLine.getChartOfAccountsCode())) {
                // BB
                if (balanceForwardObjectTypeCodes.contains(accountingLine.getFinancialObjectCode()) && accountingLine.getAmount().isNonZero()) {
                    bbAccounts.add(accountingLine);
                }
                // get the expense accounts
                if (expenseObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
                    String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
                    if (expenseAccounts.containsKey(accountKey)) {
                        KualiDecimal expense = expenseAccounts.get(accountKey).getAmount();
                        KualiDecimal amount = accountingLine.getAmount();
                        // Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
                        if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                            amount = amount.negated();
                        }
                        expenseAccounts.get(accountKey).setAmount(expense.add(amount));
                        expenseAccounts.put(accountKey, expenseAccounts.get(accountKey));
                    } else {
                        KualiDecimal expense = accountingLine.getAmount();
                        // Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
                        if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                            expense = expense.negated();
                        }
                        SourceAccountingLine expenseAcctLine = new SourceAccountingLine();
                        expenseAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
                        expenseAcctLine.setAccountNumber(accountingLine.getAccountNumber());
                        expenseAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
                        expenseAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
                        expenseAcctLine.setProjectCode(accountingLine.getProjectCode());
                        expenseAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
                        expenseAcctLine.setAmount(expense);
                        expenseAccounts.put(accountKey, expenseAcctLine);
                    }
                } else if (incomeObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
                    // get income
                    String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
                    if (incomeAccounts.containsKey(accountKey)) {
                        KualiDecimal income = incomeAccounts.get(accountKey).getAmount();
                        KualiDecimal amount = accountingLine.getAmount();
                        // Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
                        if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                            amount = amount.negated();
                        }
                        incomeAccounts.get(accountKey).setAmount(income.add(amount));
                        incomeAccounts.put(accountKey, incomeAccounts.get(accountKey));
                    } else {
                        KualiDecimal income = accountingLine.getAmount();
                        // Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
                        if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                            income = income.negated();
                        }
                        SourceAccountingLine incomeAcctLine = new SourceAccountingLine();
                        incomeAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
                        incomeAcctLine.setAccountNumber(accountingLine.getAccountNumber());
                        incomeAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
                        incomeAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
                        incomeAcctLine.setProjectCode(accountingLine.getProjectCode());
                        incomeAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
                        incomeAcctLine.setAmount(income);
                        incomeAccounts.put(accountKey, incomeAcctLine);
                    }
                }
                // credit
                if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                    String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
                    if (accountCredit.containsKey(accountKey)) {
                        KualiDecimal credit = accountCredit.get(accountKey).getAmount();
                        KualiDecimal amount = accountingLine.getAmount();
                        accountCredit.get(accountKey).setAmount(credit.add(amount));
                        accountCredit.put(accountKey, accountCredit.get(accountKey));
                    } else {
                        KualiDecimal credit = accountingLine.getAmount();
                        SourceAccountingLine creditAcctLine = new SourceAccountingLine();
                        creditAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
                        creditAcctLine.setAccountNumber(accountingLine.getAccountNumber());
                        creditAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
                        creditAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
                        creditAcctLine.setProjectCode(accountingLine.getProjectCode());
                        creditAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
                        creditAcctLine.setAmount(credit);
                        accountCredit.put(accountKey, creditAcctLine);
                    }
                }
                // debit
                if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
                    String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
                    if (accountDebit.containsKey(accountKey)) {
                        KualiDecimal debit = accountDebit.get(accountKey).getAmount();
                        KualiDecimal amount = accountingLine.getAmount();
                        accountDebit.get(accountKey).setAmount(debit.add(amount));
                        accountDebit.put(accountKey, accountDebit.get(accountKey));
                    } else {
                        KualiDecimal debit = accountingLine.getAmount();
                        SourceAccountingLine debitAcctLine = new SourceAccountingLine();
                        debitAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
                        debitAcctLine.setAccountNumber(accountingLine.getAccountNumber());
                        debitAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
                        debitAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
                        debitAcctLine.setProjectCode(accountingLine.getProjectCode());
                        debitAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
                        debitAcctLine.setAmount(debit);
                        accountDebit.put(accountKey, debitAcctLine);
                    }
                }
            }
        }
        // create gl entries
        // create NB 4490 income entry and 3190 offset
        List<GeneralLedgerPendingEntry> entries = createPendingEntries(document, accountingLine, sequenceHelper, closingCharts, fiscalYear);
        for (GeneralLedgerPendingEntry entry : entries) {
            document.addPendingEntry(entry);
        }
    }
    Set<String> incomeExpenseSet = new HashSet<String>();
    incomeExpenseSet.addAll(incomeAccounts.keySet());
    incomeExpenseSet.addAll(expenseAccounts.keySet());
    // create BB income - expense 3190 entry
    for (String accountKey : incomeExpenseSet) {
        KualiDecimal income = KualiDecimal.ZERO;
        KualiDecimal expense = KualiDecimal.ZERO;
        AccountingLine acctLine = ObjectUtils.isNull(incomeAccounts.get(accountKey)) ? expenseAccounts.get(accountKey) : incomeAccounts.get(accountKey);
        if (ObjectUtils.isNotNull(incomeAccounts.get(accountKey))) {
            income = incomeAccounts.get(accountKey).getAmount();
        }
        if (ObjectUtils.isNotNull(expenseAccounts.get(accountKey))) {
            expense = expenseAccounts.get(accountKey).getAmount();
        }
        KualiDecimal amount = income.subtract(expense);
        acctLine.setAmount(amount);
        if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
            document.addPendingEntry(generateBBIncomeLessExpenseOffset(document, acctLine, sequenceHelper.getSequenceCounter(), fiscalYear));
            sequenceHelper.increment();
        }
    }
    Set<String> creditDebitSet = new HashSet<String>();
    creditDebitSet.addAll(accountCredit.keySet());
    creditDebitSet.addAll(accountDebit.keySet());
    // create 1000 cash offset entry for remaining cash = credit - debit
    for (String accountKey : creditDebitSet) {
        KualiDecimal credit = KualiDecimal.ZERO;
        KualiDecimal debit = KualiDecimal.ZERO;
        AccountingLine acctLine = ObjectUtils.isNull(accountCredit.get(accountKey)) ? accountDebit.get(accountKey) : accountCredit.get(accountKey);
        if (ObjectUtils.isNotNull(accountCredit.get(accountKey))) {
            credit = accountCredit.get(accountKey).getAmount();
        }
        if (ObjectUtils.isNotNull(accountDebit.get(accountKey))) {
            debit = accountDebit.get(accountKey).getAmount();
        }
        KualiDecimal amount = credit.subtract(debit);
        acctLine.setAmount(amount);
        if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
            document.addPendingEntry(generateBBCashOffset(document, acctLine, sequenceHelper.getSequenceCounter(), documentTypeCode, fiscalYear));
            sequenceHelper.increment();
        }
    }
    return true;
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) HashMap(java.util.HashMap) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) ArrayList(java.util.ArrayList) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) HashSet(java.util.HashSet)

Example 18 with GeneralLedgerPendingEntry

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateCGBalanceForwardPendingEntry.

/**
 * Generates the CG Balance Forward entry.
 *
 * @param document
 * @param postable
 * @param sequenceNumber
 * @param fiscalYear
 * @return The GL pending entry
 */
public GeneralLedgerPendingEntry generateCGBalanceForwardPendingEntry(AccountingDocumentBase document, AccountingLine postable, Integer sequenceNumber, Integer fiscalYear) {
    /*
         * Much of the code below was copied from BalanceForwardRuleHelper.generateCumulativeForwardOriginEntry,
         * and adapted for generating a YEJV GL pending entry instead of a full origin entry.
         */
    GeneralLedgerPendingEntry entry = new GeneralLedgerPendingEntry();
    // Populate a temporary OriginEntryFull object so that we can use the FlexibleOffsetAccountService functionality.
    OriginEntryFull originEntry = new OriginEntryFull();
    originEntry.setUniversityFiscalYear(new Integer(fiscalYear + 1));
    originEntry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
    originEntry.setAccountNumber(postable.getAccountNumber());
    originEntry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
    originEntry.setFinancialObjectCode(postable.getFinancialObjectCode());
    originEntry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
    originEntry.setFinancialBalanceTypeCode(postable.getBalanceTypeCode());
    originEntry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
    // Use the FlexibleOffsetAccountService to make updates as needed.
    try {
        getFlexibleOffsetAccountService().updateOffset(originEntry);
    } catch (InvalidFlexibleOffsetException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("generateCGBalanceForwardPendingEntry() Balance Forward Flexible Offset Error: " + e.getMessage());
        }
    }
    // Copy the potentially-changed data into the GL pending entry accordingly.
    entry.setUniversityFiscalYear(originEntry.getUniversityFiscalYear());
    entry.setChartOfAccountsCode(originEntry.getChartOfAccountsCode());
    entry.setAccountNumber(originEntry.getAccountNumber());
    entry.setSubAccountNumber(originEntry.getSubAccountNumber());
    entry.setFinancialObjectCode(originEntry.getFinancialObjectCode());
    entry.setFinancialSubObjectCode(originEntry.getFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(originEntry.getFinancialBalanceTypeCode());
    entry.setFinancialObjectTypeCode(originEntry.getFinancialObjectTypeCode());
    // Continue with regular setup.
    entry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE);
    entry.setFinancialDocumentTypeCode(document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    entry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    entry.setDocumentNumber(new StringBuilder(KFSConstants.BALANCE_TYPE_ACTUAL).append(postable.getAccountNumber()).toString());
    entry.setTransactionLedgerEntrySequenceNumber(sequenceNumber);
    entry.setTransactionLedgerEntryDescription(new StringBuilder("BEG C & G BAL BROUGHT FORWARD FROM ").append(fiscalYear).toString());
    entry.setTransactionLedgerEntryAmount(postable.getAmount());
    if (KFSConstants.BALANCE_TYPE_CURRENT_BUDGET.equals(postable.getBalanceTypeCode()) || KFSConstants.BALANCE_TYPE_BASE_BUDGET.equals(postable.getBalanceTypeCode())) {
        entry.setTransactionDebitCreditCode(null);
    } else {
        entry.setTransactionDebitCreditCode(postable.getDebitCreditCode());
    }
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    entry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    entry.setOrganizationDocumentNumber(null);
    entry.setProjectCode(KFSConstants.getDashProjectCode());
    entry.setOrganizationReferenceId(null);
    entry.setReferenceFinancialDocumentNumber(null);
    entry.setReferenceFinancialSystemOriginationCode(null);
    entry.setReferenceFinancialDocumentNumber(null);
    entry.setFinancialDocumentReversalDate(null);
    String transactionEncumbranceUpdateCode = KFSConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD;
    entry.setTransactionEncumbranceUpdateCode(transactionEncumbranceUpdateCode);
    if (KFSConstants.BALANCE_TYPE_AUDIT_TRAIL.equals(postable.getBalanceTypeCode())) {
        entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    }
    if (entry.getTransactionLedgerEntryAmount().isNegative()) {
        if (KFSConstants.BALANCE_TYPE_ACTUAL.equals(entry.getFinancialBalanceTypeCode())) {
            entry.setTransactionLedgerEntryAmount(entry.getTransactionLedgerEntryAmount().negated());
        }
    }
    return entry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) InvalidFlexibleOffsetException(org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException) Timestamp(java.sql.Timestamp) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 19 with GeneralLedgerPendingEntry

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateBBIncomeLessExpenseOffset.

/**
 * Generates the BB income less expense glpe.
 *
 * @param document
 * @param accountingLine
 * @param sequenceNumber
 * @param fiscalYear
 * @return the generated glpe
 */
public GeneralLedgerPendingEntry generateBBIncomeLessExpenseOffset(AccountingDocumentBase document, AccountingLine accountingLine, 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);
    Integer closingFiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry();
    offsetEntry.setUniversityFiscalYear(fiscalYear + 1);
    offsetEntry.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
    offsetEntry.setAccountNumber(accountingLine.getAccountNumber());
    offsetEntry.setSubAccountNumber(StringUtils.isBlank(accountingLine.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : accountingLine.getSubAccountNumber());
    offsetEntry.setFinancialObjectCode(varFundBalanceObjectCode);
    offsetEntry.setFinancialSubObjectCode(StringUtils.isBlank(accountingLine.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : accountingLine.getFinancialSubObjectCode());
    offsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    offsetEntry.setFinancialObjectTypeCode(varFundBalanceObjectTypeCode);
    offsetEntry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
    offsetEntry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    offsetEntry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    offsetEntry.setDocumentNumber(document.getDocumentNumber());
    offsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceNumber.intValue()));
    offsetEntry.setTransactionLedgerEntryDescription(new StringBuffer("BEG BAL BROUGHT FORWARD FROM ").append(closingFiscalYear).toString());
    offsetEntry.setTransactionLedgerEntryAmount(accountingLine.getAmount());
    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(accountingLine.getProjectCode()) ? KFSConstants.getDashProjectCode() : accountingLine.getProjectCode());
    offsetEntry.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
    offsetEntry.setReferenceFinancialDocumentTypeCode(null);
    offsetEntry.setReferenceFinancialSystemOriginationCode(null);
    offsetEntry.setReferenceFinancialDocumentNumber(null);
    offsetEntry.setFinancialDocumentReversalDate(null);
    offsetEntry.setTransactionEncumbranceUpdateCode(null);
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    } else {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    }
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionLedgerEntryAmount(accountingLine.getAmount().negated());
    }
    return offsetEntry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) Timestamp(java.sql.Timestamp)

Example 20 with GeneralLedgerPendingEntry

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

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateBBCashOffset.

/**
 * Generates the BB cash offset.
 *
 * @param document
 * @param accountingLine
 * @param sequenceNumber
 * @param documentTypeCode
 * @param fiscalYear
 * @return the generated glpe
 */
public GeneralLedgerPendingEntry generateBBCashOffset(AccountingDocumentBase document, AccountingLine accountingLine, Integer sequenceNumber, String documentTypeCode, Integer fiscalYear) {
    Integer closingFiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    OffsetDefinition cashOffsetDefinition = offsetDefinitionService.getByPrimaryId(fiscalYear, accountingLine.getChartOfAccountsCode(), documentTypeCode, KFSConstants.BALANCE_TYPE_ACTUAL);
    ObjectCode cashObjectCode = cashOffsetDefinition.getFinancialObject();
    String cashOffsetObjectCode = cashOffsetDefinition.getFinancialObjectCode();
    String debitCreditCode = null;
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry();
    offsetEntry.setUniversityFiscalYear(fiscalYear + 1);
    offsetEntry.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
    offsetEntry.setAccountNumber(accountingLine.getAccountNumber());
    offsetEntry.setSubAccountNumber(StringUtils.isBlank(accountingLine.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : accountingLine.getSubAccountNumber());
    offsetEntry.setFinancialObjectCode(cashOffsetObjectCode);
    offsetEntry.setFinancialSubObjectCode(StringUtils.isBlank(accountingLine.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : accountingLine.getFinancialSubObjectCode());
    offsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    offsetEntry.setFinancialObjectTypeCode(cashObjectCode.getFinancialObjectTypeCode());
    offsetEntry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
    offsetEntry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    offsetEntry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    offsetEntry.setDocumentNumber(document.getDocumentNumber());
    offsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceNumber.intValue()));
    offsetEntry.setTransactionLedgerEntryDescription("BEG BAL BROUGHT FORWARD FROM " + closingFiscalYear);
    offsetEntry.setTransactionLedgerEntryAmount(accountingLine.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(accountingLine.getProjectCode()) ? KFSConstants.getDashProjectCode() : accountingLine.getProjectCode());
    offsetEntry.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
    offsetEntry.setReferenceFinancialDocumentTypeCode(null);
    offsetEntry.setReferenceFinancialSystemOriginationCode(null);
    offsetEntry.setReferenceFinancialDocumentNumber(null);
    offsetEntry.setFinancialDocumentReversalDate(null);
    offsetEntry.setTransactionEncumbranceUpdateCode(null);
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    } else {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    }
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionLedgerEntryAmount(accountingLine.getAmount().negated());
    }
    return offsetEntry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) Timestamp(java.sql.Timestamp)

Aggregations

GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)25 Timestamp (java.sql.Timestamp)6 ArrayList (java.util.ArrayList)6 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)6 HashMap (java.util.HashMap)4 List (java.util.List)3 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)3 SystemOptions (org.kuali.kfs.sys.businessobject.SystemOptions)3 PaymentMethodChart (edu.cornell.kfs.fp.businessobject.PaymentMethodChart)2 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 Date (java.sql.Date)2 Map (java.util.Map)2 Account (org.kuali.kfs.coa.businessobject.Account)2 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)2 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)2 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)2 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)2 GeneralLedgerPostingDocument (org.kuali.kfs.sys.document.GeneralLedgerPostingDocument)2 GeneralLedgerPendingEntryService (org.kuali.kfs.sys.service.GeneralLedgerPendingEntryService)2 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)2