ruchiD commented on code in PR #2928:
URL: https://github.com/apache/fineract/pull/2928#discussion_r1095531494


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/updateloanarrearsageing/LoanArrearsAgeingUpdateHandler.java:
##########
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.portfolio.loanaccount.jobs.updateloanarrearsageing;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
+import 
org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData;
+import 
org.apache.fineract.portfolio.loanaccount.service.LoanArrearsAgingService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class LoanArrearsAgeingUpdateHandler {
+
+    private final JdbcTemplate jdbcTemplate;
+    private final DatabaseSpecificSQLGenerator sqlGenerator;
+    private final LoanArrearsAgingService loanArrearsAgingService;
+
+    private void truncateLoanArrearsAgingDetails() {
+        jdbcTemplate.execute("truncate table m_loan_arrears_aging");
+    }
+
+    private void deleteLoanArrearsAgingDetails(List<Long> loanIds) {
+        // delete existing record for loan from m_loan_arrears_aging table
+        for (Long loanId : loanIds) {
+            jdbcTemplate.update("delete from m_loan_arrears_aging where 
loan_id=?", loanId);
+        }
+    }
+
+    public void updateLoanArrearsAgeingDetailsForAllLoans() {
+        truncateLoanArrearsAgingDetails();
+        String updateSQL = buildQueryForUpdateAgeingDetails(Boolean.TRUE);
+        List<String> insertStatements = 
updateLoanArrearsAgeingDetailsWithOriginalScheduleForAllLoans();
+        insertStatements.add(0, updateSQL);
+        final int[] records = 
this.jdbcTemplate.batchUpdate(insertStatements.toArray(new String[0]));
+        int result = 0;
+        for (int record : records) {
+            result += record;
+        }
+
+        log.debug("{}: Records affected by updateLoanArrearsAgeingDetails: 
{}", ThreadLocalContextUtil.getTenant().getName(), result);

Review Comment:
   done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/updateloanarrearsageing/LoanArrearsAgeingUpdateHandler.java:
##########
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.portfolio.loanaccount.jobs.updateloanarrearsageing;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
+import 
org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData;
+import 
org.apache.fineract.portfolio.loanaccount.service.LoanArrearsAgingService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class LoanArrearsAgeingUpdateHandler {
+
+    private final JdbcTemplate jdbcTemplate;
+    private final DatabaseSpecificSQLGenerator sqlGenerator;
+    private final LoanArrearsAgingService loanArrearsAgingService;
+
+    private void truncateLoanArrearsAgingDetails() {
+        jdbcTemplate.execute("truncate table m_loan_arrears_aging");
+    }
+
+    private void deleteLoanArrearsAgingDetails(List<Long> loanIds) {
+        // delete existing record for loan from m_loan_arrears_aging table
+        for (Long loanId : loanIds) {
+            jdbcTemplate.update("delete from m_loan_arrears_aging where 
loan_id=?", loanId);
+        }
+    }
+
+    public void updateLoanArrearsAgeingDetailsForAllLoans() {
+        truncateLoanArrearsAgingDetails();
+        String updateSQL = buildQueryForUpdateAgeingDetails(Boolean.TRUE);
+        List<String> insertStatements = 
updateLoanArrearsAgeingDetailsWithOriginalScheduleForAllLoans();
+        insertStatements.add(0, updateSQL);
+        final int[] records = 
this.jdbcTemplate.batchUpdate(insertStatements.toArray(new String[0]));
+        int result = 0;

Review Comment:
   done



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