Skip to content

Commit

Permalink
FINERACT-1958-backdated-disbursement
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchiD committed Sep 14, 2023
1 parent 781f3ae commit fb7ee80
Show file tree
Hide file tree
Showing 3 changed files with 838 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2599,21 +2599,16 @@ public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO schedule
}

public boolean canDisburse(final LocalDate actualDisbursementDate) {
LocalDate lastDisburseDate = this.actualDisbursementDate;
LocalDate loanSubmittedOnDate = this.submittedOnDate;
final LoanStatus statusEnum = this.loanLifecycleStateMachine.dryTransition(LoanEvent.LOAN_DISBURSED, this);

boolean isMultiTrancheDisburse = false;
LoanStatus actualLoanStatus = LoanStatus.fromInt(this.loanStatus);
if ((actualLoanStatus.isActive() || actualLoanStatus.isClosedObligationsMet() || actualLoanStatus.isOverpaid())
&& isAllTranchesNotDisbursed()) {
LoanDisbursementDetails details = fetchLastDisburseDetail();

if (details != null) {
lastDisburseDate = details.actualDisbursementDate();
}
if (actualDisbursementDate.isBefore(lastDisburseDate)) {
final String errorMsg = "Loan can't be disbursed before " + lastDisburseDate;
throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.lastdusbursedate", lastDisburseDate,
if (actualDisbursementDate.isBefore(loanSubmittedOnDate)) {
final String errorMsg = "Loan can't be disbursed before " + loanSubmittedOnDate;
throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.submittedDate", loanSubmittedOnDate,
actualDisbursementDate);
}
isMultiTrancheDisburse = true;
Expand All @@ -2626,6 +2621,8 @@ public Money adjustDisburseAmount(final JsonCommand command, final LocalDate act
BigDecimal principalDisbursed = command.bigDecimalValueOfParameterNamed(LoanApiConstants.principalDisbursedParameterName);
if (this.actualDisbursementDate == null) {
this.actualDisbursementDate = actualDisbursementDate;
} else if (actualDisbursementDate.isBefore(this.actualDisbursementDate)) {
this.actualDisbursementDate = actualDisbursementDate;
}
BigDecimal diff = BigDecimal.ZERO;
Collection<LoanDisbursementDetails> details = fetchUndisbursedDetail();
Expand Down
Loading

0 comments on commit fb7ee80

Please sign in to comment.