Search in sources :

Example 11 with GeneralLedgerPendingEntry

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

the class CuPreEncumbranceActionTest method setTabStatesHasGLPEs.

@Test
public void setTabStatesHasGLPEs() throws Exception {
    List<GeneralLedgerPendingEntry> generalLedgerPendingEntries = new ArrayList<>();
    generalLedgerPendingEntries.add(new GeneralLedgerPendingEntry());
    generalLedgerPendingEntries.add(new GeneralLedgerPendingEntry());
    preEncumbranceDocument.setGeneralLedgerPendingEntries(generalLedgerPendingEntries);
    cuPreEncumbranceAction.setTabStates(kualiAccountingDocumentFormBase);
    Assert.assertFalse("TabStates should NOT be empty", kualiAccountingDocumentFormBase.getTabStates().isEmpty());
    Assert.assertEquals("General Ledger Pending Entries tab should be OPEN", "OPEN", kualiAccountingDocumentFormBase.getTabState("GeneralLedgerPendingEntries"));
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with GeneralLedgerPendingEntry

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

the class CuGeneralLedgerPendingEntryServiceImplTest method testFillinForNullFiscalYrPeriod.

/*
     * test fill in current fiscal year/period for for Null fiscal year/period
     * 
     */
public void testFillinForNullFiscalYrPeriod() {
    GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
    cuGeneralLedgerPendingEntryService.fillInFiscalPeriodYear(glpe);
    assertTrue("should fill in fiscal year", ud.getUniversityFiscalYear().equals(glpe.getUniversityFiscalYear()));
    assertTrue("should fill in fiscal period code", StringUtils.equals(ud.getUniversityFiscalAccountingPeriod(), glpe.getUniversityFiscalPeriodCode()));
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)

Example 13 with GeneralLedgerPendingEntry

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

the class CuGeneralLedgerPendingEntryServiceImplTest method testFillinFiscalYrPeriodForPCDOInInactiveFiscalYrPeriod.

public void testFillinFiscalYrPeriodForPCDOInInactiveFiscalYrPeriod() {
    GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
    glpe.setFinancialDocumentTypeCode(KFSConstants.FinancialDocumentTypeCodes.PROCUREMENT_CARD);
    glpe.setUniversityFiscalYear(2012);
    glpe.setUniversityFiscalPeriodCode("01");
    // 2012/01 is an inactive period; so it should be set to current fiscal yr/period for PCDO
    cuGeneralLedgerPendingEntryService.fillInFiscalPeriodYear(glpe);
    assertTrue("should fill in fiscal year", ud.getUniversityFiscalYear().equals(glpe.getUniversityFiscalYear()));
    assertTrue("should fill in fiscal period code", StringUtils.equals(ud.getUniversityFiscalAccountingPeriod(), glpe.getUniversityFiscalPeriodCode()));
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)

Example 14 with GeneralLedgerPendingEntry

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

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFinalEntriesForPRNC.

/**
 * Creates final entries for PRNC doc: Reverse all usage 2900 object codes Replaces with 1000 offset object code Generate
 * Bank Offsets for total amounts
 *
 * @see edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService#generateFinalEntriesForPRNC(org.kuali.kfs.module.purap.document.PaymentRequestDocument)
 */
public void generateFinalEntriesForPRNC(PaymentRequestDocument document) {
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(document.getDocumentNumber()));
    String documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_NON_CHECK;
    if (PaymentMethod.PM_CODE_INTERNAL_BILLING.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_INTERNAL_BILLING;
    }
    // generate bank offset
    if (PaymentMethod.PM_CODE_FOREIGN_DRAFT.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode()) || PaymentMethod.PM_CODE_WIRE.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        generateDocumentBankOffsetEntries((AccountingDocument) document, document.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", documentType, sequenceHelper, document.getTotalDollarAmount().negated());
    }
    // check for balance type Actual offset pending entries and replace the object code with chart cash object code (currently replacing object code 2900 with 1000)
    List<GeneralLedgerPendingEntry> glpes = document.getGeneralLedgerPendingEntries();
    for (GeneralLedgerPendingEntry glpe : glpes) {
        OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glpe.getUniversityFiscalYear(), glpe.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
        if (glpe.getFinancialObjectCode().equalsIgnoreCase(offsetDefinition.getFinancialObjectCode())) {
            if (ObjectUtils.isNull(glpe.getChart())) {
                glpe.refreshReferenceObject(KFSPropertyConstants.CHART);
            }
            glpe.setFinancialObjectCode(glpe.getChart().getFinancialCashObjectCode());
            glpe.refreshReferenceObject(KFSPropertyConstants.FINANCIAL_OBJECT);
            glpe.setFinancialObjectTypeCode(glpe.getFinancialObject().getFinancialObjectTypeCode());
        }
    }
    // reverse 2900
    // check for posted entries and create reverse pending entries
    // get all charts on document
    List<AccountingLine> accountingLines = new ArrayList<AccountingLine>();
    if (ObjectUtils.isNotNull(document.getSourceAccountingLines())) {
        accountingLines.addAll(document.getSourceAccountingLines());
    }
    if (ObjectUtils.isNotNull(document.getTargetAccountingLines())) {
        accountingLines.addAll(document.getTargetAccountingLines());
    }
    Map<String, String> chartOffsets = new HashMap<String, String>();
    if (accountingLines.size() > 0) {
        for (AccountingLine accountingLine : accountingLines) {
            if (!chartOffsets.containsKey(accountingLine.getChartOfAccountsCode())) {
                OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(accountingLine.getPostingYear(), accountingLine.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
                chartOffsets.put(accountingLine.getChartOfAccountsCode(), offsetDefinition.getFinancialObjectCode());
            }
        }
    }
    for (String offsetObjectCode : chartOffsets.values()) {
        Collection<Entry> glEntries = findMatchingGLEntries(document, offsetObjectCode);
        if (glEntries != null && glEntries.size() > 0) {
            for (Entry entry : glEntries) {
                // create reversal
                GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
                boolean debit = KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(entry.getTransactionDebitCreditCode());
                glpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getFinancialObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
                glpe.setFinancialDocumentTypeCode(documentType);
                document.addPendingEntry(glpe);
                sequenceHelper.increment();
                // create cash entry
                GeneralLedgerPendingEntry cashGlpe = new GeneralLedgerPendingEntry();
                cashGlpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getChart().getFinancialCashObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), !debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
                cashGlpe.setFinancialDocumentTypeCode(documentType);
                document.addPendingEntry(cashGlpe);
                sequenceHelper.increment();
            }
        }
    }
    if (document.getGeneralLedgerPendingEntries() != null && document.getGeneralLedgerPendingEntries().size() > 0) {
        for (GeneralLedgerPendingEntry glpe : document.getGeneralLedgerPendingEntries()) {
            glpe.setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
        }
    }
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) Entry(org.kuali.kfs.gl.businessobject.Entry) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService)

Example 15 with GeneralLedgerPendingEntry

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

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateDocumentBankOffsetEntries.

/**
 * If bank specification is enabled generates bank offsetting entries for the document amount
 */
public boolean generateDocumentBankOffsetEntries(AccountingDocument document, String bankCode, String bankCodePropertyName, String documentTypeCode, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, KualiDecimal bankOffsetAmount) {
    boolean success = true;
    if (!getBankService().isBankSpecificationEnabled()) {
        return success;
    }
    Bank bank = getBankService().getByPrimaryId(bankCode);
    if (bankOffsetAmount == null) {
        bankOffsetAmount = getGeneralLedgerPendingEntryService().getOffsetToCashAmount(document).negated();
    }
    if (!KualiDecimal.ZERO.equals(bankOffsetAmount)) {
        GeneralLedgerPendingEntry bankOffsetEntry = new GeneralLedgerPendingEntry();
        success &= getGeneralLedgerPendingEntryService().populateBankOffsetGeneralLedgerPendingEntry(bank, bankOffsetAmount, document, document.getPostingYear(), sequenceHelper, bankOffsetEntry, bankCodePropertyName);
        if (success) {
            AccountingDocumentRuleHelperService accountingDocumentRuleUtil = SpringContext.getBean(AccountingDocumentRuleHelperService.class);
            bankOffsetEntry.setTransactionLedgerEntryDescription(accountingDocumentRuleUtil.formatProperty(KFSKeyConstants.Bank.DESCRIPTION_GLPE_BANK_OFFSET));
            bankOffsetEntry.setFinancialDocumentTypeCode(documentTypeCode);
            document.addPendingEntry(bankOffsetEntry);
            sequenceHelper.increment();
            GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(bankOffsetEntry);
            success &= getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), bankOffsetEntry, sequenceHelper, offsetEntry);
            bankOffsetEntry.setFinancialDocumentTypeCode(documentTypeCode);
            document.addPendingEntry(offsetEntry);
            sequenceHelper.increment();
        }
    }
    return success;
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) AccountingDocumentRuleHelperService(org.kuali.kfs.sys.document.service.AccountingDocumentRuleHelperService)

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