Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2222,18 +2222,103 @@ public void loanTransactionsTabCheck(DataTable table) {
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions();
List<List<String>> data = table.asLists();
List<String> header = table.row(0);
checkLoanTransactionTab(data, transactions, header, resourceId);
}

@Then("Loan Transactions tab has the following new accrual data:")
public void loanTransactionsTabCheckNewAccruals(DataTable table) {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
List<List<String>> expectedAccruals = testContext().get(TestContextKey.VERIFIED_LOAN_ACCRUALS);
if (expectedAccruals == null) {
expectedAccruals = new ArrayList<>();
testContext().set(TestContextKey.VERIFIED_LOAN_ACCRUALS, expectedAccruals);
}
long loanId = loanCreateResponse.getLoanId();
String resourceId = String.valueOf(loanId);
List<GetLoansLoanIdTransactions> transactions = getAccrualTransactions(loanId);
List<List<String>> data = table.asLists();
expectedAccruals.addAll(data.subList(1, data.size()));
List<String> header = table.row(0);

checkLoanTransactionTabRows(expectedAccruals, transactions, header, resourceId);
assertThat(transactions.size())
.as(ErrorMessageHelper.nrOfLinesWrongInTransactionsTab(resourceId, transactions.size(), expectedAccruals.size()))
.isEqualTo(expectedAccruals.size());
}

@Then("Loan Transactions tab has no new accrual data")
public void loanTransactionsTabCheckNoNewAccruals() {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
List<List<String>> expectedAccruals = testContext().get(TestContextKey.VERIFIED_LOAN_ACCRUALS);
if (expectedAccruals == null) {
expectedAccruals = new ArrayList<>();
testContext().set(TestContextKey.VERIFIED_LOAN_ACCRUALS, expectedAccruals);
}
long loanId = loanCreateResponse.getLoanId();
String resourceId = String.valueOf(loanId);

List<GetLoansLoanIdTransactions> transactions = getAccrualTransactions(loanId);
assertThat(transactions.size())
.as(ErrorMessageHelper.nrOfLinesWrongInTransactionsTab(resourceId, transactions.size(), expectedAccruals.size()))
.isEqualTo(expectedAccruals.size());
}

@Then("Loan Transactions tab has the following accrual data:")
public void loanTransactionsTabCheckAccruals(DataTable table) {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.getLoanId();
String resourceId = String.valueOf(loanId);
List<GetLoansLoanIdTransactions> transactions = getAccrualTransactions(loanId);
List<List<String>> data = table.asLists();
List<String> header = table.row(0);

checkLoanTransactionTab(data, transactions, header, resourceId);
}

@Then("Loan Transactions tab has the following data without accruals:")
public void loanTransactionsTabCheckWithoutAccruals(DataTable table) {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.getLoanId();
String resourceId = String.valueOf(loanId);

GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.getTransactions().stream()
.filter(lt -> !lt.getType().getAccrual() && !"Accrual Adjustment".equalsIgnoreCase(lt.getType().getValue())).toList();
List<List<String>> data = table.asLists();
List<String> header = table.row(0);

checkLoanTransactionTab(data, transactions, header, resourceId);
}

public List<GetLoansLoanIdTransactions> getAccrualTransactions(Long loanId) {
GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
return loanDetailsResponse.getTransactions().stream().filter(
lt -> "Accrual".equalsIgnoreCase(lt.getType().getValue()) || "Accrual Adjustment".equalsIgnoreCase(lt.getType().getValue()))
.toList();
}

public void checkLoanTransactionTabRows(List<List<String>> data, List<GetLoansLoanIdTransactions> transactions, List<String> header,
String resourceId) {
for (int i = 1; i < data.size(); i++) {
List<String> expectedValues = data.get(i);
String transactionDateExpected = expectedValues.get(0);
List<List<String>> actualValuesList = transactions.stream()//
.filter(t -> transactionDateExpected.equals(FORMATTER.format(t.getDate())))//
.map(t -> fetchValuesOfTransaction(table.row(0), t))//
.map(t -> fetchValuesOfTransaction(header, t))//
.collect(Collectors.toList());//
boolean containsExpectedValues = actualValuesList.stream()//
.anyMatch(actualValues -> actualValues.equals(expectedValues));//
assertThat(containsExpectedValues)
.as(ErrorMessageHelper.wrongValueInLineInTransactionsTab(resourceId, i, actualValuesList, expectedValues)).isTrue();
}
}

public void checkLoanTransactionTab(List<List<String>> data, List<GetLoansLoanIdTransactions> transactions, List<String> header,
String resourceId) {
checkLoanTransactionTabRows(data, transactions, header, resourceId);
assertThat(transactions.size())
.as(ErrorMessageHelper.nrOfLinesWrongInTransactionsTab(resourceId, transactions.size(), data.size() - 1))
.isEqualTo(data.size() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,5 @@ public abstract class TestContextKey {
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentZeroInterestChargeOffBehaviourAccrualActivity";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_PRINCIPAL_FIRST = "loanProductCreateResponseLP2AdvancedPaymentHorizontalPrincipalFirst";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL_360_30_USD = "loanProductCreateResponseLP2AdvancedPaymentHorizontal36030Usd";
public static final String VERIFIED_LOAN_ACCRUALS = "VERIFIED_LOAN_ACCRUALS";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4175,7 +4175,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 February 2024 | Chargeback | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 100.0 | false | false |
| 15 March 2024 | Re-age | 101.42 | 100.0 | 1.42 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 101.42 | 100.0 | 1.42 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 2.0 | 0.0 | 2.0 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:C4135 @AdvancedPaymentAllocation
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - Charge-back before re-aging and installment is partially paid - UC3.1
Expand Down Expand Up @@ -4274,7 +4274,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 March 2024 | Repayment | 10.0 | 10.0 | 0.0 | 0.0 | 0.0 | 90.0 | false | false |
| 15 March 2024 | Re-age | 91.4 | 90.0 | 1.4 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 91.4 | 90.0 | 1.4 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.98 | 0.0 | 1.98 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:C4356 @AdvancedPaymentAllocation
Scenario: Verify Re-aging on interest bearing loan - Interest calculation: Default Behavior - with NEXT_INSTALLMENT allocation rule, backdated re-aging on 1st installment after repay and chargeback on 1st due - UC3.2
Expand Down Expand Up @@ -4603,7 +4603,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 February 2024 | Accrual Activity | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Re-age | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.22 | 0.0 | 1.22 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual Activity | 0.64 | 0.0 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule

Expand Down Expand Up @@ -4827,7 +4827,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 March 2024 | Accrual Activity | 0.47 | 0.0 | 0.47 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Re-age | 59.21 | 59.05 | 0.16 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 59.21 | 59.05 | 0.16 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.05 | 0.0 | 1.05 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.21 | 0.0 | 1.21 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual Activity | 0.16 | 0.0 | 0.16 | 0.0 | 0.0 | 0.0 | false | false |
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule

Expand Down Expand Up @@ -4927,7 +4927,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 March 2024 | Accrual Activity | 0.49 | 0.0 | 0.49 | 0.0 | 0.0 | 0.0 | false | false |
| 01 April 2024 | Accrual Activity | 0.39 | 0.0 | 0.39 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Repayment | 67.83 | 67.05 | 0.78 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.07 | 0.0 | 1.07 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.85 | 0.0 | 1.85 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual Activity | 0.39 | 0.0 | 0.39 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:C4233
Expand Down Expand Up @@ -5020,7 +5020,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 March 2024 | Re-age | 76.02 | 75.58 | 0.44 | 0.0 | 0.0 | 0.0 | false | false |
| 01 March 2024 | Accrual Activity | 0.44 | 0.0 | 0.44 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.22 | 0.0 | 1.22 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual Activity | 0.2 | 0.0 | 0.2 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:C4085 @AdvancedPaymentAllocation
Expand Down Expand Up @@ -6498,7 +6498,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 February 2024 | Re-age | 83.57 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
| 01 March 2024 | Repayment | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | 66.56 | false | true |
| 01 June 2024 | Repayment | 68.22 | 66.56 | 1.66 | 0.0 | 0.0 | 0.0 | false | false |
| 01 June 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 01 June 2024 | Accrual | 2.24 | 0.0 | 2.24 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:С4268 @AdvancedPaymentAllocation
Scenario: Verify allowing Re-aging on interest bearing loan - Interest calculation: Default Behavior - with LAST_INSTALLMENT allocation rule and partial repayment, due date and frequency changed - UC5.1
Expand Down Expand Up @@ -6591,7 +6591,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 February 2024 | Accrual Activity | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Re-age | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.22 | 0.0 | 1.22 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual Activity | 0.64 | 0.0 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule

Expand Down Expand Up @@ -6697,7 +6697,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 13 April 2024 | Accrual Activity | 0.18 | 0.0 | 0.18 | 0.0 | 0.0 | 0.0 | false | false |
| 27 April 2024 | Accrual Activity | 0.18 | 0.0 | 0.18 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Repayment | 67.83 | 67.05 | 0.78 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.07 | 0.0 | 1.07 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.85 | 0.0 | 1.85 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual Activity | 0.05 | 0.0 | 0.05 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:С4270 @AdvancedPaymentAllocation
Expand Down Expand Up @@ -6790,7 +6790,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 01 March 2024 | Re-age | 76.02 | 75.58 | 0.44 | 0.0 | 0.0 | 0.0 | false | false |
| 01 March 2024 | Accrual Activity | 0.44 | 0.0 | 0.44 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Repayment | 76.22 | 75.58 | 0.64 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 0.58 | 0.0 | 0.58 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual | 1.22 | 0.0 | 1.22 | 0.0 | 0.0 | 0.0 | false | false |
| 15 March 2024 | Accrual Activity | 0.2 | 0.0 | 0.2 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:С4271 @AdvancedPaymentAllocation
Expand Down Expand Up @@ -6895,7 +6895,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 16 April 2024 | Accrual Activity | 0.18 | 0.0 | 0.18 | 0.0 | 0.0 | 0.0 | false | false |
| 30 April 2024 | Accrual Activity | 0.18 | 0.0 | 0.18 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Repayment | 67.82 | 67.05 | 0.77 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.07 | 0.0 | 1.07 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual | 1.84 | 0.0 | 1.84 | 0.0 | 0.0 | 0.0 | false | false |
| 01 May 2024 | Accrual Activity | 0.01 | 0.0 | 0.01 | 0.0 | 0.0 | 0.0 | false | false |

@TestRailId:C4249 @AdvancedPaymentAllocation
Expand Down Expand Up @@ -8520,7 +8520,7 @@ Then Loan Repayment schedule has 4 periods, with the following data for periods:
| 16 April 2024 | Payout Refund | 40.0 | 14.52 | 0.48 | 0.0 | 25.0 | 69.05 | false | false |
| 16 April 2024 | Interest Refund | 0.52 | 0.39 | 0.13 | 0.0 | 0.0 | 68.66 | false | false |
| 17 April 2024 | Repayment | 80.0 | 68.66 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
| 17 April 2024 | Accrual | 25.58 | 0.0 | 0.58 | 0.0 | 25.0 | 0.0 | false | false |
| 17 April 2024 | Accrual | 26.19 | 0.0 | 1.19 | 0.0 | 25.0 | 0.0 | false | false |
| 17 April 2024 | Accrual Activity | 25.13 | 0.0 | 0.13 | 0.0 | 25.0 | 0.0 | false | false |
| 18 April 2024 | Credit Balance Refund | 11.34 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
# --- Close loan ---
Expand Down
Loading
Loading