fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [fineract] nikpawar89 commented on a change in pull request #738: GSIM and GLIM with test cases (FINERACT-603)
Date Sun, 19 Apr 2020 20:23:50 GMT
nikpawar89 commented on a change in pull request #738: GSIM and GLIM with test cases (FINERACT-603)
URL: https://github.com/apache/fineract/pull/738#discussion_r410983843
 
 

 ##########
 File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/GSIMReadPlatformServiceImpl.java
 ##########
 @@ -0,0 +1,388 @@
+
+/**
+ * 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.savings.service;
+
+import java.math.BigDecimal;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.fineract.infrastructure.core.data.EnumOptionData;
+import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
+import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
+import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
+import org.apache.fineract.organisation.monetary.data.CurrencyData;
+import org.apache.fineract.portfolio.accountdetails.data.SavingsSummaryCustom;
+import org.apache.fineract.portfolio.accountdetails.service.AccountEnumerations;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
+import org.apache.fineract.portfolio.savings.data.GSIMContainer;
+import org.apache.fineract.portfolio.savings.data.GroupSavingsIndividualMonitoringAccountData;
+import org.apache.fineract.portfolio.savings.data.SavingsAccountApplicationTimelineData;
+import org.apache.fineract.portfolio.savings.data.SavingsAccountStatusEnumData;
+import org.apache.fineract.portfolio.savings.data.SavingsAccountSubStatusEnumData;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
+import org.joda.time.LocalDate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Service;
+
+@Service
+public class GSIMReadPlatformServiceImpl implements GSIMReadPlatformService
+{
+
+     private final JdbcTemplate jdbcTemplate;
+     private final PlatformSecurityContext context;
+     private final ColumnValidator columnValidator;
+
+
+
+     @Autowired
+     public GSIMReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource
dataSource
+               ,final ColumnValidator columnValidator) {
+          this.context = context;
+          this.jdbcTemplate = new JdbcTemplate(dataSource);
+          this.columnValidator = columnValidator;
+
+          }
+
+     private static final class GSIMFieldsMapper implements RowMapper<GroupSavingsIndividualMonitoringAccountData>
{
+          public String schema() {
+               return "gsim.id as gsimId,sv.group_id as groupId,sv.client_id as clientId,gsim.account_number
as accountNumber, sv.id as childAccountId,sv.account_no as childAccountNumber,sv.account_balance_derived
as childBalance,gsim.parent_deposit as parentBalance,gsim.child_accounts_count as childAccountsCount,"
+                         +"gsim.savings_status_id as savingsStatus from gsim_accounts gsim,m_savings_account
sv where gsim.id=sv.gsim_id";
+          }
+
+          @Override
+          public GroupSavingsIndividualMonitoringAccountData mapRow(final ResultSet rs, @SuppressWarnings("unused")
final int rowNum)
+                    throws SQLException {
+
+          final BigDecimal gsimId=rs.getBigDecimal("gsimId");
+          final BigDecimal groupId=rs.getBigDecimal("groupId");
+          final BigDecimal clientId=rs.getBigDecimal("clientId");
+          final String accountNumber=rs.getString("accountNumber");
+          final BigDecimal childAccountId=rs.getBigDecimal("childAccountId");
+          final String childAccountNumber=rs.getString("childAccountNumber");
+          final Long childAccountsCount=rs.getLong("childAccountsCount");
+          final BigDecimal parentBalance=rs.getBigDecimal("parentBalance");
+          final BigDecimal childBalance=rs.getBigDecimal("childBalance");
+          final String savingsStatus=SavingsAccountStatusType.fromInt((int)rs.getLong("savingsStatus")).toString();
+          return GroupSavingsIndividualMonitoringAccountData.getInstance2(gsimId,groupId,clientId,accountNumber,childAccountId,childAccountNumber,parentBalance,childBalance,
+                    childAccountsCount,savingsStatus);
+          }
+     }
+
+     private static final class GSIMMapper implements RowMapper<GroupSavingsIndividualMonitoringAccountData>
{
+          public String schema() {
+               return "gsim.id as gsimId,gsim.group_id as groupId,gsim.account_number as
accountNumber,gsim.parent_deposit as parentDeposit,gsim.child_accounts_count as childAccountsCount,"
+                         +"gsim.savings_status_id as savingsStatus from gsim_accounts gsim";
+          }
+
+          @Override
+          public GroupSavingsIndividualMonitoringAccountData mapRow(final ResultSet rs, @SuppressWarnings("unused")
final int rowNum)
+                    throws SQLException {
+
+          final BigDecimal glimId=rs.getBigDecimal("gsimId");
+
+          final BigDecimal groupId=rs.getBigDecimal("groupId");
+
+          final String accountNumber=rs.getString("accountNumber");
+
+          final BigDecimal parentDeposit=rs.getBigDecimal("parentDeposit");
+
+          final String loanStatus=LoanStatus.fromInt((int)rs.getLong("savingsStatus")).toString();
+
+          return GroupSavingsIndividualMonitoringAccountData.getInstance1(glimId,groupId,
accountNumber, parentDeposit,loanStatus);
+
+          }
+     }
+
+     @Override
+     public  Collection<GSIMContainer> findGSIMAccountContainerByGroupId(Long groupId)
{
+          this.context.authenticatedUser();
+          Collection<GroupSavingsIndividualMonitoringAccountData> gsimInfo=findGSIMAccountsByGroupId(groupId+"");
+
+          //List<LoanAccountSummaryData> glimAccounts = retrieveLoanAccountDetails(loanWhereClauseForGroupAndLoanType,
new Object[] { groupId });
+            String savingswhereClauseForGroup;
+
+          List<GSIMContainer> gsimAccounts=new ArrayList<GSIMContainer>();
+          List<SavingsSummaryCustom> childSavings;
+          for(GroupSavingsIndividualMonitoringAccountData gsimAccount:gsimInfo)
+          {
+               savingswhereClauseForGroup = " where sa.group_id = ? and sa.gsim_id="+gsimAccount.getGsimId()+"
order by sa.status_enum ASC, sa.account_no ASC";
 
 Review comment:
   pass gsimID as object param.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message