Skip to content

Commit

Permalink
FINERACT-2081: clear closed_on date on repayment reversal
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozsa authored and adamsaghy committed Aug 9, 2024
1 parent 69dd19c commit c70007e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,21 @@ public void loanStatus(String statusExpected) throws IOException {
.isEqualTo(loanStatusExpectedValue);
}

@Then("Loan closedon_date is {}")
public void loanClosedonDate(String date) throws IOException {
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.body().getLoanId();

Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "", "", "").execute();
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
testContext().set(TestContextKey.LOAN_RESPONSE, loanDetailsResponse);
if (date == null || "null".equals(date)) {
assertThat(loanDetailsResponse.body().getTimeline().getClosedOnDate()).isNull();
} else {
assertThat(loanDetailsResponse.body().getTimeline().getClosedOnDate()).isEqualTo(date);
}
}

@Then("Admin can successfully set Fraud flag to the loan")
public void setFraud() throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
Expand Down
14 changes: 14 additions & 0 deletions fineract-e2e-tests-runner/src/test/resources/features/Loan.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,20 @@ Feature: Loan
| actualMaturityDate | expectedMaturityDate |
| 01 July 2023 | 01 July 2023 |

Scenario: Verify that closed date is updated on repayment reversal
When Admin sets the business date to "01 June 2023"
When Admin creates a client with random data
When Admin creates a new default Loan with date: "01 June 2023"
And Admin successfully approves the loan on "01 June 2023" with "1000" amount and expected disbursement date on "01 June 2023"
When Admin successfully disburse the loan on "01 June 2023" with "1000" EUR transaction amount
Then Loan status will be "ACTIVE"
When Admin sets the business date to "20 June 2023"
And Customer makes "AUTOPAY" repayment on "20 June 2023" with 1000 EUR transaction amount
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
When Admin sets the business date to "20 June 2023"
When Customer undo "1"th "Repayment" transaction made on "20 June 2023"
Then Loan status will be "ACTIVE"
Then Loan closedon_date is null

Scenario: As an admin I would like to delete a loan using external id
When Admin sets the business date to the actual date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public void transition(final LoanEvent loanEvent, final Loan loan) {
// in case of Loan creation, a LoanCreatedBusinessEvent is also raised, no need to send a status change
businessEventNotifierService.notifyPostBusinessEvent(new LoanStatusChangedBusinessEvent(loan));
}

// set mandatory field states based on new status after the transition
switch (newStatus) {
case ACTIVE -> {
if (loan.getClosedOnDate() != null) {
loan.setClosedOnDate(null);
}
if (loan.getOverpaidOnDate() != null) {
loan.setOverpaidOnDate(null);
}
}
default -> {
}
}
}
}

Expand Down

0 comments on commit c70007e

Please sign in to comment.