FINERACT-2181: Update outstandingBalance when the LoanInterestRecalculationCOBBusinessStep of COB job is executed
This commit is contained in:
committed by
Adam Saghy
parent
2644981424
commit
38a5686df8
+37
@@ -1888,6 +1888,25 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
.isEqualTo(totalOutstandingExpected);
|
||||
}
|
||||
|
||||
@Then("Loan has {double} interest outstanding amount")
|
||||
public void loanInterestOutstanding(double totalInterestOutstandingExpected) throws IOException {
|
||||
final Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
assert loanCreateResponse.body() != null;
|
||||
final long loanId = loanCreateResponse.body().getLoanId();
|
||||
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
testContext().set(TestContextKey.LOAN_RESPONSE, loanDetailsResponse);
|
||||
|
||||
assert loanDetailsResponse.body() != null;
|
||||
assert loanDetailsResponse.body().getSummary() != null;
|
||||
assert loanDetailsResponse.body().getSummary().getInterestOutstanding() != null;
|
||||
final double totalInterestOutstandingActual = loanDetailsResponse.body().getSummary().getInterestOutstanding().doubleValue();
|
||||
assertThat(totalInterestOutstandingActual)
|
||||
.as(ErrorMessageHelper.wrongAmountInTotalOutstanding(totalInterestOutstandingActual, totalInterestOutstandingExpected))
|
||||
.isEqualTo(totalInterestOutstandingExpected);
|
||||
}
|
||||
|
||||
@Then("Loan has {double} overpaid amount")
|
||||
public void loanOverpaid(double totalOverpaidExpected) throws IOException {
|
||||
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
@@ -1922,6 +1941,24 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
.isEqualTo(totalOverdueExpected);
|
||||
}
|
||||
|
||||
@Then("Loan has {double} total interest overdue amount")
|
||||
public void loanInterestOverdue(final double totalInterestOverdueExpected) throws IOException {
|
||||
final Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
assert loanCreateResponse.body() != null;
|
||||
final long loanId = loanCreateResponse.body().getLoanId();
|
||||
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
testContext().set(TestContextKey.LOAN_RESPONSE, loanDetailsResponse);
|
||||
|
||||
assert Objects.requireNonNull(loanDetailsResponse.body()).getSummary() != null;
|
||||
assert loanDetailsResponse.body().getSummary().getInterestOverdue() != null;
|
||||
final double totalInterestOverdueActual = loanDetailsResponse.body().getSummary().getInterestOverdue().doubleValue();
|
||||
assertThat(totalInterestOverdueActual)
|
||||
.as(ErrorMessageHelper.wrongAmountInTotalOverdue(totalInterestOverdueActual, totalInterestOverdueExpected))
|
||||
.isEqualTo(totalInterestOverdueExpected);
|
||||
}
|
||||
|
||||
@Then("Loan has {double} last payment amount")
|
||||
public void loanLastPaymentAmount(double lastPaymentAmountExpected) throws IOException {
|
||||
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
|
||||
@@ -2171,6 +2171,10 @@ Feature: EMI calculation and repayment schedule checks for interest bearing loan
|
||||
Then Loan Repayment schedule has the following data in Total row:
|
||||
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
|
||||
| 100.0 | 2.21 | 0.0 | 0.0 | 102.21 | 0.0 | 0.0 | 0.0 | 102.21 |
|
||||
Then Loan has 102.21 outstanding amount
|
||||
Then Loan has 2.21 interest outstanding amount
|
||||
Then Loan has 34.02 total overdue amount
|
||||
Then Loan has 1.16 total interest overdue amount
|
||||
Then Loan Transactions tab has the following data:
|
||||
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
|
||||
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
|
||||
|
||||
+1
@@ -2428,6 +2428,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
} else {
|
||||
loanScheduleService.recalculateScheduleFromLastTransaction(loan, null, existingTransactionIds, existingReversedTransactionIds,
|
||||
true);
|
||||
loanBalanceService.updateLoanSummaryDerivedFields(loan);
|
||||
loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
||||
businessEventNotifierService.notifyPostBusinessEvent(new LoanInterestRecalculationBusinessEvent(loan));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user