FINERACT-2081: fix disburse error scenario
This commit is contained in:
committed by
Adam Saghy
parent
bd19f28cb6
commit
ec1c55d022
+17
@@ -80,6 +80,7 @@ import org.apache.fineract.portfolio.loanaccount.exception.DateMismatchException
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanStateTransitionException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanApplicationDateException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanChargeRefundException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanDisbursalException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanRepaymentScheduleNotFoundException;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanUtilService;
|
||||
@@ -213,6 +214,22 @@ public final class LoanTransactionValidator {
|
||||
loan.getExpectedDisbursedOnLocalDate());
|
||||
}
|
||||
|
||||
if ((loan.getStatus().isActive() || loan.getStatus().isClosedObligationsMet() || loan.getStatus().isOverpaid())
|
||||
&& loan.isAllTranchesNotDisbursed()) {
|
||||
LocalDate submittedOnDate = loan.getSubmittedOnDate();
|
||||
if (DateUtils.isBefore(actualDisbursementDate, submittedOnDate)) {
|
||||
final String errorMsg = "Loan can't be disbursed before " + submittedOnDate;
|
||||
throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.submittedDate", submittedOnDate,
|
||||
actualDisbursementDate);
|
||||
}
|
||||
}
|
||||
|
||||
LocalDate approvedOnDate = loan.getApprovedOnDate();
|
||||
if (DateUtils.isBefore(actualDisbursementDate, approvedOnDate)) {
|
||||
final String errorMessage = "The date on which a loan is disbursed cannot be before its approval date: " + approvedOnDate;
|
||||
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage,
|
||||
actualDisbursementDate, approvedOnDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -349,7 +349,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
|
||||
|
||||
if (loan.canDisburse(actualDisbursementDate)) {
|
||||
if (loan.canDisburse()) {
|
||||
// Get netDisbursalAmount from disbursal screen field.
|
||||
final BigDecimal netDisbursalAmount = command
|
||||
.bigDecimalValueOfParameterNamed(LoanApiConstants.disbursementNetDisbursalAmountParameterName);
|
||||
@@ -774,7 +774,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
// disbursement and actual disbursement happens on same date
|
||||
loan.validateAccountStatus(LoanEvent.LOAN_DISBURSED);
|
||||
updateLoanCounters(loan, actualDisbursementDate);
|
||||
boolean canDisburse = loan.canDisburse(actualDisbursementDate);
|
||||
boolean canDisburse = loan.canDisburse();
|
||||
ChangedTransactionDetail changedTransactionDetail = null;
|
||||
if (canDisburse) {
|
||||
Money amountBeforeAdjust = loan.getPrincipal();
|
||||
|
||||
Reference in New Issue
Block a user