adamsaghy commented on code in PR #4503:
URL: https://github.com/apache/fineract/pull/4503#discussion_r2013637556


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualsProcessingServiceImpl.java:
##########
@@ -143,13 +154,34 @@ public void addPeriodicAccruals(@NotNull LocalDate 
tillDate, @NotNull Loan loan)
     public void addAccruals(@NotNull LocalDate tillDate) throws 
JobExecutionException {
         List<Loan> loans = 
loanRepositoryWrapper.findLoansForAddAccrual(AccountingRuleType.ACCRUAL_PERIODIC,
 tillDate,
                 !isChargeOnDueDate());
+
+        List<Future<?>> loanTasks = new ArrayList<>();
+
+        FineractContext context = ThreadLocalContextUtil.getContext();
+
+        loans.forEach(outerLoan -> {
+            loanTasks.add(taskExecutor.submit(() -> {
+                ThreadLocalContextUtil.init(context);
+                transactionTemplate.executeWithoutResult(status -> {
+                    Loan loan = 
loanRepositoryWrapper.findOneWithNotFoundDetection(outerLoan.getId());
+                    setSetHelpers(loan);
+                    try {
+                        log.debug("Adding accruals for loan '{}'", 
loan.getId());
+                        addAccruals(loan, tillDate, false, false, true);
+                        log.debug("Successfully processed loan: '{}' for 
accrual entries", loan.getId());
+                    } catch (Exception e) {
+                        log.error("Failed to add accrual for loan {}", 
loan.getId(), e);
+                        throw new RuntimeException("Failed to add accrual for 
loan " + loan.getId(), e);

Review Comment:
   You should not throw runtime exception, but add it to the errors list which 
will trigger `JobExecutionException` at the end... 



-- 
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]

Reply via email to