From 97330a8faa78dd757f424a57e9a3192158319e72 Mon Sep 17 00:00:00 2001 From: faheem205 Date: Mon, 16 Dec 2024 22:20:55 +0500 Subject: [PATCH 1/4] SU-502 initial commit --- .../domain/LoanRepaymentScheduleInstallment.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java index 678645c739e..c16a8b3f75e 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java @@ -169,6 +169,9 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa @Column(name = "original_interest_charged", nullable = true) private BigDecimal originalInterestChargedAmount; + @Column(name = "migrated_installment") + private boolean isMigratedInstallment; + public LoanRepaymentScheduleInstallment() { this.installmentNumber = null; this.fromDate = null; @@ -971,7 +974,9 @@ public Money payInterestComponent(final LocalDate transactionDate, final Money t Money interestDue = Money.zero(currency); - if (isOn(transactionDate, this.getDueDate())) { + if(this.isMigratedInstallment) { + interestDue = getInterestOutstanding(currency); + } else if (isOn(transactionDate, this.getDueDate())) { interestDue = getInterestOutstanding(currency); } else if (isOnOrBetween(transactionDate) && getInterestOutstanding(currency).isGreaterThanZero()) { final RoundingMode roundingMode = RoundingMode.HALF_UP; @@ -1072,7 +1077,7 @@ public Money payPrincipalComponent(final LocalDate transactionDate, final Money //// Update installment interest charged if principal is fully paid during the accrual period and interest has //// also been recalculated and paid // Keep the original interest charged in case the transaction is rollbacked. - if (this.getLoan() != null && this.getLoan().isProgressiveLoan()) { + if (this.getLoan() != null && this.getLoan().isProgressiveLoan() && !this.isMigratedInstallment) { if (isOnOrBetween(transactionDate)) { if (this.getPrincipalOutstanding(currency).isZero() && (this.originalInterestChargedAmount == null || this.originalInterestChargedAmount.equals(BigDecimal.ZERO)) @@ -1710,4 +1715,8 @@ public boolean isFullyGraced() { public BigDecimal originalInterestChargedAmount() { return originalInterestChargedAmount; } + + public boolean isMigratedInstallment() { + return isMigratedInstallment; + } } From d53f9ea722ab97d037e7e62a10af69e0389e7247 Mon Sep 17 00:00:00 2001 From: faheem205 Date: Mon, 16 Dec 2024 22:26:12 +0500 Subject: [PATCH 2/4] Revert "SU-502 initial commit" This reverts commit 97330a8faa78dd757f424a57e9a3192158319e72. --- .../domain/LoanRepaymentScheduleInstallment.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java index c16a8b3f75e..678645c739e 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java @@ -169,9 +169,6 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa @Column(name = "original_interest_charged", nullable = true) private BigDecimal originalInterestChargedAmount; - @Column(name = "migrated_installment") - private boolean isMigratedInstallment; - public LoanRepaymentScheduleInstallment() { this.installmentNumber = null; this.fromDate = null; @@ -974,9 +971,7 @@ public Money payInterestComponent(final LocalDate transactionDate, final Money t Money interestDue = Money.zero(currency); - if(this.isMigratedInstallment) { - interestDue = getInterestOutstanding(currency); - } else if (isOn(transactionDate, this.getDueDate())) { + if (isOn(transactionDate, this.getDueDate())) { interestDue = getInterestOutstanding(currency); } else if (isOnOrBetween(transactionDate) && getInterestOutstanding(currency).isGreaterThanZero()) { final RoundingMode roundingMode = RoundingMode.HALF_UP; @@ -1077,7 +1072,7 @@ public Money payPrincipalComponent(final LocalDate transactionDate, final Money //// Update installment interest charged if principal is fully paid during the accrual period and interest has //// also been recalculated and paid // Keep the original interest charged in case the transaction is rollbacked. - if (this.getLoan() != null && this.getLoan().isProgressiveLoan() && !this.isMigratedInstallment) { + if (this.getLoan() != null && this.getLoan().isProgressiveLoan()) { if (isOnOrBetween(transactionDate)) { if (this.getPrincipalOutstanding(currency).isZero() && (this.originalInterestChargedAmount == null || this.originalInterestChargedAmount.equals(BigDecimal.ZERO)) @@ -1715,8 +1710,4 @@ public boolean isFullyGraced() { public BigDecimal originalInterestChargedAmount() { return originalInterestChargedAmount; } - - public boolean isMigratedInstallment() { - return isMigratedInstallment; - } } From 5e8ad436679776c7e6b79fb2235b8e8b585ac7f4 Mon Sep 17 00:00:00 2001 From: faheem205 Date: Fri, 27 Dec 2024 21:02:24 +0500 Subject: [PATCH 3/4] SU-539 --- .../service/LoanChargeWritePlatformServiceImpl.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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..11e4812a211 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,16 @@ 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()); From fe79e6e356a6b683c847f14e1111bb9220d49ed2 Mon Sep 17 00:00:00 2001 From: Faheem Ahmad Date: Fri, 27 Dec 2024 21:05:29 +0500 Subject: [PATCH 4/4] SU-539 spotless Check applied --- .../service/LoanChargeWritePlatformServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 11e4812a211..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 @@ -1052,7 +1052,8 @@ private boolean addCharge(final Loan loan, final Charge chargeDefinition, LoanCh if (loan.getStatus().isActive() && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null); if (DateUtils.isBeforeBusinessDate(loanCharge.getDueLocalDate())) { - Long minimumDaysInArrearsToSuspendLoanAccount = this.configurationDomainService.retriveMinimumDaysInArrearsToSuspendLoanAccount(); + Long minimumDaysInArrearsToSuspendLoanAccount = this.configurationDomainService + .retriveMinimumDaysInArrearsToSuspendLoanAccount(); if (minimumDaysInArrearsToSuspendLoanAccount == null) { minimumDaysInArrearsToSuspendLoanAccount = 90L; }