Skip to content

Commit

Permalink
FINERACT-2081: Loan Unpaid Payable Interest fix to include amount paid
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez committed Aug 2, 2024
1 parent 141e26f commit 0c7cf1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.MathUtil;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
Expand Down Expand Up @@ -260,6 +261,12 @@ private static BigDecimal computeAccruedInterestTillDay(final LoanSchedulePeriod
remainingDays--;
}

totalAccruedInterest = totalAccruedInterest.subtract(period.getInterestPaid()).subtract(period.getInterestWaived());
if (MathUtil.isLessThanZero(totalAccruedInterest)) {
// Set Zero If the Interest Paid + Waived is greather than Interest Accrued
totalAccruedInterest = BigDecimal.ZERO;
}

return Money.of(currency, totalAccruedInterest).getAmount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4739,7 +4739,7 @@ public void uc144() {
addRepaymentForLoan(createdLoanId.get(), 20.50, "30 January 2024");
loanDetails = loanTransactionHelper.getLoanDetails(createdLoanId.get());
assertEquals(BigDecimal.ZERO, loanDetails.getSummary().getTotalUnpaidPayableDueInterest().stripTrailingZeros());
assertEquals(new BigDecimal("0.97"), loanDetails.getSummary().getTotalUnpaidPayableNotDueInterest().stripTrailingZeros());
assertEquals(new BigDecimal("0.05"), loanDetails.getSummary().getTotalUnpaidPayableNotDueInterest().stripTrailingZeros());
});

// Not Due and Due Interest
Expand Down

0 comments on commit 0c7cf1b

Please sign in to comment.