adamsaghy commented on code in PR #4432:
URL: https://github.com/apache/fineract/pull/4432#discussion_r1987643114
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java:
##########
@@ -596,6 +599,27 @@ public LoanTransactionData retrieveLoanTransaction(final
Long loanId, final Long
}
}
+ @Override
+ public org.springframework.data.domain.Page<LoanTransactionData>
retrieveLoanTransactions(
+ @jakarta.validation.constraints.NotNull Long loanId,
Set<LoanTransactionType> excludedTransactionTypes, Pageable pageable) {
+ final org.springframework.data.domain.Page<LoanTransaction>
transactionPage = loanTransactionRepository
+ .findAll((root, query, builder) -> {
+ List<Predicate> predicates = new ArrayList<>();
+
+ final Join<Object, Object> loanjoin = root.join("loan");
+ predicates.add(builder.equal(loanjoin.get("id"), loanId));
+
+ if (excludedTransactionTypes != null &&
!excludedTransactionTypes.isEmpty()) {
+ final List<Integer> excludedTransactionTypeValues =
excludedTransactionTypes.stream()
+ .map(LoanTransactionType::getValue).toList();
+
predicates.add(builder.not(root.get("typeOf").in(excludedTransactionTypeValues)));
+ }
+ return builder.and(predicates.toArray(new Predicate[] {}));
+ }, pageable);
+
+ return transactionPage.map(x ->
x.toData(x.getLoan().getCurrency().toData(), null));
Review Comment:
I wonder whether it would be better to change the
`org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction#toData` to
not accept any incoming parameter, rather it is using only the fields that he
fetched.
As far as i see noone else is using this method, so we can rework a little
bit... maybe we can move the whole mapping out from the LoanTransaction entity
into a mapper.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]