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 1, 2024
1 parent 526fb6b commit 1eeb1f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 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

0 comments on commit 1eeb1f8

Please sign in to comment.