adamsaghy commented on code in PR #4000:
URL: https://github.com/apache/fineract/pull/4000#discussion_r1698392284
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java:
##########
@@ -236,44 +223,23 @@ public static LoanSummaryData
withOnlyCurrencyData(CurrencyData currencyData) {
return LoanSummaryData.builder().currency(currencyData).build();
}
- private static BigDecimal
computeTotalAccruedDueInterestAmount(Collection<LoanSchedulePeriodData>
periods) {
- final LocalDate businessDate = DateUtils.getBusinessLocalDate();
- return periods.stream().filter(period ->
!period.getDownPaymentPeriod() && businessDate.isAfter(period.getDueDate()))
- .map(period ->
period.getTotalAccruedInterest()).reduce(BigDecimal.ZERO, BigDecimal::add);
- }
-
- private static BigDecimal
computeTotalInterestPaidDueAmount(Collection<LoanSchedulePeriodData> periods) {
- final LocalDate businessDate = DateUtils.getBusinessLocalDate();
+ private static BigDecimal
computeTotalUnpaidPayableDueInterestAmount(Collection<LoanSchedulePeriodData>
periods,
+ final LocalDate businessDate) {
return periods.stream().filter(period ->
!period.getDownPaymentPeriod() && businessDate.isAfter(period.getDueDate()))
- .map(period ->
period.getInterestPaid()).reduce(BigDecimal.ZERO, BigDecimal::add);
+ .map(period ->
period.getInterestOutstanding()).reduce(BigDecimal.ZERO, BigDecimal::add);
}
- private static BigDecimal
computeTotalAccruedNotDueInterestAmountOnActualPeriod(Collection<LoanSchedulePeriodData>
periods) {
- final LocalDate businessDate = DateUtils.getBusinessLocalDate();
- return periods.stream()
- .filter(period -> !period.getDownPaymentPeriod() &&
isActualPeriod(period) && businessDate.isBefore(period.getDueDate()))
- .map(period ->
period.getTotalAccruedInterest()).reduce(BigDecimal.ZERO, BigDecimal::add);
- }
-
- private static BigDecimal
computeTotalInterestPaidNotDueAmountOnActualPeriod(Collection<LoanSchedulePeriodData>
periods) {
- final LocalDate businessDate = DateUtils.getBusinessLocalDate();
- return periods.stream()
- .filter(period -> !period.getDownPaymentPeriod() &&
isActualPeriod(period) && businessDate.isBefore(period.getDueDate()))
- .map(period ->
period.getInterestPaid()).reduce(BigDecimal.ZERO, BigDecimal::add);
- }
-
- private static boolean isActualPeriod(LoanSchedulePeriodData period) {
- final LocalDate businessDate = DateUtils.getBusinessLocalDate();
- boolean actualPeriod = false;
- if (period.getPeriod() != null) {
- if (period.getPeriod() == 1) {
- actualPeriod = ((businessDate.isEqual(period.getFromDate()) ||
businessDate.isAfter(period.getFromDate()))
- && businessDate.isBefore(period.getDueDate()));
- } else {
- actualPeriod = (businessDate.isAfter(period.getFromDate()) &&
businessDate.isBefore(period.getDueDate()));
- }
+ private static BigDecimal
computeTotalUnpaidPayableNotDueInterestAmountOnActualPeriod(final
Collection<LoanSchedulePeriodData> periods,
+ final LocalDate businessDate) {
+ // Default value equal to Zero
+ BigDecimal totalAccruedNotDueInterestAmount = BigDecimal.ZERO;
+ // Find the current Period (If exists one) based in the Business date
Review Comment:
typo: in -> on
--
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]