oleksii-novikov-onix commented on code in PR #4700:
URL: https://github.com/apache/fineract/pull/4700#discussion_r2113452717
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanAccountingBridgeMapper.java:
##########
@@ -73,7 +76,9 @@ public List<AccountingBridgeDataDTO>
deriveAccountingBridgeDataForChargeOff(fina
public AccountingBridgeDataDTO deriveAccountingBridgeData(final String
currencyCode, final List<Long> existingTransactionIds,
final List<Long> existingReversedTransactionIds, final boolean
isAccountTransfer, final Loan loan) {
final List<AccountingBridgeLoanTransactionDTO> newLoanTransactions =
new ArrayList<>();
- for (final LoanTransaction transaction : loan.getLoanTransactions()) {
+
+ // TODO Probably we should not fetch all transactions here
+ for (final LoanTransaction transaction :
loanTransactionRepository.findByLoan(loan)) {
Review Comment:
@adamsaghy I rewrote the logic to fetch all transactions using three
separate queries. I also tried to avoid loading the full LoanTransaction entity
by using JPA interface projections or custom DTOs.
Unfortunately, the data structure is quite complex, for example, we need a
list of `LoanChargePaidBy` items. This can't be achieved using JPQL or
Criteria API.
One possible solution is to use native queries and map the results to DTOs
manually. Another option is to split the logic:
1. First, fetch the list of LoanTransaction objects.
2. Then, fetch the related `LoanChargePaidBy `entries using the transaction
ids.
--
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]