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);
}
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"));
}
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()));
}
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()));
}
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;
}
Aggregations