diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java index 5e006812e33..d357c6e4fc5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -746,7 +747,7 @@ public void applyOverdueChargesForLoan(final Long loanId, Collection e.getInstallmentNumber() > 0).collect(Collectors .groupingBy(schedule -> schedule.getLoan().getId() + "-" + schedule.getInstallmentNumber(), Collectors.counting())) .values().stream().anyMatch(count -> count > 1); @@ -1050,6 +1051,17 @@ private boolean addCharge(final Loan loan, final Charge chargeDefinition, LoanCh // the loan product uses Upfront Accruals if (loan.getStatus().isActive() && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null); + if (DateUtils.isBeforeBusinessDate(loanCharge.getDueLocalDate())) { + Long minimumDaysInArrearsToSuspendLoanAccount = this.configurationDomainService + .retriveMinimumDaysInArrearsToSuspendLoanAccount(); + if (minimumDaysInArrearsToSuspendLoanAccount == null) { + minimumDaysInArrearsToSuspendLoanAccount = 90L; + } + long days = loan.getDisburseDonDate().until(applyLoanChargeTransaction.getTransactionDate(), ChronoUnit.DAYS); + if (days >= minimumDaysInArrearsToSuspendLoanAccount) { + applyLoanChargeTransaction.markAsOccurredOnSuspendedAccount(); + } + } this.loanTransactionRepository.saveAndFlush(applyLoanChargeTransaction); } return DateUtils.isBeforeBusinessDate(loanCharge.getDueLocalDate());