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 CuPurapGeneralLedgerServiceImpl method getNextAvailableSequence.
protected int getNextAvailableSequence(String documentNumber) {
LOG.debug("getNextAvailableSequence() started");
Map fieldValues = new HashMap();
fieldValues.put("financialSystemOriginationCode", PURAP_ORIGIN_CODE);
fieldValues.put("documentNumber", documentNumber);
List<GeneralLedgerPendingEntry> glpes = (List<GeneralLedgerPendingEntry>) SpringContext.getBean(org.kuali.kfs.krad.service.BusinessObjectService.class).findMatching(GeneralLedgerPendingEntry.class, fieldValues);
// KFSPTS-2632 : Bankoffset will not be posted by nightly batch job because its status is 'N'.
// so, we need to find the highest transactionsequence. Otherwise it may cause OLE
int count = 0;
if (CollectionUtils.isNotEmpty(glpes)) {
for (GeneralLedgerPendingEntry glpe : glpes) {
if (glpe.getTransactionLedgerEntrySequenceNumber() > count) {
count = glpe.getTransactionLedgerEntrySequenceNumber();
}
}
}
return count + 1;
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method getNextAvailableSequence.
/**
* Retrieves the next available sequence number from the general ledger pending entry table for this document
*
* @param documentNumber
* Document number to find next sequence number
* @return Next available sequence number
*/
protected int getNextAvailableSequence(String documentNumber) {
LOG.debug("getNextAvailableSequence() started");
Map fieldValues = new HashMap();
fieldValues.put("financialSystemOriginationCode", PURAP_ORIGIN_CODE);
fieldValues.put("documentNumber", documentNumber);
List<GeneralLedgerPendingEntry> glpes = (List<GeneralLedgerPendingEntry>) (SpringContext.getBean(BusinessObjectService.class)).findMatching(GeneralLedgerPendingEntry.class, fieldValues);
int count = 0;
if (CollectionUtils.isNotEmpty(glpes)) {
for (GeneralLedgerPendingEntry glpe : glpes) {
if (glpe.getTransactionLedgerEntrySequenceNumber() > count) {
count = glpe.getTransactionLedgerEntrySequenceNumber();
}
}
}
return count + 1;
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateClearingAccountOffsetEntries.
/**
* When the "A" payment method is used for AP Credit Cards - generate the needed entries in the clearing account.
*
* @param document Document into which to add the generated GL Entries.
* @param sequenceHelper helper class to keep track of GLPE sequence
*/
public boolean generateClearingAccountOffsetEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Map<String, KualiDecimal> actualTotalsByChart) {
if (actualTotalsByChart == null) {
actualTotalsByChart = getNonOffsetActualTotalsByChart(document);
}
for (String chart : actualTotalsByChart.keySet()) {
KualiDecimal offsetAmount = actualTotalsByChart.get(chart);
if (!KualiDecimal.ZERO.equals(offsetAmount)) {
PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(chart, new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
if (pmc == null) {
LOG.warn("No Applicable PaymentMethodChart found for chart: " + chart + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
// skip this line - still attempt for other charts
continue;
}
String clearingChartCode = pmc.getClearingChartOfAccountsCode();
String clearingAccountNumber = pmc.getClearingAccountNumber();
// liability object code
String clearingObjectCode = pmc.getClearingFinancialObjectCode();
GeneralLedgerPendingEntry apOffsetEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
apOffsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceHelper.getSequenceCounter()));
apOffsetEntry.setChartOfAccountsCode(clearingChartCode);
apOffsetEntry.setAccountNumber(clearingAccountNumber);
apOffsetEntry.setFinancialObjectCode(clearingObjectCode);
// if internal billing
if (StringUtils.equals(PaymentMethod.PM_CODE_INTERNAL_BILLING, pm.getPaymentMethodCode())) {
apOffsetEntry.setFinancialSubObjectCode(pmc.getClearingFinancialSubObjectCode());
apOffsetEntry.setSubAccountNumber(pmc.getClearingSubAccountNumber());
} else {
apOffsetEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
apOffsetEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
}
apOffsetEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
// retrieve object type
ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(clearingChartCode, clearingObjectCode);
if (objectCode == null) {
LOG.fatal("Specified offset object code: " + clearingChartCode + "-" + clearingObjectCode + " does not exist - failed to generate CC offset entries", new RuntimeException());
return false;
}
apOffsetEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
apOffsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
apOffsetEntry.setTransactionDebitCreditCode(offsetAmount.isNegative() ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
apOffsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
document.addPendingEntry(apOffsetEntry);
sequenceHelper.increment();
// handle the offset entry
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(apOffsetEntry);
getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), apOffsetEntry, sequenceHelper, offsetEntry);
document.addPendingEntry(offsetEntry);
sequenceHelper.increment();
}
}
return true;
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method updateGLPEDatesAndAddRecurringDocumentLinks.
private void updateGLPEDatesAndAddRecurringDocumentLinks(DisbursementVoucherDocument dv, String recurringDisbursemntVoucherDocumentNumber) {
for (GeneralLedgerPendingEntry glpe : dv.getGeneralLedgerPendingEntries()) {
glpe.setTransactionDate(dv.getDisbursementVoucherDueDate());
glpe.setReferenceFinancialDocumentTypeCode(CuFPConstants.RecurringDisbursementVoucherDocumentConstants.RECURRING_DV_DOCUMENT_TYPE_NAME);
glpe.setReferenceFinancialDocumentNumber(recurringDisbursemntVoucherDocumentNumber);
AccountingPeriod ap = getAccountingPeriodService().getByDate(dv.getDisbursementVoucherDueDate());
glpe.setAccountingPeriod(ap);
glpe.setUniversityFiscalPeriodCode(ap.getUniversityFiscalPeriodCode());
glpe.setUniversityFiscalYear(ap.getUniversityFiscalYear());
getBusinessObjectService().save(glpe);
}
}
Aggregations