adamsaghy commented on code in PR #4446:
URL: https://github.com/apache/fineract/pull/4446#discussion_r1987086362
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/ReprocessLoanTransactionsServiceImpl.java:
##########
@@ -63,12 +67,49 @@ public void removeLoanCharge(final Loan loan, final
LoanCharge loanCharge) {
loan.removeLoanCharge(loanCharge).ifPresent(this::handleChangedDetail);
}
+ @Override
+ public void processLatestTransaction(final LoanTransaction
loanTransaction, final Loan loan) {
+ final ChangedTransactionDetail changedTransactionDetail =
loan.getTransactionProcessor().processLatestTransaction(loanTransaction,
+ new TransactionCtx(loan.getCurrency(),
loan.getRepaymentScheduleInstallments(), loan.getActiveCharges(),
+ new MoneyHolder(loan.getTotalOverpaidAsMoney()), new
ChangedTransactionDetail()));
+ if (!loan.isInterestRecalculationEnabled()) {
+ final List<LoanTransaction> newTransactions =
changedTransactionDetail.getTransactionChanges().stream()
+
.map(TransactionChangeData::getNewTransaction).peek(transaction ->
transaction.updateLoan(loan)).toList();
+
+ loan.getLoanTransactions().addAll(newTransactions);
+ }
+
+ loan.updateLoanSummaryDerivedFields();
+ handleChangedDetail(changedTransactionDetail);
+ }
+
private void handleChangedDetail(final ChangedTransactionDetail
changedTransactionDetail) {
- for (final Map.Entry<Long, LoanTransaction> mapEntry :
changedTransactionDetail.getNewTransactionMappings().entrySet()) {
-
loanAccountService.saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
-
loanAccountTransfersService.updateLoanTransaction(mapEntry.getKey(),
mapEntry.getValue());
+ final List<TransactionChangeData> sortedChanges =
changedTransactionDetail.getTransactionChanges().stream()
Review Comment:
Why to resort them? the list should contain in the right order the created /
reversed / reverse-replayed transactions.
--
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]