Skip to content

Commit

Permalink
FINERACT-2081: fix disburse error scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozsa committed Aug 2, 2024
1 parent 526fb6b commit 98f37d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2012,18 +2012,10 @@ public void handleDisbursementTransaction(final LocalDate disbursedOn, final Pay
updateLoanOutstandingBalances();
}

if (getApprovedOnDate() != null && DateUtils.isBefore(disbursedOn, getApprovedOnDate())) {
final String errorMessage = "The date on which a loan is disbursed cannot be before its approval date: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn,
getApprovedOnDate());
}

LocalDate expectedDate = getExpectedFirstRepaymentOnDate();
if (expectedDate != null && (DateUtils.isAfter(disbursedOn, this.fetchRepaymentScheduleInstallment(1).getDueDate())
|| DateUtils.isAfter(disbursedOn, expectedDate)) && DateUtils.isEqual(disbursedOn, this.actualDisbursementDate)) {
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: "
+ expectedDate.toString();
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: " + expectedDate;
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage,
disbursedOn, expectedDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public void validateDisbursement(JsonCommand command, boolean isAccountTransfer,
loan.getExpectedDisbursedOnLocalDate());
}

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);
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public void loanAccountBackDatedDisbursementWithDisbursementDateBeforeLoanSubmit
List<HashMap<String, Object>> loanErrorData = (List<HashMap<String, Object>>) validationErrorHelper
.disburseLoanWithTransactionAmountWithError("02 March 2023", loanId, "500", CommonConstants.RESPONSE_ERROR);
assertNotNull(loanErrorData);
assertEquals("Loan can't be disbursed before 2023-03-03", loanErrorData.get(0).get("defaultUserMessage"));
assertEquals("The date on which a loan is disbursed cannot be before its approval date: 2023-03-03", loanErrorData.get(0).get("defaultUserMessage"));
assertEquals("error.msg.loan.actualdisbursementdate.before.submittedDate",
loanErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));

Expand Down

0 comments on commit 98f37d8

Please sign in to comment.