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 @@ -2290,6 +2290,17 @@ public void loanTransactionsTabCheckNewAccruals(DataTable table) {
.isEqualTo(expectedAccruals.size());
}

@Then("Loan has {double} total Accruals")
public void loanTransactionsTabCheckTotalAccruals(Double totalAccruedExpected) {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.getLoanId();
List<GetLoansLoanIdTransactions> transactions = getAccrualTransactions(loanId);
BigDecimal totalAccruedActual = transactions.stream().map(t -> isLoanTransactionAccrual(t) ? t.getAmount() : t.getAmount().negate())
.reduce(BigDecimal.ZERO, BigDecimal::add);

assertEquals(totalAccruedExpected, totalAccruedActual.doubleValue());
}

@Then("Loan Transactions tab has no new accrual data")
public void loanTransactionsTabCheckNoNewAccruals() {
PostLoansResponse loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
Expand Down Expand Up @@ -2335,12 +2346,19 @@ public void loanTransactionsTabCheckWithoutAccruals(DataTable table) {
checkLoanTransactionTab(data, transactions, header, resourceId);
}

private boolean isLoanTransactionAccrual(GetLoansLoanIdTransactions lt) {
return "Accrual".equalsIgnoreCase(lt.getType().getValue());
}

private boolean isLoanTransactionAccrualAdjustment(GetLoansLoanIdTransactions lt) {
return "Accrual Adjustment".equalsIgnoreCase(lt.getType().getValue());
}

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();
return loanDetailsResponse.getTransactions().stream()
.filter(lt -> isLoanTransactionAccrual(lt) || isLoanTransactionAccrualAdjustment(lt)).toList();
}

public void checkLoanTransactionTabRows(List<List<String>> data, List<GetLoansLoanIdTransactions> transactions, List<String> header,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9366,16 +9366,16 @@ Feature: LoanReAgingEqualAmortization
| frequencyNumber | frequencyType | startDate | numberOfInstallments | reAgeInterestHandling |
| 1 | MONTHS | 15 February 2024 | 6 | EQUAL_AMORTIZATION_FULL_INTEREST |
Then Loan Repayment schedule has 8 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 | | | |
| 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 |
| 2 | 14 | 15 February 2024 | 15 February 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 3 | 0 | 15 February 2024 | | 69.64 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 4 | 29 | 15 March 2024 | | 55.71 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 5 | 31 | 15 April 2024 | | 41.77 | 13.94 | 0.24 | 0.0 | 0.0 | 14.18 | 0.0 | 0.0 | 0.0 | 14.18 |
| 6 | 30 | 15 May 2024 | | 27.83 | 13.94 | 0.24 | 0.0 | 0.0 | 14.18 | 0.0 | 0.0 | 0.0 | 14.18 |
| 7 | 31 | 15 June 2024 | | 13.89 | 13.94 | 0.24 | 0.0 | 0.0 | 14.18 | 0.0 | 0.0 | 0.0 | 14.18 |
| 8 | 30 | 15 July 2024 | | 0.0 | 13.89 | 0.27 | 0.0 | 0.0 | 14.16 | 0.0 | 0.0 | 0.0 | 14.16 |
| 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 | | | |
| 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 |
| 2 | 14 | 15 February 2024 | 15 February 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 3 | 0 | 15 February 2024 | | 69.64 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 4 | 29 | 15 March 2024 | | 55.71 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 5 | 31 | 15 April 2024 | | 41.78 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 6 | 30 | 15 May 2024 | | 27.85 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 7 | 31 | 15 June 2024 | | 13.92 | 13.93 | 0.24 | 0.0 | 0.0 | 14.17 | 0.0 | 0.0 | 0.0 | 14.17 |
| 8 | 30 | 15 July 2024 | | 0.0 | 13.92 | 0.27 | 0.0 | 0.0 | 14.19 | 0.0 | 0.0 | 0.0 | 14.19 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 100.0 | 2.05 | 0.0 | 0.0 | 102.05 | 17.01 | 0.0 | 0.0 | 85.04 |
Expand Down
Loading
Loading