use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurDetailLineGroupForCollector method buildOriginEntryForPaymentOffset.
protected Optional<OriginEntryFull> buildOriginEntryForPaymentOffset(OriginEntryFull cashEntry, List<ConcurStandardAccountingExtractDetailLine> cashLines) {
KualiDecimal cashAmount = getSignedAmountFromOriginEntry(cashEntry);
KualiDecimal cashAdvanceAmount = calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines(cashLines);
KualiDecimal cashAmountToOffset = cashAmount.add(cashAdvanceAmount);
if (cashAmountToOffset.isZero()) {
return Optional.empty();
}
OriginEntryFull offsetEntry = buildOffsetOriginEntry(cashEntry, cashAmountToOffset);
offsetEntry.setFinancialObjectCode(collectorHelper.getPaymentOffsetObjectCode());
offsetEntry.setFinancialSubObjectCode(collectorHelper.getDashOnlyPropertyValue(KFSPropertyConstants.SUB_OBJECT_CODE));
return Optional.of(offsetEntry);
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurDetailLineGroupForCollector method addOffsetOriginEntriesForUnusedAtmCashAdvanceAmountLines.
protected void addOffsetOriginEntriesForUnusedAtmCashAdvanceAmountLines(Consumer<OriginEntryFull> entryConsumer, List<ConcurStandardAccountingExtractDetailLine> unusedAtmAmountLines) {
if (CollectionUtils.isEmpty(unusedAtmAmountLines)) {
return;
}
KualiDecimal totalAmount = calculateTotalAmountForLines(unusedAtmAmountLines);
if (totalAmount.isNonZero()) {
OriginEntryFull offsetEntry = this.buildOriginEntryForUnusedAtmAmountOffset(unusedAtmAmountLines, totalAmount);
entryConsumer.accept(offsetEntry);
}
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurDetailLineGroupForCollector method calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines.
protected KualiDecimal calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines(List<ConcurStandardAccountingExtractDetailLine> regularDetailLines) {
if (totalCashAdvanceAmountsByReportEntryId.isEmpty()) {
return KualiDecimal.ZERO;
}
KualiDecimal totalAmount = KualiDecimal.ZERO;
String[] reportEntryIds = regularDetailLines.stream().map(ConcurStandardAccountingExtractDetailLine::getReportEntryId).distinct().toArray(String[]::new);
for (String reportEntryId : reportEntryIds) {
KualiDecimal subTotalAmount = totalCashAdvanceAmountsByReportEntryId.get(reportEntryId);
if (subTotalAmount != null) {
totalAmount = totalAmount.add(subTotalAmount);
}
}
return totalAmount;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurDetailLineGroupForCollector method calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines.
protected KualiDecimal calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines(List<ConcurStandardAccountingExtractDetailLine> regularDetailLines) {
if (unusedCashAdvanceAmountsByReportEntryId.isEmpty()) {
return KualiDecimal.ZERO;
}
KualiDecimal usableAmount = KualiDecimal.ZERO;
for (ConcurStandardAccountingExtractDetailLine detailLine : regularDetailLines) {
KualiDecimal lineAmount = detailLine.getJournalAmount();
KualiDecimal oldUnusedAmount = unusedCashAdvanceAmountsByReportEntryId.getOrDefault(detailLine.getReportEntryId(), KualiDecimal.ZERO);
if (lineAmount.isPositive() && oldUnusedAmount.isNegative()) {
KualiDecimal newUnusedAmount = unusedCashAdvanceAmountsByReportEntryId.merge(detailLine.getReportEntryId(), lineAmount, KualiDecimal::add);
if (newUnusedAmount.isPositive()) {
usableAmount = usableAmount.add(oldUnusedAmount);
} else {
usableAmount = usableAmount.add(lineAmount.negated());
}
}
}
return usableAmount;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurDetailLineGroupForCollector method calculateTotalCashAmountNotOffsetByCashAdvances.
protected KualiDecimal calculateTotalCashAmountNotOffsetByCashAdvances() {
List<ConcurStandardAccountingExtractDetailLine> allCashLines = getSubGroupsOfType(ConcurSAECollectorLineType.CASH).stream().flatMap(List::stream).collect(Collectors.toCollection(ArrayList::new));
KualiDecimal totalCashAmount = calculateTotalAmountForLines(allCashLines);
KualiDecimal totalCashAdvanceAmount = calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines(allCashLines);
return totalCashAmount.add(totalCashAdvanceAmount);
}
Aggregations