use of edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine 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 edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class PreEncumbranceAutoDisEncumberValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
boolean success = true;
ParameterService ps = SpringContext.getBean(ParameterService.class);
try {
DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
annualClosingDate = new Date(transactionDateFormat.parse(ps.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
// this needs to be changed
annualClosingDate.setYear(annualClosingDate.getYear() + 1);
LOG.info("Annual closing Date of: " + annualClosingDate);
} catch (ParseException e) {
LOG.error("PreEncumbrance validation nnable to parse transaction date", e);
throw new IllegalArgumentException("Unable to parse transaction date");
}
PreEncumbranceDocument ped = (PreEncumbranceDocument) getAccountingDocumentForValidation();
Iterator<PreEncumbranceSourceAccountingLine> it = ped.getSourceAccountingLines().iterator();
while (it.hasNext()) {
PreEncumbranceSourceAccountingLine pesal = it.next();
auto = true;
if (checkMinimumRequirements(pesal) && auto) {
success &= checkDates(pesal);
success &= checkGenerationValidity(pesal);
} else {
if (auto) {
success &= false;
}
}
}
return success;
}
Aggregations