FINERACT-2232: added e2e automation tests for capitalized income validation with future date and COB run

This commit is contained in:
mdmytriv
2025-06-02 13:22:02 +02:00
committed by Adam Saghy
parent 5281c7b17d
commit c44972043e
3 changed files with 128 additions and 0 deletions
@@ -150,6 +150,10 @@ public final class ErrorMessageHelper {
return "Failed data validation due to: exceeds.approved.amount.";
}
public static String addCapitalizedIncomeFutureDateFailure() {
return "Failed data validation due to: cannot.be.in.the.future.";
}
public static String wrongAmountInRepaymentSchedule(int line, BigDecimal actual, BigDecimal expected) {
String lineToStr = String.valueOf(line);
String actualToStr = actual.toString();
@@ -4151,6 +4151,18 @@ public class LoanStepDef extends AbstractStepDef {
.isEqualTo(ErrorMessageHelper.addCapitalizedIncomeExceedApprovedAmountFailure());
}
@Then("Capitalized income with payment type {string} on {string} is forbidden with amount {string} due to future date")
public void capitalizedIncomeForbiddenFutureDate(final String transactionPaymentType, final String transactionDate, final String amount)
throws IOException {
final Response<PostLoansLoanIdTransactionsResponse> capitalizedIncomeResponse = addCapitalizedIncomeToTheLoanOnWithEURTransactionAmount(
transactionPaymentType, transactionDate, amount);
ErrorResponse errorDetails = ErrorResponse.from(capitalizedIncomeResponse);
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addCapitalizedIncomeFutureDateFailure()).isEqualTo(400);
assertThat(errorDetails.getSingleError().getDeveloperMessage())
.isEqualTo(ErrorMessageHelper.addCapitalizedIncomeFutureDateFailure());
}
@Then("LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent is raised on {string}")
public void checkLoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent(final String date) throws IOException {
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
@@ -4259,4 +4271,26 @@ public class LoanStepDef extends AbstractStepDef {
eventAssertion.assertEventRaised(LoanTransactionContractTerminationPostBusinessEvent.class, loanContractTerminationTransactionId);
}
@Then("Capitalized income adjustment with payment type {string} on {string} is forbidden with amount {string} due to future date")
public void capitalizedIncomeAdjustmentForbiddenFutureDate(final String transactionPaymentType, final String transactionDate,
final String amount) throws IOException {
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
final long loanId = loanResponse.body().getLoanId();
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
final List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();
final GetLoansLoanIdTransactions capitalizedIncomeTransaction = transactions.stream()
.filter(t -> "Capitalized Income".equals(t.getType().getValue())).findFirst()
.orElseThrow(() -> new IllegalStateException("No Capitalized Income transaction found for loan " + loanId));
final Response<PostLoansLoanIdTransactionsResponse> capitalizedIncomeAdjustmentResponse = adjustCapitalizedIncome(
transactionPaymentType, transactionDate, amount, capitalizedIncomeTransaction.getId());
ErrorResponse errorDetails = ErrorResponse.from(capitalizedIncomeAdjustmentResponse);
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addCapitalizedIncomeFutureDateFailure()).isEqualTo(400);
assertThat(errorDetails.getSingleError().getDeveloperMessage())
.isEqualTo(ErrorMessageHelper.addCapitalizedIncomeFutureDateFailure());
}
}
@@ -2837,3 +2837,93 @@ Feature: Capitalized Income
| 01 February 2024 | Capitalized Income Amortization | 0.83 | 0.0 | 0.83 | 0.0 | 0.0 | 0.0 | false |
| 01 March 2024 | Repayment | 50.89 | 50.3 | 0.59 | 0.0 | 0.0 | 49.99 | false |
| 02 March 2024 | Capitalized Income Adjustment | 50.0 | 49.99 | 0.01 | 0.0 | 0.0 | 0.0 | false |
@TestRailId:C3716
Scenario: Verify Capitalized Income/Adjustment validation - Transaction date can't be in a future
When Admin sets the business date to "01 January 2024"
And Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC | 01 January 2024 | 150 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 January 2024" with "150" amount and expected disbursement date on "01 January 2024"
And Admin successfully disburse the loan on "01 January 2024" with "50" EUR transaction amount
# try do add capitalized income with future date
Then Capitalized income with payment type "AUTOPAY" on "01 February 2024" is forbidden with amount "20" due to future date
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "01 January 2024" with "50" EUR transaction amount
Then Loan status will be "ACTIVE"
When Admin sets the business date to "01 February 2024"
Then Capitalized income with payment type "AUTOPAY" on "01 March 2024" is forbidden with amount "20" due to future date
# try do add capitalized income adjustment with future date
Then Capitalized income adjustment with payment type "AUTOPAY" on "01 March 2024" is forbidden with amount "20" due to future date
And Admin adds capitalized income adjustment with "AUTOPAY" payment type to the loan on "01 February 2024" with "30" EUR transaction amount
Then Capitalized income adjustment with payment type "AUTOPAY" on "01 April 2024" is forbidden with amount "10" due to future date
@TestRailId:C3717
Scenario: Verify Capitalized Income validation while run COB at first day of loan
When Admin sets the business date to "01 January 2024"
And Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC | 01 January 2024 | 150 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 January 2024" with "150" amount and expected disbursement date on "01 January 2024"
And Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "01 January 2024" with "50" EUR transaction amount
And Admin runs inline COB job for Loan
Then Loan Repayment schedule has 3 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 01 January 2024 | | 50.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 01 February 2024 | | 100.29 | 49.71 | 0.87 | 0.0 | 0.0 | 50.58 | 0.0 | 0.0 | 0.0 | 50.58 |
| 2 | 29 | 01 March 2024 | | 50.3 | 49.99 | 0.59 | 0.0 | 0.0 | 50.58 | 0.0 | 0.0 | 0.0 | 50.58 |
| 3 | 31 | 01 April 2024 | | 0.0 | 50.3 | 0.29 | 0.0 | 0.0 | 50.59 | 0.0 | 0.0 | 0.0 | 50.59 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 150.0 | 1.75 | 0.00 | 0.00 | 151.75 | 0.0 | 0.0 | 0.0 | 151.75 |
And Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false |
| 01 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 150.0 | false |
When Admin sets the business date to "02 January 2024"
And Admin runs inline COB job for Loan
And 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 |
| 01 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 150.0 | false | false |
| 01 January 2024 | Capitalized Income Amortization | 0.55 | 0.0 | 0.55 | 0.0 | 0.0 | 0.0 | false | false |
@TestRailId:C3718
Scenario: Verify Capitalized Income Adjustment validation while run COB at first day of loan
When Admin sets the business date to "01 January 2024"
And Admin creates a client with random data
When Admin creates a fully customized loan with the following data:
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC | 01 January 2024 | 200 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 3 | MONTHS | 1 | MONTHS | 3 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
And Admin successfully approves the loan on "01 January 2024" with "200" amount and expected disbursement date on "01 January 2024"
And Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "01 January 2024" with "50" EUR transaction amount
And Admin adds capitalized income adjustment with "AUTOPAY" payment type to the loan on "01 January 2024" with "40" EUR transaction amount
And Admin runs inline COB job for Loan
Then Loan Repayment schedule has 3 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 01 January 2024 | | 50.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 01 February 2024 | | 100.06 | 49.94 | 0.64 | 0.0 | 0.0 | 50.58 | 40.0 | 40.0 | 0.0 | 10.58 |
| 2 | 29 | 01 March 2024 | | 50.06 | 50.0 | 0.58 | 0.0 | 0.0 | 50.58 | 0.0 | 0.0 | 0.0 | 50.58 |
| 3 | 31 | 01 April 2024 | | 0.0 | 50.06 | 0.29 | 0.0 | 0.0 | 50.35 | 0.0 | 0.0 | 0.0 | 50.35 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 150.0 | 1.51 | 0.00 | 0.00 | 151.51 | 40.0 | 40.0 | 0.0 | 111.51 |
And 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 |
| 01 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 150.0 | false | false |
| 01 January 2024 | Capitalized Income Adjustment | 40.0 | 40.0 | 0.0 | 0.0 | 0.0 | 110.0 | false | false |
When Admin sets the business date to "02 January 2024"
And Admin runs inline COB job for Loan
And 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 |
| 01 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 150.0 | false | false |
| 01 January 2024 | Capitalized Income Adjustment | 40.0 | 40.0 | 0.0 | 0.0 | 0.0 | 110.0 | false | false |
| 01 January 2024 | Capitalized Income Amortization | 0.11 | 0.0 | 0.11 | 0.0 | 0.0 | 0.0 | false | false |