FINERACT-2308: Allow approval / disbursal above loan applied amount for multidisbursal progressive loan that does expect tranches

This commit is contained in:
mariiaKraievska
2025-08-01 15:44:43 +02:00
committed by Adam Saghy
parent cb4c66302a
commit 68bfd7a3f8
8 changed files with 210 additions and 11 deletions
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.delinquency.service;
import static org.apache.fineract.portfolio.loanaccount.domain.Loan.EARLIEST_UNPAID_DATE;
import static org.apache.fineract.portfolio.loanaccount.domain.Loan.NEXT_UNPAID_DUE_DATE;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collection;
import java.util.Comparator;
@@ -148,7 +149,10 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
// Overpaid
// loans
collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
collectionData.setAvailableDisbursementAmount(loan.getApprovedPrincipal().subtract(loan.getDisbursedAmount()));
// Ensure availableDisbursementAmount is never negative
final BigDecimal availableAmount = loan.getApprovedPrincipal().subtract(loan.getDisbursedAmount());
collectionData
.setAvailableDisbursementAmount(availableAmount.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : availableAmount);
collectionData.setNextPaymentDueDate(possibleNextRepaymentDate(nextPaymentDueDateConfig, loan));
final LoanTransaction lastPayment = loan.getLastPaymentTransaction();
@@ -414,14 +414,6 @@ public class LoanProduct extends AbstractPersistableCustom<Long> {
}
}
if (this.allowApprovedDisbursedAmountsOverApplied) {
if (this.isMultiDisburseLoan() && !this.disallowExpectedDisbursements) {
throw new LoanProductGeneralRuleException(
"disallowExpectedDisbursements.not.set.allowApprovedDisbursedAmountsOverApplied.cant.be.set",
"Disallow Expected Disbursals Not Set - Allow Approved / Disbursed Amounts Over Applied Can't Be Set");
}
}
if (this.overAppliedCalculationType == null || this.overAppliedCalculationType.isEmpty()) {
if (this.allowApprovedDisbursedAmountsOverApplied) {
throw new LoanProductGeneralRuleException(