fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] incubator-fineract git commit: FINERACT-378 and 379 : Can not link a Saving account to during Group Loan Application and Bluck JLG Loan application
Date Mon, 13 Mar 2017 12:01:38 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop b5c130736 -> a8f386811


FINERACT-378 and 379 : Can not link a Saving account to during Group Loan Application and
Bluck JLG Loan application


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/0296fd43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/0296fd43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/0296fd43

Branch: refs/heads/develop
Commit: 0296fd4351f78d3d7758167bdc58fa2ca3e4f2db
Parents: f1f3d65
Author: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Authored: Fri Mar 10 13:45:54 2017 +0530
Committer: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Committed: Fri Mar 10 13:45:54 2017 +0530

----------------------------------------------------------------------
 .../account/data/PortfolioAccountDTO.java       |  9 ++++++
 ...PortfolioAccountReadPlatformServiceImpl.java | 29 +++++++++++++-----
 .../loanaccount/api/LoansApiResource.java       | 32 +++++++++++++-------
 3 files changed, 52 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/0296fd43/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountDTO.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountDTO.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountDTO.java
index b259ff1..5b9be0b 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountDTO.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/data/PortfolioAccountDTO.java
@@ -22,6 +22,7 @@ public class PortfolioAccountDTO {
 
     private final Integer accountTypeId;
     private final Long clientId;
+    private Long groupId;
     private final String currencyCode;
     private final long[] accountStatus;
     private final Integer depositType;
@@ -79,5 +80,13 @@ public class PortfolioAccountDTO {
     public boolean isExcludeOverDraftAccounts() {
         return this.excludeOverDraftAccounts;
     }
+    
+    public Long getGroupId() {
+        return this.groupId;
+    }
+    
+    public void setGroupId(final Long groupId) {
+        this.groupId = groupId;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/0296fd43/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/PortfolioAccountReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/PortfolioAccountReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/PortfolioAccountReadPlatformServiceImpl.java
index 0c323dd..dc4edb1 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/PortfolioAccountReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/PortfolioAccountReadPlatformServiceImpl.java
@@ -104,8 +104,8 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
     @Override
     public Collection<PortfolioAccountData> retrieveAllForLookup(final PortfolioAccountDTO
portfolioAccountDTO) {
 
-        List<Object> sqlParams = new ArrayList<>();
-        sqlParams.add(portfolioAccountDTO.getClientId());
+        final List<Object> sqlParams = new ArrayList<>();
+        //sqlParams.add(portfolioAccountDTO.getClientId());
         Collection<PortfolioAccountData> accounts = null;
         String sql = null;
         String defaultAccountStatus = "300";
@@ -120,8 +120,13 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
             case INVALID:
             break;
             case LOAN:
-                sql = "select " + this.loanAccountMapper.schema() + " where la.client_id
= ? and la.loan_status_id in ("
-                        + defaultAccountStatus.toString() + ")";
+                sql = "select " + this.loanAccountMapper.schema() + " where ";
+                if (portfolioAccountDTO.getClientId() != null) {
+                    sql += " la.client_id = ? and la.loan_status_id in (" + defaultAccountStatus.toString()
+ ") ";
+                    sqlParams.add(portfolioAccountDTO.getClientId());
+                } else {
+                    sql += " la.loan_status_id in (" + defaultAccountStatus.toString() +
") ";
+                }
                 if (portfolioAccountDTO.getCurrencyCode() != null) {
                     sql += " and la.currency_code = ?";
                     sqlParams.add(portfolioAccountDTO.getCurrencyCode());
@@ -130,8 +135,13 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
                 accounts = this.jdbcTemplate.query(sql, this.loanAccountMapper, sqlParams.toArray());
             break;
             case SAVINGS:
-                sql = "select " + this.savingsAccountMapper.schema() + " where sa.client_id
= ? and sa.status_enum in ("
-                        + defaultAccountStatus.toString() + ")";
+                sql = "select " + this.savingsAccountMapper.schema() + " where ";
+                if (portfolioAccountDTO.getClientId() != null) {
+                    sql += " sa.client_id = ? and sa.status_enum in (" + defaultAccountStatus.toString()
+ ") ";
+                    sqlParams.add(portfolioAccountDTO.getClientId());
+                } else {
+                    sql += " sa.status_enum in (" + defaultAccountStatus.toString() + ")
";
+                }
                 if (portfolioAccountDTO.getCurrencyCode() != null) {
                     sql += " and sa.currency_code = ?";
                     sqlParams.add(portfolioAccountDTO.getCurrencyCode());
@@ -145,7 +155,12 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
                 if(portfolioAccountDTO.isExcludeOverDraftAccounts()){
                     sql += " and sa.allow_overdraft = 0";
                 }
-
+                
+                if(portfolioAccountDTO.getClientId() == null && portfolioAccountDTO.getGroupId()
!= null){
+                    sql += " and sa.group_id = ? ";
+                    sqlParams.add(portfolioAccountDTO.getGroupId());
+                }
+                
                 accounts = this.jdbcTemplate.query(sql, this.savingsAccountMapper, sqlParams.toArray());
             break;
             default:

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/0296fd43/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
index bded415..8da89c0 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
@@ -267,6 +267,7 @@ public class LoansApiResource {
         Collection<CalendarData> calendarOptions = null;
         LoanAccountData newLoanAccount = null;
         Long officeId = null;
+        Collection<PortfolioAccountData> accountLinkingOptions = null;
 
         if (productId != null) {
             newLoanAccount = this.loanReadPlatformService.retrieveLoanProductDetailsTemplate(productId,
clientId, groupId);
@@ -306,6 +307,7 @@ public class LoansApiResource {
                 calendarOptions = this.loanReadPlatformService.retrieveCalendars(groupId);
                 newLoanAccount = newLoanAccount == null ? loanAccountGroupData : LoanAccountData.populateGroupDefaults(newLoanAccount,
                         loanAccountGroupData);
+                accountLinkingOptions = getaccountLinkingOptions(newLoanAccount, clientId,
groupId);
 
             } else if (templateType.equals("jlgbulk")) {
                 // get group details along with members in that group
@@ -317,9 +319,11 @@ public class LoansApiResource {
                 if (productId != null) {
                     Map<Long, Integer> memberLoanCycle = new HashMap<>();
                     Collection<ClientData> members = loanAccountGroupData.groupData().clientMembers();
+                    accountLinkingOptions = new ArrayList<>();
                     for (ClientData clientData : members) {
                         Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(),
productId);
                         memberLoanCycle.put(clientData.id(), loanCounter);
+                        accountLinkingOptions.addAll(getaccountLinkingOptions(newLoanAccount,
clientData.id(), groupId));
                     }
                     newLoanAccount = LoanAccountData.associateMemberVariations(newLoanAccount,
memberLoanCycle);
                 }
@@ -331,18 +335,8 @@ public class LoansApiResource {
 
             allowedLoanOfficers = this.loanReadPlatformService.retrieveAllowedLoanOfficers(officeId,
staffInSelectedOfficeOnly);
 
-            Collection<PortfolioAccountData> accountLinkingOptions = null;
             if (clientId != null) {
-                final CurrencyData currencyData = newLoanAccount.currency();
-                String currencyCode = null;
-                if (currencyData != null) {
-                    currencyCode = currencyData.code();
-                }
-                final long[] accountStatus = { SavingsAccountStatusType.ACTIVE.getValue()
};
-                PortfolioAccountDTO portfolioAccountDTO = new PortfolioAccountDTO(PortfolioAccountType.SAVINGS.getValue(),
clientId,
-                        currencyCode, accountStatus, DepositAccountType.SAVINGS_DEPOSIT.getValue());
-                accountLinkingOptions = this.portfolioAccountReadPlatformService.retrieveAllForLookup(portfolioAccountDTO);
-
+                accountLinkingOptions = getaccountLinkingOptions(newLoanAccount, clientId,
groupId);
             }
 
             // add product options, allowed loan officers and calendar options
@@ -358,6 +352,22 @@ public class LoansApiResource {
         return this.toApiJsonSerializer.serialize(settings, newLoanAccount, this.LOAN_DATA_PARAMETERS);
     }
 
+    private Collection<PortfolioAccountData> getaccountLinkingOptions(final LoanAccountData
newLoanAccount, final Long clientId,
+            final Long groupId) {
+        final CurrencyData currencyData = newLoanAccount.currency();
+        String currencyCode = null;
+        if (currencyData != null) {
+            currencyCode = currencyData.code();
+        }
+        final long[] accountStatus = { SavingsAccountStatusType.ACTIVE.getValue() };
+        final PortfolioAccountDTO portfolioAccountDTO = new PortfolioAccountDTO(PortfolioAccountType.SAVINGS.getValue(),
clientId, currencyCode,
+                accountStatus, DepositAccountType.SAVINGS_DEPOSIT.getValue());
+        if (groupId != null) {
+            portfolioAccountDTO.setGroupId(groupId);
+        }
+        return this.portfolioAccountReadPlatformService.retrieveAllForLookup(portfolioAccountDTO);
+    }
+    
     @GET
     @Path("{loanId}")
     @Consumes({ MediaType.APPLICATION_JSON })


Mime
View raw message