use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountExtractPdpEntryServiceImpl method cleanAccountingEntriesInDetailEntry.
protected void cleanAccountingEntriesInDetailEntry(PdpFeedDetailEntry newDetailEntry) {
Map<DebitCreditTotal, KualiDecimal> totals = calculateTotals(newDetailEntry);
KualiDecimal originalDebitTotal = totals.get(DebitCreditTotal.DEBIT);
KualiDecimal originalCreditTotal = totals.get(DebitCreditTotal.CREDIT);
if (areThereMoreCreditsThanDebits(originalDebitTotal, originalCreditTotal)) {
LOG.info("cleanAccountingEntriesInDetailEntry, credits are greater than or equal to debits, so removing PDP transactions");
newDetailEntry.getAccounting().clear();
} else if (shouldDeductCreditsFromDebits(originalDebitTotal, originalCreditTotal)) {
LOG.info("cleanAccountingEntriesInDetailEntry, deduct credits from debits required");
deductCreditAmountsFromDebitTransactions(newDetailEntry, originalCreditTotal);
} else {
LOG.info("cleanAccountingEntriesInDetailEntry, no changes required to the accounting entries");
}
removeNonPositiveAccountingEntriesFromDetailEntry(newDetailEntry);
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountExtractPdpEntryServiceImpl method buildPdpFeedTrailerEntry.
@Override
public PdpFeedTrailerEntry buildPdpFeedTrailerEntry(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, ConcurStandardAccountingExtractBatchReportData reportData) {
PdpFeedTrailerEntry trailerEntry = new PdpFeedTrailerEntry();
KualiDecimal pdpTotal = KualiDecimal.ZERO;
int numberOfDetails = 0;
for (PdpFeedGroupEntry group : pdpFeedFileBaseEntry.getGroup()) {
numberOfDetails += group.getDetail().size();
for (PdpFeedDetailEntry detailEntry : group.getDetail()) {
for (PdpFeedAccountingEntry accountingEntry : detailEntry.getAccounting()) {
pdpTotal = pdpTotal.add(accountingEntry.getAmount());
}
}
}
trailerEntry.setDetailCount(numberOfDetails);
trailerEntry.setDetailTotAmt(pdpTotal);
reportData.getPdpRecordsProcessed().setRecordCount(numberOfDetails);
reportData.getPdpRecordsProcessed().setDollarAmount(pdpTotal);
return trailerEntry;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractServiceImpl method buildPdpFeedFileBaseEntry.
private PdpFeedFileBaseEntry buildPdpFeedFileBaseEntry(ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile, ConcurStandardAccountingExtractBatchReportData reportData) {
PdpFeedFileBaseEntry pdpFeedFileBaseEntry = new PdpFeedFileBaseEntry();
pdpFeedFileBaseEntry.setVersion(ConcurConstants.FEED_FILE_ENTRY_HEADER_VERSION);
pdpFeedFileBaseEntry.setHeader(getConcurStandardAccountExtractPdpEntryService().buildPdpFeedHeaderEntry(concurStandardAccountingExtractFile.getBatchDate()));
int totalReimbursementLineCount = 0;
KualiDecimal totalReimbursementDollarAmount = KualiDecimal.ZERO;
for (ConcurStandardAccountingExtractDetailLine line : concurStandardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
if (shouldProcessSAELineToPDP(line)) {
if (shouldLineTotalsBeAddedToReimbursementReportTotals(line)) {
totalReimbursementLineCount++;
totalReimbursementDollarAmount = totalReimbursementDollarAmount.add(line.getJournalAmount());
}
logJournalAccountCodeOverridden(line, reportData);
String overriddenObjectCode = getParameterService().getParameterValueAsString(CUKFSConstants.ParameterNamespaces.CONCUR, CUKFSParameterKeyConstants.ALL_COMPONENTS, ConcurParameterConstants.CONCUR_SAE_PDP_DEFAULT_OBJECT_CODE);
String overriddenSubObjectCode = StringUtils.EMPTY;
if (getConcurStandardAccountingExtractValidationService().validateConcurStandardAccountingExtractDetailLineWithObjectCodeOverrideForPdp(line, reportData, overriddenObjectCode, overriddenSubObjectCode)) {
buildAndUpdateAccountingEntryFromLine(pdpFeedFileBaseEntry, line, concurStandardAccountingExtractFile);
}
}
}
reportData.getReimbursementsInExpenseReport().setRecordCount(totalReimbursementLineCount);
reportData.getReimbursementsInExpenseReport().setDollarAmount(totalReimbursementDollarAmount);
pdpFeedFileBaseEntry.setTrailer(getConcurStandardAccountExtractPdpEntryService().buildPdpFeedTrailerEntry(pdpFeedFileBaseEntry, reportData));
return pdpFeedFileBaseEntry;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractServiceImpl method buildAndUpdateAccountingEntryFromLine.
private void buildAndUpdateAccountingEntryFromLine(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, ConcurStandardAccountingExtractDetailLine line, ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile) {
PdpFeedGroupEntry currentGroup = getGroupEntryForLine(pdpFeedFileBaseEntry, line);
PdpFeedDetailEntry currentDetail = getDetailEntryForLine(currentGroup, line);
PdpFeedAccountingEntry currentAccounting = getAccountingEntryForLine(currentDetail, line, concurStandardAccountingExtractFile);
KualiDecimal newAmount = line.getJournalAmount().add(currentAccounting.getAmount());
currentAccounting.setAmount(newAmount);
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurStandardAccountingExtractValidationServiceImpl method validateAmountsAndDebitCreditCode.
@Override
public boolean validateAmountsAndDebitCreditCode(ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile, ConcurStandardAccountingExtractBatchReportData reportData) {
KualiDecimal journalTotal = concurStandardAccountingExtractFile.getJournalAmountTotal();
KualiDecimal detailTotal = KualiDecimal.ZERO;
boolean debitCreditValid = true;
boolean employeeGroupIdValid = true;
boolean journalTotalValidation = true;
for (ConcurStandardAccountingExtractDetailLine line : concurStandardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
if (line.getJournalAmount() != null) {
detailTotal = detailTotal.add(line.getJournalAmount());
} else {
String validationError = "Parsed a null KualiDecimal from the original value of " + line.getJournalAmountString();
reportData.addValidationErrorFileLine(new ConcurBatchReportLineValidationErrorItem(line, validationError));
LOG.error("validateAmountsAndDebitCreditCode, " + validationError);
journalTotalValidation = false;
}
debitCreditValid &= validateDebitCreditField(line, reportData);
employeeGroupIdValid &= validateEmployeeGroupId(line, reportData);
}
journalTotalValidation = journalTotalValidation && detailTotal.equals(journalTotal);
if (journalTotalValidation) {
LOG.debug("validateAmounts, journal total: " + journalTotal.doubleValue() + " and detailTotal: " + detailTotal.doubleValue() + " do match.");
} else {
String validationError = "The journal total (" + journalTotal + ") does not equal the detail line total (" + detailTotal + ")";
reportData.addHeaderValidationError(validationError);
LOG.error("validateAmounts, " + validationError);
}
return journalTotalValidation && debitCreditValid && employeeGroupIdValid;
}
Aggregations