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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java:
##########
@@ -1386,4 +1388,110 @@ public List<Long> getAccountsIdsByStatusPaged(Integer 
status, int pageSize, Long
     public Long retrieveAccountIdByExternalId(final ExternalId externalId) {
         return savingsAccountRepositoryWrapper.findIdByExternalId(externalId);
     }
+
+    @Override
+    public List<SavingsAccrualData> retrievePeriodicAccrualData(LocalDate 
tillDate, SavingsAccount savings) {
+        final SavingAccrualMapper mapper = new SavingAccrualMapper();
+        final StringBuilder sqlBuilder = new StringBuilder(400);
+        sqlBuilder.append(" select " + mapper.schema() + " where ");
+
+        sqlBuilder.append(" savings.status_enum = ? ");
+        sqlBuilder.append(" and (savings.nominal_annual_interest_rate is not 
null and savings.nominal_annual_interest_rate > 0) ");
+        sqlBuilder.append(" and msp.accounting_type = ? ");
+        sqlBuilder.append(" and (savings.closedon_date <= ? or 
savings.closedon_date is null) ");
+        sqlBuilder.append(" and (savings.accrued_till_date <= ? or 
savings.accrued_till_date is null) ");
+        if (savings != null) {
+            sqlBuilder.append(" and savings.id = " + savings.getId());
+        }
+        sqlBuilder.append(" order by savings.id ");
+        try {
+            return this.jdbcTemplate.query(sqlBuilder.toString(), mapper, new 
Object[] { SavingsAccountStatusType.ACTIVE.getValue(),
+                    AccountingRuleType.ACCRUAL_PERIODIC.getValue(), tillDate, 
tillDate });
+        } catch (EmptyResultDataAccessException e) {
+            return new ArrayList<>();
+        }
+    }
+
+    private static final class SavingAccrualMapper implements 
RowMapper<SavingsAccrualData> {
+
+        private final String schemaSql;
+
+        SavingAccrualMapper() {

Review Comment:
   Can we use JPQL here instead of native queries?



-- 
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: commits-unsubscr...@fineract.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to