adamsaghy commented on code in PR #4294:
URL: https://github.com/apache/fineract/pull/4294#discussion_r1949815303
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -283,37 +285,81 @@ private InterestPeriod findPreviousInterestPeriod(final
RepaymentPeriod repaymen
}
}
+ /**
+ * Gives back the total due interest amount in the whole repayment
schedule. Also includes chargeback interest
+ * amount.
+ *
+ * @return
+ */
public Money getTotalDueInterest() {
return repaymentPeriods().stream().flatMap(rp ->
rp.getInterestPeriods().stream().map(InterestPeriod::getCalculatedDueInterest))
.reduce(zero(), Money::plus);
}
+ /**
+ * Gives back the total due principal amount in the whole repayment
schedule based on disbursements. Do not contain
+ * chargeback principal amount.
+ *
+ * @return
+ */
public Money getTotalDuePrincipal() {
- return repaymentPeriods.stream().flatMap(rp ->
rp.getInterestPeriods().stream().map(InterestPeriod::getDisbursementAmount))
- .reduce(zero(), Money::plus);
+ return
repaymentPeriods.stream().map(RepaymentPeriod::getDisbursedAmounts).reduce(zero(),
Money::plus);
}
+ /**
+ * Gives back the total paid interest amount in the whole repayment
schedule.
+ *
+ * @return
+ */
public Money getTotalPaidInterest() {
return
repaymentPeriods().stream().map(RepaymentPeriod::getPaidInterest).reduce(zero,
Money::plus);
}
+ /**
+ * Gives back the total paid principal amount in the whole repayment
schedule.
+ *
+ * @return
+ */
public Money getTotalPaidPrincipal() {
return
repaymentPeriods().stream().map(RepaymentPeriod::getPaidPrincipal).reduce(zero,
Money::plus);
}
+ /**
+ * Gives back the total chargeback principal amount in the whole repayment
schedule.
+ *
+ * @return
+ */
+ public Money getTotalChargebackPrincipal() {
+ return
repaymentPeriods().stream().map(RepaymentPeriod::getChargebackPrincipal).reduce(zero,
Money::plus);
+ }
+
public Optional<RepaymentPeriod> findRepaymentPeriod(@NotNull LocalDate
transactionDate) {
return repaymentPeriods.stream() //
.filter(period -> isInPeriod(transactionDate,
period.getFromDate(), period.getDueDate(), period.isFirstRepaymentPeriod()))//
.findFirst();
}
+ /**
+ * Check if there is a disbursement in the model.
+ *
+ * @return
+ */
public boolean isEmpty() {
return repaymentPeriods.stream() //
.filter(rp -> !rp.getEmi().isZero()) //
.findFirst() //
.isEmpty(); //
}
+ @NotNull
+ public RepaymentPeriod getLastRepaymentPeriod() {
+ return repaymentPeriods.get(repaymentPeriods.size() - 1);
+ }
+
+ public boolean isLastRepaymentPeriod(@NotNull RepaymentPeriod
repaymentPeriod) {
+ return
getLastRepaymentPeriod().getDueDate().equals(repaymentPeriod.getDueDate());
Review Comment:
reference equality?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]