Skip to content

Commit ee9da2c

Browse files
committed
FINERACT-2354: Re-aging: -Interest Handling Option: Equal amortization -- EMICalculator fix & chargeback handling
1 parent d50196a commit ee9da2c

File tree

5 files changed

+93
-121
lines changed

5 files changed

+93
-121
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAgingStepDef.java

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,11 @@ public void createReAgingTransaction(DataTable table) throws IOException {
7272
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
7373
long loanId = loanResponse.body().getLoanId();
7474

75-
List<List<String>> tableRows = table.asLists();
76-
List<String> headers = tableRows.get(0);
77-
List<String> values = tableRows.get(1);
78-
79-
Map<String, String> rowData = new LinkedHashMap<>();
80-
int columnCount = Math.min(headers.size(), values.size());
81-
for (int i = 0; i < columnCount; i++) {
82-
rowData.put(headers.get(i), values.get(i));
83-
}
84-
85-
int frequencyNumber = Integer.parseInt(resolveValue(rowData, values, 0, "frequencyNumber"));
86-
String frequencyType = resolveValue(rowData, values, 1, "frequencyType");
87-
String startDate = resolveValue(rowData, values, 2, "startDate");
88-
int numberOfInstallments = Integer.parseInt(resolveValue(rowData, values, 3, "numberOfInstallments"));
89-
90-
PostLoansLoanIdTransactionsRequest reAgingRequest = LoanRequestFactory//
91-
.defaultReAgingRequest()//
92-
.frequencyNumber(frequencyNumber)//
93-
.frequencyType(frequencyType)//
94-
.startDate(startDate)//
95-
.numberOfInstallments(numberOfInstallments);//
96-
97-
applyAdditionalFields(reAgingRequest, rowData, Set.of("frequencyNumber", "frequencyType", "startDate", "numberOfInstallments"));
75+
PostLoansLoanIdTransactionsRequest reAgingRequest = setReAgeingRequestProperties(//
76+
LoanRequestFactory.defaultReAgingRequest(), //
77+
table.row(0), //
78+
table.row(1) //
79+
);
9880

9981
Response<PostLoansLoanIdTransactionsResponse> response = loanTransactionsApi.executeLoanTransaction(loanId, reAgingRequest, "reAge")
10082
.execute();
@@ -195,18 +177,11 @@ public void createReAgingTransactionByLoanExternalId(DataTable table) throws IOE
195177
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
196178
String loanExternalId = loanResponse.body().getResourceExternalId();
197179

198-
List<String> data = table.asLists().get(1);
199-
int frequencyNumber = Integer.parseInt(data.get(0));
200-
String frequencyType = data.get(1);
201-
String startDate = data.get(2);
202-
int numberOfInstallments = Integer.parseInt(data.get(3));
203-
204-
PostLoansLoanIdTransactionsRequest reAgingRequest = LoanRequestFactory//
205-
.defaultReAgingRequest()//
206-
.frequencyNumber(frequencyNumber)//
207-
.frequencyType(frequencyType)//
208-
.startDate(startDate)//
209-
.numberOfInstallments(numberOfInstallments);//
180+
PostLoansLoanIdTransactionsRequest reAgingRequest = setReAgeingRequestProperties(//
181+
LoanRequestFactory.defaultReAgingRequest(), //
182+
table.row(0), //
183+
table.row(1) //
184+
);
210185

211186
Response<PostLoansLoanIdTransactionsResponse> response = loanTransactionsApi
212187
.executeLoanTransaction1(loanExternalId, reAgingRequest, "reAge").execute();
@@ -521,4 +496,19 @@ private List<String> validateRepaymentScheduleTotal(List<String> header, LoanSch
521496
return actualValues;
522497
}
523498

499+
PostLoansLoanIdTransactionsRequest setReAgeingRequestProperties(PostLoansLoanIdTransactionsRequest request, List<String> headers,
500+
List<String> values) {
501+
for (int i = 0; i < headers.size(); i++) {
502+
String header = headers.get(i).toLowerCase().trim().replaceAll(" ", "");
503+
switch (header) {
504+
case "frequencynumber" -> request.setFrequencyNumber(Integer.parseInt(values.get(i)));
505+
case "frequencytype" -> request.setFrequencyType(values.get(i));
506+
case "startdate" -> request.setStartDate(values.get(i));
507+
case "numberofinstallments" -> request.setNumberOfInstallments(Integer.parseInt(values.get(i)));
508+
case "reageinteresthandling" -> request.setReAgeInterestHandling(values.get(i));
509+
default -> throw new IllegalStateException("Unknown header: " + header);
510+
}
511+
}
512+
return request;
513+
}
524514
}

0 commit comments

Comments
 (0)