Search in sources :

Example 1 with GeneralLedgerPendingEntry

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

the class PreEncumbranceDocument method processExplicitGeneralLedgerPendingEntry.

/**
 * This method processes all necessary information to build an explicit general ledger entry, and then adds that to the
 * document.
 *
 * @param accountingDocument
 * @param sequenceHelper
 * @param accountingLine
 * @param explicitEntry
 * @return boolean True if the explicit entry generation was successful, false otherwise.
 */
@Override
protected void processExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntrySourceDetail glpeSourceDetail, GeneralLedgerPendingEntry explicitEntry) {
    if (glpeSourceDetail instanceof PreEncumbranceSourceAccountingLine) {
        int rowId = ((AccountingLine) glpeSourceDetail).getSequenceNumber() - 1;
        PreEncumbranceSourceAccountingLine pesal = (PreEncumbranceSourceAccountingLine) glpeSourceDetail;
        if (ObjectUtils.isNotNull(pesal.getAutoDisEncumberType())) {
            if (ObjectUtils.isNull(pesal.getStartDate()) || ObjectUtils.isNull(pesal.getPartialTransactionCount()) || ObjectUtils.isNull(pesal.getPartialAmount())) {
                throw new ValidationException("Insufficient information for GLPE generation");
            }
            Date generatedEndDate = PreEncumbranceAccountingLineUtil.generateEndDate(pesal.getStartDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAutoDisEncumberType());
            pesal.setEndDate(generatedEndDate);
            TreeMap<Date, KualiDecimal> datesAndAmounts = PreEncumbranceAccountingLineUtil.generateDatesAndAmounts(pesal.getAutoDisEncumberType(), pesal.getStartDate(), pesal.getEndDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAmount(), pesal.getPartialAmount(), rowId);
            Iterator<Date> it = datesAndAmounts.keySet().iterator();
            boolean isErrorCorrection = false;
            Date today = new Date(Calendar.getInstance().getTimeInMillis());
            if (pesal.getAmount().isNegative()) {
                // we are doing error correction
                LOG.info("Error correction!");
                isErrorCorrection = true;
            }
            while (it.hasNext()) {
                Date revDate = it.next();
                if (isErrorCorrection && revDate.before(today)) {
                    break;
                }
                KualiDecimal partialAmount = datesAndAmounts.get(revDate);
                GeneralLedgerPendingEntry explicitPartialEntry = new GeneralLedgerPendingEntry();
                SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitPartialEntry);
                explicitPartialEntry.setFinancialDocumentReversalDate(revDate);
                explicitPartialEntry.setTransactionLedgerEntryAmount(isErrorCorrection ? partialAmount.negated() : partialAmount);
                customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitPartialEntry);
                addPendingEntry(explicitPartialEntry);
                sequenceHelper.increment();
                GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitPartialEntry);
                processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitPartialEntry, offsetEntry);
                sequenceHelper.increment();
            }
            // no need to do the following stuff, as we're generating a bunch of custom GL pending entries above
            return;
        }
    }
    // populate the explicit entry
    SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitEntry);
    // hook for children documents to implement document specific GLPE field mappings
    customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitEntry);
    addPendingEntry(explicitEntry);
    sequenceHelper.increment();
    // handle the offset entry
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitEntry);
    boolean success = processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitEntry, offsetEntry);
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) PreEncumbranceSourceAccountingLine(edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine) GeneralLedgerPendingEntryService(org.kuali.kfs.sys.service.GeneralLedgerPendingEntryService) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Date(java.sql.Date)

Example 2 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 3 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 4 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 5 with GeneralLedgerPendingEntry

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

the class FinancialSystemSearchableAttribute method getSearchingRows.

@Override
protected List<Row> getSearchingRows(String documentTypeName) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getSearchingRows( " + documentTypeName + " )");
        if (LOG.isTraceEnabled()) {
            LOG.trace("Stack Trace at point of call", new Throwable());
        }
    }
    List<Row> docSearchRows = super.getSearchingRows(documentTypeName);
    // add account number search field when selected document type is COA
    if (StringUtils.isNotEmpty(documentTypeName)) {
        if (CUKFSConstants.COA_DOCUMENT_TYPE.equalsIgnoreCase(documentTypeName)) {
            Field accountField = FieldUtils.getPropertyField(Account.class, KFSPropertyConstants.ACCOUNT_NUMBER, true);
            accountField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            accountField.setColumnVisible(true);
            docSearchRows.add(new Row(Collections.singletonList(accountField)));
        }
    }
    DocumentEntry entry = SpringContext.getBean(DocumentDictionaryService.class).getDocumentEntry(documentTypeName);
    if (entry != null) {
        Class<? extends Document> docClass = entry.getDocumentClass();
        if (AccountingDocument.class.isAssignableFrom(docClass)) {
            Map<String, AccountingLineGroupDefinition> alGroups = ((FinancialSystemTransactionalDocumentEntry) entry).getAccountingLineGroups();
            Class alClass = SourceAccountingLine.class;
            if (ObjectUtils.isNotNull(alGroups)) {
                if (alGroups.containsKey("source")) {
                    alClass = alGroups.get("source").getAccountingLineClass();
                }
            }
            BusinessObject alBusinessObject;
            try {
                alBusinessObject = (BusinessObject) alClass.newInstance();
            } catch (Exception cnfe) {
                throw new RuntimeException("Unable to instantiate accounting line class: " + alClass, cnfe);
            }
            Field chartField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, true);
            chartField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            chartField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartField, Collections.singletonList(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE));
            docSearchRows.add(new Row(Collections.singletonList(chartField)));
            Field orgField = FieldUtils.getPropertyField(Organization.class, KFSPropertyConstants.ORGANIZATION_CODE, true);
            orgField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            orgField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(new Account(), KFSPropertyConstants.ORGANIZATION_CODE, orgField, Collections.singletonList(KFSPropertyConstants.ORGANIZATION_CODE));
            docSearchRows.add(new Row(Collections.singletonList(orgField)));
            Field accountField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.ACCOUNT_NUMBER, true);
            accountField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            accountField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.ACCOUNT_NUMBER, accountField, Collections.singletonList(KFSPropertyConstants.ACCOUNT_NUMBER));
            docSearchRows.add(new Row(Collections.singletonList(accountField)));
        }
        boolean displayedLedgerPostingDoc = false;
        if (LaborLedgerPostingDocumentForSearching.class.isAssignableFrom(docClass)) {
            Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
            searchField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
            displayedLedgerPostingDoc = true;
        }
        if (GeneralLedgerPostingDocument.class.isAssignableFrom(docClass) && !displayedLedgerPostingDoc) {
            Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
            searchField.setFieldDataType(CoreConstants.DATA_TYPE_STRING);
            LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
        }
        if (AmountTotaling.class.isAssignableFrom(docClass)) {
            Field searchField = FieldUtils.getPropertyField(FinancialSystemDocumentHeader.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, true);
            searchField.setFieldDataType(CoreConstants.DATA_TYPE_FLOAT);
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
        }
    }
    Row resultType = createSearchResultDisplayTypeRow();
    docSearchRows.add(resultType);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Returning Rows: " + docSearchRows);
    }
    return docSearchRows;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) DocumentDictionaryService(org.kuali.kfs.datadictionary.legacy.DocumentDictionaryService) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) DocumentAttributeString(org.kuali.kfs.kew.api.document.attribute.DocumentAttributeString) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) BusinessObject(org.kuali.kfs.krad.bo.BusinessObject) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) Field(org.kuali.kfs.kns.web.ui.Field) AccountingLineGroupDefinition(org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition) FinancialSystemTransactionalDocumentEntry(org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) FinancialSystemTransactionalDocumentEntry(org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry) DocumentEntry(org.kuali.kfs.kns.datadictionary.DocumentEntry) Row(org.kuali.kfs.kns.web.ui.Row)

Aggregations

GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)28 Timestamp (java.sql.Timestamp)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)4 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)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 WireCharge (org.kuali.kfs.sys.businessobject.WireCharge)2 GeneralLedgerPostingDocument (org.kuali.kfs.sys.document.GeneralLedgerPostingDocument)2 GeneralLedgerPendingEntryService (org.kuali.kfs.sys.service.GeneralLedgerPendingEntryService)2