diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 555053bccd..cd5b4bac00 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -2851,13 +2851,13 @@ public void applyDailyAccrualsAtDisbursement(LocalDate currentDate) { final List loanRepaymentScheduleInstallments = getRepaymentScheduleInstallments(); for (LoanRepaymentScheduleInstallment repaymentScheduleInstallment : loanRepaymentScheduleInstallments) { if (!currentDate.isBefore(repaymentScheduleInstallment.getFromDate()) - && !currentDate.isAfter(repaymentScheduleInstallment.getDueDate())) { + && !currentDate.isAfter(repaymentScheduleInstallment.getDueDate().minusDays(1))) { long daysInPeriod = Math.toIntExact( ChronoUnit.DAYS.between(repaymentScheduleInstallment.getFromDate(), repaymentScheduleInstallment.getDueDate())); Money interestForInstallment = repaymentScheduleInstallment.getInterestCharged(getCurrency()); BigDecimal dailyInterest; // Adjust interest on the last day of the period to make up the difference - if (currentDate.equals(repaymentScheduleInstallment.getDueDate())) { + if (currentDate.equals(repaymentScheduleInstallment.getDueDate().minusDays(1))) { // if the amount is whole number when divided across the days in the period, then do same for last // day if (interestForInstallment.getAmount().remainder(BigDecimal.valueOf(daysInPeriod)).compareTo(BigDecimal.ZERO) == 0) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index c4d2cc2f7e..259c5ad1a3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -4447,14 +4447,14 @@ public void persistDailyAccrual(final LocalDate transactionDate) { Money principalLoanBalanceOutstanding = loan.getPrincipal(); for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : repaymentScheduleInstallments) { if (!transactionDate.isBefore(loanRepaymentScheduleInstallment.getFromDate()) - && !transactionDate.isAfter(loanRepaymentScheduleInstallment.getDueDate())) { + && !transactionDate.isAfter(loanRepaymentScheduleInstallment.getDueDate().minusDays(1))) { final BigDecimal totalAccruedInterestForInstallment = loan .getAccruedInterestForInstallment(loanRepaymentScheduleInstallment.getInstallmentNumber()); long daysInPeriod = Math.toIntExact(ChronoUnit.DAYS.between(loanRepaymentScheduleInstallment.getFromDate(), loanRepaymentScheduleInstallment.getDueDate())); Money interestForInstallment = loanRepaymentScheduleInstallment.getInterestCharged(currency); // Adjust interest on the last day of the period to make up the difference - if (transactionDate.equals(loanRepaymentScheduleInstallment.getDueDate())) { + if (transactionDate.equals(loanRepaymentScheduleInstallment.getDueDate().minusDays(1))) { // if the amount is whole number when divided across the days in the period, then do same for // last // day