group retrive accountdetails API changes
This commit is contained in:
+9
-38
@@ -8,8 +8,7 @@ package org.mifosplatform.organisation.staff.data;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.portfolio.client.data.ClientLoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.LoanAccountSummaryData;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -17,23 +16,23 @@ import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
public class StaffAccountSummaryCollectionData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final List<ClientSummary> clients;
|
||||
private final List<LoanAccountSummary> clients;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<GroupSummary> groups;
|
||||
private final List<LoanAccountSummary> groups;
|
||||
|
||||
public StaffAccountSummaryCollectionData(final List<ClientSummary> clients, final List<GroupSummary> groups) {
|
||||
public StaffAccountSummaryCollectionData(final List<LoanAccountSummary> clients, final List<LoanAccountSummary> groups) {
|
||||
this.clients = clients;
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
public static final class ClientSummary {
|
||||
public static final class LoanAccountSummary {
|
||||
|
||||
private final Long id;
|
||||
private final String displayName;
|
||||
|
||||
private Collection<ClientLoanAccountSummaryData> loans;
|
||||
private Collection<LoanAccountSummaryData> loans;
|
||||
|
||||
public ClientSummary(Long id, String displayName) {
|
||||
public LoanAccountSummary(Long id, String displayName) {
|
||||
this.id = id;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
@@ -46,41 +45,13 @@ public class StaffAccountSummaryCollectionData {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public Collection<ClientLoanAccountSummaryData> getLoans() {
|
||||
public Collection<LoanAccountSummaryData> getLoans() {
|
||||
return loans;
|
||||
}
|
||||
|
||||
public void setLoans(Collection<ClientLoanAccountSummaryData> loans) {
|
||||
public void setLoans(Collection<LoanAccountSummaryData> loans) {
|
||||
this.loans = loans;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class GroupSummary {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
|
||||
private Collection<GroupAccountSummaryData> loans;
|
||||
|
||||
public GroupSummary(Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Collection<GroupAccountSummaryData> getLoans() {
|
||||
return loans;
|
||||
}
|
||||
|
||||
public void setLoans(Collection<GroupAccountSummaryData> loans) {
|
||||
this.loans = loans;
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.accountdetails.data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Immutable data object representing a summary of various accounts.
|
||||
*/
|
||||
public class AccountSummaryCollectionData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<LoanAccountSummaryData> loanAccounts;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<SavingsAccountSummaryData> savingsAccounts;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<LoanAccountSummaryData> memberLoanAccounts;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<SavingsAccountSummaryData> memberSavingsAccounts;
|
||||
|
||||
public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,
|
||||
final Collection<SavingsAccountSummaryData> savingsAccounts) {
|
||||
this.loanAccounts = defaultLoanAccountsIfEmpty(loanAccounts);
|
||||
this.savingsAccounts = defaultSavingsAccountsIfEmpty(savingsAccounts);
|
||||
this.memberLoanAccounts = null;
|
||||
this.memberSavingsAccounts = null;
|
||||
}
|
||||
|
||||
public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,
|
||||
final Collection<SavingsAccountSummaryData> savingsAccounts, final Collection<LoanAccountSummaryData> memberLoanAccounts,
|
||||
Collection<SavingsAccountSummaryData> memberSavingsAccounts) {
|
||||
this.loanAccounts = defaultLoanAccountsIfEmpty(loanAccounts);
|
||||
this.savingsAccounts = defaultSavingsAccountsIfEmpty(savingsAccounts);
|
||||
this.memberLoanAccounts = defaultLoanAccountsIfEmpty(memberLoanAccounts);
|
||||
this.memberSavingsAccounts = defaultSavingsAccountsIfEmpty(memberSavingsAccounts);
|
||||
}
|
||||
|
||||
private Collection<LoanAccountSummaryData> defaultLoanAccountsIfEmpty(final Collection<LoanAccountSummaryData> collection) {
|
||||
Collection<LoanAccountSummaryData> returnCollection = null;
|
||||
if (collection != null && !collection.isEmpty()) {
|
||||
returnCollection = collection;
|
||||
}
|
||||
return returnCollection;
|
||||
}
|
||||
|
||||
private Collection<SavingsAccountSummaryData> defaultSavingsAccountsIfEmpty(final Collection<SavingsAccountSummaryData> collection) {
|
||||
Collection<SavingsAccountSummaryData> returnCollection = null;
|
||||
if (collection != null && !collection.isEmpty()) {
|
||||
returnCollection = collection;
|
||||
}
|
||||
return returnCollection;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -3,16 +3,16 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.data;
|
||||
package org.mifosplatform.portfolio.accountdetails.data;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
|
||||
/**
|
||||
* Immutable data object for client loan accounts.
|
||||
* Immutable data object for loan accounts.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientLoanAccountSummaryData {
|
||||
public class LoanAccountSummaryData {
|
||||
|
||||
private final Long id;
|
||||
private final String accountNo;
|
||||
@@ -23,7 +23,7 @@ public class ClientLoanAccountSummaryData {
|
||||
private final EnumOptionData loanType;
|
||||
private final Integer loanCycle;
|
||||
|
||||
public ClientLoanAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
public LoanAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String loanProductName, final LoanStatusEnumData loanStatus, final EnumOptionData loanType, final Integer loanCycle) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
+4
-4
@@ -3,7 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.data;
|
||||
package org.mifosplatform.portfolio.accountdetails.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -11,10 +11,10 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountStatusEnumData;
|
||||
|
||||
/**
|
||||
* Immutable data object for client savings accounts.
|
||||
* Immutable data object for savings accounts.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientSavingsAccountSummaryData {
|
||||
public class SavingsAccountSummaryData {
|
||||
|
||||
private final Long id;
|
||||
private final String accountNo;
|
||||
@@ -25,7 +25,7 @@ public class ClientSavingsAccountSummaryData {
|
||||
private final CurrencyData currency;
|
||||
private final BigDecimal accountBalance;
|
||||
|
||||
public ClientSavingsAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
public SavingsAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String productName, final SavingsAccountStatusEnumData status, final CurrencyData currency,
|
||||
final BigDecimal accountBalance) {
|
||||
this.id = id;
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.accountdetails.domain;
|
||||
|
||||
/**
|
||||
* Enum representation of account types .
|
||||
*/
|
||||
public enum AccountType {
|
||||
|
||||
INVALID(0, "accountType.invalid"), //
|
||||
INDIVIDUAL(1, "accountType.individual"), //
|
||||
GROUP(2, "accountType.group"), //
|
||||
JLG(3, "accountType.jlg");//JLG account given in group context
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private AccountType(final Integer value, final String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static AccountType fromInt(final Integer accountTypeValue) {
|
||||
|
||||
AccountType enumeration = AccountType.INVALID;
|
||||
switch (accountTypeValue) {
|
||||
case 1:
|
||||
enumeration = AccountType.INDIVIDUAL;
|
||||
break;
|
||||
case 2:
|
||||
enumeration = AccountType.GROUP;
|
||||
break;
|
||||
case 3:
|
||||
enumeration = AccountType.JLG;
|
||||
break;
|
||||
}
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
public static AccountType fromName(final String name){
|
||||
AccountType accountType = AccountType.INVALID;
|
||||
for (AccountType type : AccountType.values()) {
|
||||
if(type.getName().equals(name)) {
|
||||
accountType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public boolean isInvalid(){
|
||||
return this.value.equals(AccountType.INVALID.getValue());
|
||||
}
|
||||
|
||||
public boolean isIndividualAccount(){
|
||||
return this.value.equals(AccountType.INDIVIDUAL.getValue());
|
||||
}
|
||||
|
||||
public boolean isGroupAccount(){
|
||||
return this.value.equals(AccountType.GROUP.getValue());
|
||||
}
|
||||
|
||||
public boolean isJLGAccount(){
|
||||
return this.value.equals(AccountType.JLG.getValue());
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.mifosplatform.portfolio.accountdetails.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.portfolio.accountdetails.data.AccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.LoanAccountSummaryData;
|
||||
|
||||
|
||||
public interface AccountDetailsReadPlatformService {
|
||||
|
||||
public AccountSummaryCollectionData retrieveClientAccountDetails(final Long clientId);
|
||||
|
||||
public AccountSummaryCollectionData retrieveGroupAccountDetails(final Long groupId);
|
||||
|
||||
public Collection<LoanAccountSummaryData> retrieveClientLoanAccountsByLoanOfficerId(final Long clientId, final Long loanOfficerId);
|
||||
|
||||
public Collection<LoanAccountSummaryData> retrieveGroupLoanAccountsByLoanOfficerId(final Long groupId,final Long loanOfficerId);
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
package org.mifosplatform.portfolio.accountdetails.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.AccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.LoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.SavingsAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountStatusEnumData;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
|
||||
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 AccountDetailsReadPlatformServiceJpaRepositoryImpl implements AccountDetailsReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final GroupReadPlatformService groupReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public AccountDetailsReadPlatformServiceJpaRepositoryImpl(final ClientReadPlatformService clientReadPlatformService,
|
||||
final RoutingDataSource dataSource, final GroupReadPlatformService groupReadPlatformService) {
|
||||
this.clientReadPlatformService = clientReadPlatformService;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.groupReadPlatformService = groupReadPlatformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountSummaryCollectionData retrieveClientAccountDetails(Long clientId) {
|
||||
// Check if client exists
|
||||
clientReadPlatformService.retrieveOne(clientId);
|
||||
String loanwhereClause = " where l.client_id = ?";
|
||||
String savingswhereClause = " where sa.client_id = ? order by sa.status_enum ASC, sa.account_no ASC";
|
||||
List<LoanAccountSummaryData> loanAccounts = retrieveLoanAccountDetails(loanwhereClause, new Object[] { clientId });
|
||||
List<SavingsAccountSummaryData> savingsAccounts = retrieveAccountDetails(savingswhereClause, new Object[] { clientId });
|
||||
return new AccountSummaryCollectionData(loanAccounts, savingsAccounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountSummaryCollectionData retrieveGroupAccountDetails(Long groupId) {
|
||||
// Check if group exists
|
||||
groupReadPlatformService.retrieveOne(groupId);
|
||||
String loanWhereClauseForGroup = " where l.group_id = ? and l.client_id is null";
|
||||
String loanWhereClauseForMembers = " where l.group_id = ? and l.client_id is not null";
|
||||
String savingswhereClauseForGroup = " where sa.group_id = ? and sa.client_id is null order by sa.status_enum ASC, sa.account_no ASC";
|
||||
String savingswhereClauseForMembers = " where sa.group_id = ? and sa.client_id is not null order by sa.status_enum ASC, sa.account_no ASC";
|
||||
List<LoanAccountSummaryData> groupLoanAccounts = retrieveLoanAccountDetails(loanWhereClauseForGroup, new Object[] { groupId });
|
||||
List<SavingsAccountSummaryData> groupSavingsAccounts = retrieveAccountDetails(savingswhereClauseForGroup, new Object[] { groupId });
|
||||
List<LoanAccountSummaryData> memberLoanAccounts = retrieveLoanAccountDetails(loanWhereClauseForMembers, new Object[] { groupId });
|
||||
List<SavingsAccountSummaryData> memberSavingsAccounts = retrieveAccountDetails(savingswhereClauseForMembers,
|
||||
new Object[] { groupId });
|
||||
return new AccountSummaryCollectionData(groupLoanAccounts, groupSavingsAccounts,memberLoanAccounts, memberSavingsAccounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanAccountSummaryData> retrieveClientLoanAccountsByLoanOfficerId(final Long clientId, final Long loanOfficerId) {
|
||||
// Check if client exists
|
||||
clientReadPlatformService.retrieveOne(clientId);
|
||||
String loanWhereClause = " where l.client_id = ? and l.loan_officer_id = ?";
|
||||
return retrieveLoanAccountDetails(loanWhereClause, new Object[] { clientId, loanOfficerId });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanAccountSummaryData> retrieveGroupLoanAccountsByLoanOfficerId(final Long groupId, final Long loanOfficerId) {
|
||||
// Check if group exists
|
||||
groupReadPlatformService.retrieveOne(groupId);
|
||||
String loanWhereClause = " where l.group_id = ? and l.client_id is null and l.loan_officer_id = ?";
|
||||
return retrieveLoanAccountDetails(loanWhereClause, new Object[] { groupId, loanOfficerId });
|
||||
}
|
||||
|
||||
private List<LoanAccountSummaryData> retrieveLoanAccountDetails(String loanwhereClause, Object[] inputs) {
|
||||
LoanAccountSummaryDataMapper rm = new LoanAccountSummaryDataMapper();
|
||||
String sql = "select " + rm.loanAccountSummarySchema() + loanwhereClause;
|
||||
return this.jdbcTemplate.query(sql, rm, inputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityId
|
||||
* @return
|
||||
*/
|
||||
private List<SavingsAccountSummaryData> retrieveAccountDetails(String savingswhereClause, Object[] inputs) {
|
||||
SavingsAccountSummaryDataMapper savingsAccountSummaryDataMapper = new SavingsAccountSummaryDataMapper();
|
||||
final String savingsSql = "select " + savingsAccountSummaryDataMapper.schema() + savingswhereClause;
|
||||
return this.jdbcTemplate.query(savingsSql, savingsAccountSummaryDataMapper, inputs);
|
||||
}
|
||||
|
||||
private static final class SavingsAccountSummaryDataMapper implements RowMapper<SavingsAccountSummaryData> {
|
||||
|
||||
final String schemaSql;
|
||||
|
||||
public SavingsAccountSummaryDataMapper() {
|
||||
StringBuilder accountsSummary = new StringBuilder();
|
||||
accountsSummary.append("sa.id as id, sa.account_no as accountNo, sa.external_id as externalId, sa.status_enum as statusEnum, ");
|
||||
accountsSummary.append("sa.account_balance_derived as accountBalance, ");
|
||||
accountsSummary.append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, ");
|
||||
accountsSummary.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ");
|
||||
accountsSummary.append("curr.display_symbol as currencyDisplaySymbol, ");
|
||||
accountsSummary.append("sa.product_id as productId, p.name as productName ");
|
||||
accountsSummary.append("from m_savings_account sa ");
|
||||
accountsSummary.append("join m_savings_product as p on p.id = sa.product_id ");
|
||||
accountsSummary.append("join m_currency curr on curr.code = sa.currency_code ");
|
||||
|
||||
this.schemaSql = accountsSummary.toString();
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return this.schemaSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavingsAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String productName = rs.getString("productName");
|
||||
final Integer statusId = JdbcSupport.getInteger(rs, "statusEnum");
|
||||
final BigDecimal accountBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "accountBalance");
|
||||
final SavingsAccountStatusEnumData status = SavingsEnumerations.status(statusId);
|
||||
|
||||
final String currencyCode = rs.getString("currencyCode");
|
||||
final String currencyName = rs.getString("currencyName");
|
||||
final String currencyNameCode = rs.getString("currencyNameCode");
|
||||
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
|
||||
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
|
||||
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, currencyDisplaySymbol,
|
||||
currencyNameCode);
|
||||
|
||||
return new SavingsAccountSummaryData(id, accountNo, externalId, productId, productName, status, currency, accountBalance);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class LoanAccountSummaryDataMapper implements RowMapper<LoanAccountSummaryData> {
|
||||
|
||||
public String loanAccountSummarySchema() {
|
||||
|
||||
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.account_no as accountNo, l.external_id as externalId,");
|
||||
accountsSummary.append("l.product_id as productId, lp.name as productName,")
|
||||
.append("l.loan_status_id as statusId, l.loan_type_enum as loanType, ").append("l.loan_product_counter as loanCycle ")
|
||||
.append(" from m_loan l ").append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id");
|
||||
|
||||
return accountsSummary.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String loanProductName = rs.getString("productName");
|
||||
final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||
final LoanStatusEnumData loanStatus = LoanEnumerations.status(loanStatusId);
|
||||
final Integer loanTypeId = JdbcSupport.getInteger(rs, "loanType");
|
||||
final EnumOptionData loanType = AccountEnumerations.loanType(loanTypeId);
|
||||
final Integer loanCycle = JdbcSupport.getInteger(rs, "loanCycle");
|
||||
|
||||
return new LoanAccountSummaryData(id, accountNo, externalId, productId, loanProductName, loanStatus, loanType, loanCycle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package org.mifosplatform.portfolio.accountdetails.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
|
||||
|
||||
|
||||
public class AccountEnumerations {
|
||||
|
||||
public static EnumOptionData loanType(final Integer loanTypeId) {
|
||||
return loanType(AccountType.fromInt(loanTypeId));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanType(final String name) {
|
||||
return loanType(AccountType.fromName(name));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanType(final AccountType type) {
|
||||
EnumOptionData optionData = new EnumOptionData(AccountType.INVALID.getValue().longValue(), AccountType.INVALID.getCode(), "Invalid");
|
||||
switch (type) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(AccountType.INVALID.getValue().longValue(), AccountType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
case INDIVIDUAL:
|
||||
optionData = new EnumOptionData(AccountType.INDIVIDUAL.getValue().longValue(), AccountType.INDIVIDUAL.getCode(), "Individual");
|
||||
break;
|
||||
case GROUP:
|
||||
optionData = new EnumOptionData(AccountType.GROUP.getValue().longValue(), AccountType.GROUP.getCode(), "Group");
|
||||
break;
|
||||
case JLG:
|
||||
optionData = new EnumOptionData(AccountType.JLG.getValue().longValue(), AccountType.JLG.getCode(), "JLG");
|
||||
break;
|
||||
}
|
||||
|
||||
return optionData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+9
-5
@@ -34,7 +34,8 @@ import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSeriali
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.AccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
@@ -50,22 +51,25 @@ public class ClientsApiResource {
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final ToApiJsonSerializer<ClientData> toApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<ClientAccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<AccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public ClientsApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
|
||||
final ToApiJsonSerializer<ClientData> toApiJsonSerializer,
|
||||
final ToApiJsonSerializer<ClientAccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer,
|
||||
final ToApiJsonSerializer<AccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final AccountDetailsReadPlatformService accountDetailsReadPlatformService) {
|
||||
this.context = context;
|
||||
this.clientReadPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.clientAccountSummaryToApiJsonSerializer = clientAccountSummaryToApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -223,7 +227,7 @@ public class ClientsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME);
|
||||
|
||||
final ClientAccountSummaryCollectionData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||
final AccountSummaryCollectionData clientAccount = this.accountDetailsReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||
|
||||
final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("loanAccounts", "savingsAccounts"));
|
||||
|
||||
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Immutable data object representing a summary of a clients various accounts.
|
||||
*/
|
||||
public class ClientAccountSummaryCollectionData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<ClientLoanAccountSummaryData> loanAccounts;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<ClientSavingsAccountSummaryData> savingsAccounts;
|
||||
|
||||
public ClientAccountSummaryCollectionData(final Collection<ClientLoanAccountSummaryData> loanAccounts,
|
||||
final Collection<ClientSavingsAccountSummaryData> savingsAccounts) {
|
||||
this.loanAccounts = defaultIfEmpty(loanAccounts);
|
||||
this.savingsAccounts = savingsAccounts;
|
||||
}
|
||||
|
||||
private Collection<ClientLoanAccountSummaryData> defaultIfEmpty(final Collection<ClientLoanAccountSummaryData> collection) {
|
||||
Collection<ClientLoanAccountSummaryData> returnCollection = null;
|
||||
if (collection != null && !collection.isEmpty()) {
|
||||
returnCollection = collection;
|
||||
}
|
||||
return returnCollection;
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -8,8 +8,6 @@ package org.mifosplatform.portfolio.client.service;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientLoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
|
||||
@@ -25,14 +23,10 @@ public interface ClientReadPlatformService {
|
||||
|
||||
Collection<ClientData> retrieveAllForLookupByOfficeId(Long officeId);
|
||||
|
||||
ClientAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
||||
|
||||
Collection<ClientLoanAccountSummaryData> retrieveClientLoanAccountsByLoanOfficerId(Long clientId, Long loanOfficerId);
|
||||
|
||||
ClientData retrieveClientByIdentifier(Long identifierTypeId, String identifierKey);
|
||||
|
||||
Collection<ClientData> retrieveClientMembersOfGroup(Long groupId);
|
||||
|
||||
|
||||
Collection<ClientData> retrieveActiveClientMembersOfGroup(Long groupId);
|
||||
|
||||
ClientData retrieveAllClosureReasons(String clientClosureReason);
|
||||
|
||||
+1
-130
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -23,24 +22,16 @@ import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientLoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientSavingsAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientEnumerations;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientStatus;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNotFoundException;
|
||||
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountStatusEnumData;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -63,7 +54,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
private final ClientLookupMapper lookupMapper = new ClientLookupMapper();
|
||||
private final ClientMembersOfGroupMapper membersOfGroupMapper = new ClientMembersOfGroupMapper();
|
||||
private final ParentGroupsMapper clientGroupsMapper = new ParentGroupsMapper();
|
||||
private final ClientSavingsAccountSummaryDataMapper savingsAccountSummaryDataMapper = new ClientSavingsAccountSummaryDataMapper();
|
||||
|
||||
@Autowired
|
||||
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
@@ -255,7 +245,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper,
|
||||
new Object[] { hierarchySearchString, groupId, ClientStatus.ACTIVE.getValue() });
|
||||
}
|
||||
|
||||
|
||||
private static final class ClientMembersOfGroupMapper implements RowMapper<ClientData> {
|
||||
|
||||
private final String schema;
|
||||
@@ -407,125 +397,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientAccountSummaryCollectionData retrieveClientAccountDetails(final Long clientId) {
|
||||
|
||||
try {
|
||||
// Check if client exists
|
||||
retrieveOne(clientId);
|
||||
|
||||
ClientLoanAccountSummaryDataMapper rm = new ClientLoanAccountSummaryDataMapper();
|
||||
|
||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.client_id = ?";
|
||||
|
||||
List<ClientLoanAccountSummaryData> allLoanAccounts = this.jdbcTemplate.query(sql, rm, new Object[] { clientId });
|
||||
|
||||
final String savingsSql = "select " + this.savingsAccountSummaryDataMapper.schema()
|
||||
+ " where sa.client_id = ? order by sa.status_enum ASC, sa.account_no ASC";
|
||||
|
||||
final List<ClientSavingsAccountSummaryData> allSavingsAccounts = this.jdbcTemplate.query(savingsSql,
|
||||
savingsAccountSummaryDataMapper, new Object[] { clientId });
|
||||
|
||||
return new ClientAccountSummaryCollectionData(allLoanAccounts, allSavingsAccounts);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new ClientNotFoundException(clientId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ClientLoanAccountSummaryData> retrieveClientLoanAccountsByLoanOfficerId(final Long clientId, final Long loanOfficerId) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
// Check if client exists
|
||||
retrieveOne(clientId);
|
||||
|
||||
ClientLoanAccountSummaryDataMapper rm = new ClientLoanAccountSummaryDataMapper();
|
||||
|
||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.client_id = ? and l.loan_officer_id = ?";
|
||||
|
||||
List<ClientLoanAccountSummaryData> loanAccounts = this.jdbcTemplate.query(sql, rm, new Object[] { clientId, loanOfficerId });
|
||||
|
||||
return loanAccounts;
|
||||
}
|
||||
|
||||
private static final class ClientSavingsAccountSummaryDataMapper implements RowMapper<ClientSavingsAccountSummaryData> {
|
||||
|
||||
final String schemaSql;
|
||||
|
||||
public ClientSavingsAccountSummaryDataMapper() {
|
||||
StringBuilder accountsSummary = new StringBuilder();
|
||||
accountsSummary.append("sa.id as id, sa.account_no as accountNo, sa.external_id as externalId, sa.status_enum as statusEnum, ");
|
||||
accountsSummary.append("sa.account_balance_derived as accountBalance, ");
|
||||
accountsSummary.append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, ");
|
||||
accountsSummary.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ");
|
||||
accountsSummary.append("curr.display_symbol as currencyDisplaySymbol, ");
|
||||
accountsSummary.append("sa.product_id as productId, p.name as productName ");
|
||||
accountsSummary.append("from m_savings_account sa ");
|
||||
accountsSummary.append("join m_savings_product as p on p.id = sa.product_id ");
|
||||
accountsSummary.append("join m_currency curr on curr.code = sa.currency_code ");
|
||||
|
||||
this.schemaSql = accountsSummary.toString();
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return this.schemaSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientSavingsAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String productName = rs.getString("productName");
|
||||
final Integer statusId = JdbcSupport.getInteger(rs, "statusEnum");
|
||||
final BigDecimal accountBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "accountBalance");
|
||||
final SavingsAccountStatusEnumData status = SavingsEnumerations.status(statusId);
|
||||
|
||||
final String currencyCode = rs.getString("currencyCode");
|
||||
final String currencyName = rs.getString("currencyName");
|
||||
final String currencyNameCode = rs.getString("currencyNameCode");
|
||||
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
|
||||
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
|
||||
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, currencyDisplaySymbol,
|
||||
currencyNameCode);
|
||||
|
||||
return new ClientSavingsAccountSummaryData(id, accountNo, externalId, productId, productName, status, currency, accountBalance);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ClientLoanAccountSummaryDataMapper implements RowMapper<ClientLoanAccountSummaryData> {
|
||||
|
||||
public String loanAccountSummarySchema() {
|
||||
|
||||
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.account_no as accountNo, l.external_id as externalId,");
|
||||
accountsSummary.append("l.product_id as productId, lp.name as productName,")
|
||||
.append("l.loan_status_id as statusId, l.loan_type_enum as loanType, ").append("l.loan_product_counter as loanCycle ")
|
||||
.append(" from m_loan l ").append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id");
|
||||
|
||||
return accountsSummary.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientLoanAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String loanProductName = rs.getString("productName");
|
||||
final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||
final LoanStatusEnumData loanStatus = LoanEnumerations.status(loanStatusId);
|
||||
final Integer loanTypeId = JdbcSupport.getInteger(rs, "loanType");
|
||||
final EnumOptionData loanType = LoanEnumerations.loanType(loanTypeId);
|
||||
final Integer loanCycle = JdbcSupport.getInteger(rs, "loanCycle");
|
||||
|
||||
return new ClientLoanAccountSummaryData(id, accountNo, externalId, productId, loanProductName, loanStatus, loanType, loanCycle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientData retrieveClientByIdentifier(final Long identifierTypeId, final String identifierKey) {
|
||||
try {
|
||||
|
||||
+22
-21
@@ -36,12 +36,12 @@ import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.AccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
|
||||
import org.mifosplatform.portfolio.collectionsheet.data.JLGCollectionSheetData;
|
||||
import org.mifosplatform.portfolio.collectionsheet.service.CollectionSheetReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.data.CenterData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.service.CenterReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -56,26 +56,25 @@ public class CentersApiResource {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final CenterReadPlatformService centerReadPlatformService;
|
||||
private final GroupReadPlatformService groupReadPlatformService;
|
||||
private final ToApiJsonSerializer<CenterData> centerApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<Object> toApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<AccountSummaryCollectionData> groupSummaryToApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final CollectionSheetReadPlatformService collectionSheetReadPlatformService;
|
||||
private final FromJsonHelper fromJsonHelper;
|
||||
private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public CentersApiResource(final PlatformSecurityContext context, final CenterReadPlatformService centerReadPlatformService,
|
||||
final GroupReadPlatformService groupReadPlatformService, final ToApiJsonSerializer<CenterData> centerApiJsonSerializer,
|
||||
final ToApiJsonSerializer<Object> toApiJsonSerializer,
|
||||
final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer,
|
||||
final ToApiJsonSerializer<CenterData> centerApiJsonSerializer, final ToApiJsonSerializer<Object> toApiJsonSerializer,
|
||||
final ToApiJsonSerializer<AccountSummaryCollectionData> groupSummaryToApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final CollectionSheetReadPlatformService collectionSheetReadPlatformService, final FromJsonHelper fromJsonHelper) {
|
||||
final CollectionSheetReadPlatformService collectionSheetReadPlatformService, final FromJsonHelper fromJsonHelper,
|
||||
final AccountDetailsReadPlatformService accountDetailsReadPlatformService) {
|
||||
this.context = context;
|
||||
this.centerReadPlatformService = centerReadPlatformService;
|
||||
this.groupReadPlatformService = groupReadPlatformService;
|
||||
this.centerApiJsonSerializer = centerApiJsonSerializer;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.groupSummaryToApiJsonSerializer = groupSummaryToApiJsonSerializer;
|
||||
@@ -83,6 +82,7 @@ public class CentersApiResource {
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
this.collectionSheetReadPlatformService = collectionSheetReadPlatformService;
|
||||
this.fromJsonHelper = fromJsonHelper;
|
||||
this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -126,7 +126,7 @@ public class CentersApiResource {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME);
|
||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
|
||||
|
||||
CenterData center = this.centerReadPlatformService.retrieveOne(centerId);
|
||||
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
@@ -134,7 +134,7 @@ public class CentersApiResource {
|
||||
final CenterData templateCenter = this.centerReadPlatformService.retrieveTemplate(center.officeId());
|
||||
center = CenterData.withTemplate(templateCenter, center);
|
||||
}
|
||||
|
||||
|
||||
if (!associationParameters.isEmpty()) {
|
||||
if (associationParameters.contains("groupMembers")) {
|
||||
center = CenterData.setGroups(center, this.centerReadPlatformService.retrieveAssociatedGroups(centerId));
|
||||
@@ -200,18 +200,20 @@ public class CentersApiResource {
|
||||
final CommandWrapper commandRequest = builder.activateCenter(centerId).build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}else if (is(commandParam, "generateCollectionSheet")) {
|
||||
} else if (is(commandParam, "generateCollectionSheet")) {
|
||||
final JsonElement parsedQuery = this.fromJsonHelper.parse(apiRequestBodyAsJson);
|
||||
final JsonQuery query = JsonQuery.from(apiRequestBodyAsJson, parsedQuery, this.fromJsonHelper);
|
||||
final JLGCollectionSheetData collectionSheet = this.collectionSheetReadPlatformService.generateCenterCollectionSheet(centerId, query);
|
||||
final JLGCollectionSheetData collectionSheet = this.collectionSheetReadPlatformService.generateCenterCollectionSheet(centerId,
|
||||
query);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, collectionSheet, GroupingTypesApiConstants.COLLECTIONSHEET_DATA_PARAMETERS);
|
||||
}else if (is(commandParam, "saveCollectionSheet")) {
|
||||
} else if (is(commandParam, "saveCollectionSheet")) {
|
||||
final CommandWrapper commandRequest = builder.saveCenterCollectionSheet(centerId).build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
} else {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "createRole" });
|
||||
} else {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet",
|
||||
"createRole" });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -221,18 +223,17 @@ public class CentersApiResource {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{centerId}/loans")
|
||||
@Path("{centerId}/accounts")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveGroupAccount(@PathParam("centerId") final Long centerId, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME);
|
||||
|
||||
final GroupAccountSummaryCollectionData groupAccount = this.groupReadPlatformService.retrieveGroupAccountDetails(centerId);
|
||||
final AccountSummaryCollectionData groupAccount = this.accountDetailsReadPlatformService.retrieveGroupAccountDetails(centerId);
|
||||
|
||||
final Set<String> GROUP_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("pendingApprovalLoans",
|
||||
"awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount",
|
||||
"awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount"));
|
||||
final Set<String> GROUP_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("loanAccounts", "savingsAccounts",
|
||||
"memberLoanAccounts", "memberSavingsAccounts"));
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS);
|
||||
|
||||
+13
-9
@@ -38,11 +38,12 @@ import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.AccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.mifosplatform.portfolio.collectionsheet.data.JLGCollectionSheetData;
|
||||
import org.mifosplatform.portfolio.collectionsheet.service.CollectionSheetReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupRoleData;
|
||||
import org.mifosplatform.portfolio.group.service.CenterReadPlatformService;
|
||||
@@ -67,23 +68,25 @@ public class GroupsApiResource {
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final ToApiJsonSerializer<Object> toApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<GroupGeneralData> groupGeneralApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer;
|
||||
private final ToApiJsonSerializer<AccountSummaryCollectionData> groupSummaryToApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final CollectionSheetReadPlatformService collectionSheetReadPlatformService;
|
||||
private final FromJsonHelper fromJsonHelper;
|
||||
private final GroupRolesReadPlatformService groupRolesReadPlatformService;
|
||||
private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public GroupsApiResource(final PlatformSecurityContext context, final GroupReadPlatformService groupReadPlatformService,
|
||||
final CenterReadPlatformService centerReadPlatformService, final ClientReadPlatformService clientReadPlatformService,
|
||||
final ToApiJsonSerializer<Object> toApiJsonSerializer,
|
||||
final ToApiJsonSerializer<GroupGeneralData> groupTopOfHierarchyApiJsonSerializer,
|
||||
final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer,
|
||||
final ToApiJsonSerializer<AccountSummaryCollectionData> groupSummaryToApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final CollectionSheetReadPlatformService collectionSheetReadPlatformService, final FromJsonHelper fromJsonHelper,
|
||||
final GroupRolesReadPlatformService groupRolesReadPlatformService) {
|
||||
final GroupRolesReadPlatformService groupRolesReadPlatformService,
|
||||
final AccountDetailsReadPlatformService accountDetailsReadPlatformService) {
|
||||
this.context = context;
|
||||
this.groupReadPlatformService = groupReadPlatformService;
|
||||
this.centerReadPlatformService = centerReadPlatformService;
|
||||
@@ -96,6 +99,7 @@ public class GroupsApiResource {
|
||||
this.collectionSheetReadPlatformService = collectionSheetReadPlatformService;
|
||||
this.fromJsonHelper = fromJsonHelper;
|
||||
this.groupRolesReadPlatformService = groupRolesReadPlatformService;
|
||||
this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -315,20 +319,20 @@ public class GroupsApiResource {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{groupId}/loans")
|
||||
@Path("{groupId}/accounts")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveLoans(@PathParam("groupId") final Long groupId, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission("GROUP");
|
||||
|
||||
final GroupAccountSummaryCollectionData groupAccount = this.groupReadPlatformService.retrieveGroupAccountDetails(groupId);
|
||||
final AccountSummaryCollectionData groupAccount = this.accountDetailsReadPlatformService.retrieveGroupAccountDetails(groupId);
|
||||
|
||||
final Set<String> GROUP_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("pendingApprovalLoans",
|
||||
"awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount",
|
||||
"awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount"));
|
||||
final Set<String> GROUP_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("loanAccounts", "savingsAccounts",
|
||||
"memberLoanAccounts", "memberSavingsAccounts"));
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.group.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroupAccountSummaryCollectionData {
|
||||
|
||||
private final int anyLoanCount;
|
||||
private final int pendingApprovalLoanCount;
|
||||
private final List<GroupAccountSummaryData> pendingApprovalLoans;
|
||||
private final int awaitingDisbursalLoanCount;
|
||||
private final List<GroupAccountSummaryData> awaitingDisbursalLoans;
|
||||
private final int activeLoanCount;
|
||||
private final List<GroupAccountSummaryData> openLoans;
|
||||
private final int closedLoanCount;
|
||||
private final List<GroupAccountSummaryData> closedLoans;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final int anyIndividualLoanCount;
|
||||
private final int pendingApprovalIndividualLoanCount;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<GroupAccountSummaryData> pendingApprovalIndividualLoans;
|
||||
private final int awaitingDisbursalIndividualLoanCount;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<GroupAccountSummaryData> awaitingDisbursalIndividualLoans;
|
||||
private final int activeIndividualLoanCount;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<GroupAccountSummaryData> openIndividualLoans;
|
||||
private final int closedIndividualLoanCount;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<GroupAccountSummaryData> closedIndividualLoans;
|
||||
|
||||
public GroupAccountSummaryCollectionData(final List<GroupAccountSummaryData> pendingApprovalLoans,
|
||||
final List<GroupAccountSummaryData> awaitingDisbursalLoans, final List<GroupAccountSummaryData> openLoans,
|
||||
final List<GroupAccountSummaryData> closedLoans, final List<GroupAccountSummaryData> pendingApprovalIndividualLoans,
|
||||
final List<GroupAccountSummaryData> awaitingDisbursalIndividualLoans, final List<GroupAccountSummaryData> openIndividualLoans,
|
||||
final List<GroupAccountSummaryData> closedIndividualLoans) {
|
||||
this.pendingApprovalLoans = pendingApprovalLoans;
|
||||
this.pendingApprovalLoanCount = pendingApprovalLoans.size();
|
||||
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
||||
this.awaitingDisbursalLoanCount = awaitingDisbursalLoans.size();
|
||||
this.openLoans = openLoans;
|
||||
this.activeLoanCount = openLoans.size();
|
||||
this.closedLoans = closedLoans;
|
||||
this.closedLoanCount = closedLoans.size();
|
||||
|
||||
this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount;
|
||||
|
||||
this.pendingApprovalIndividualLoans = pendingApprovalIndividualLoans;
|
||||
this.pendingApprovalIndividualLoanCount = pendingApprovalIndividualLoans.size();
|
||||
this.awaitingDisbursalIndividualLoans = awaitingDisbursalIndividualLoans;
|
||||
this.awaitingDisbursalIndividualLoanCount = awaitingDisbursalIndividualLoans.size();
|
||||
this.openIndividualLoans = openIndividualLoans;
|
||||
this.activeIndividualLoanCount = openIndividualLoans.size();
|
||||
this.closedIndividualLoans = closedIndividualLoans;
|
||||
this.closedIndividualLoanCount = closedIndividualLoans.size();
|
||||
|
||||
this.anyIndividualLoanCount = this.pendingApprovalIndividualLoanCount + this.awaitingDisbursalIndividualLoanCount
|
||||
+ this.activeIndividualLoanCount + this.closedIndividualLoanCount;
|
||||
}
|
||||
|
||||
public int getAnyLoanCount() {
|
||||
return this.anyLoanCount;
|
||||
}
|
||||
|
||||
public int getPendingApprovalLoanCount() {
|
||||
return this.pendingApprovalLoanCount;
|
||||
}
|
||||
|
||||
public List<GroupAccountSummaryData> getPendingApprovalLoans() {
|
||||
return this.pendingApprovalLoans;
|
||||
}
|
||||
|
||||
public int getAwaitingDisbursalLoanCount() {
|
||||
return this.awaitingDisbursalLoanCount;
|
||||
}
|
||||
|
||||
public List<GroupAccountSummaryData> getAwaitingDisbursalLoans() {
|
||||
return this.awaitingDisbursalLoans;
|
||||
}
|
||||
|
||||
public int getActiveLoanCount() {
|
||||
return this.activeLoanCount;
|
||||
}
|
||||
|
||||
public List<GroupAccountSummaryData> getOpenLoans() {
|
||||
return this.openLoans;
|
||||
}
|
||||
|
||||
public int getClosedLoanCount() {
|
||||
return this.closedLoanCount;
|
||||
}
|
||||
|
||||
public List<GroupAccountSummaryData> getClosedLoans() {
|
||||
return this.closedLoans;
|
||||
}
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.group.data;
|
||||
|
||||
/**
|
||||
* Immutable data object for group loan accounts.
|
||||
*/
|
||||
public class GroupAccountSummaryData {
|
||||
|
||||
private final Long id;
|
||||
private final String externalId;
|
||||
private final Long productId;
|
||||
private final String productName;
|
||||
private final Integer accountStatusId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String accountNo;
|
||||
|
||||
public GroupAccountSummaryData(final Long id, final String externalId, final Long productId, final String productName,
|
||||
final Integer accountStatusId, final String accountNo) {
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
this.productId = productId;
|
||||
this.productName = productName;
|
||||
this.accountStatusId = accountStatusId;
|
||||
this.accountNo = accountNo;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return this.externalId;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return this.productName;
|
||||
}
|
||||
|
||||
public Integer getAccountStatusId() {
|
||||
return this.accountStatusId;
|
||||
}
|
||||
}
|
||||
-9
@@ -5,11 +5,7 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.group.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
|
||||
public interface GroupReadPlatformService {
|
||||
@@ -19,9 +15,4 @@ public interface GroupReadPlatformService {
|
||||
Page<GroupGeneralData> retrieveAll(SearchParameters searchParameters);
|
||||
|
||||
GroupGeneralData retrieveOne(Long groupId);
|
||||
|
||||
//
|
||||
GroupAccountSummaryCollectionData retrieveGroupAccountDetails(Long groupId);
|
||||
|
||||
Collection<GroupAccountSummaryData> retrieveGroupLoanAccountsByLoanOfficerId(Long groupId, Long loanOfficerId);
|
||||
}
|
||||
-119
@@ -5,17 +5,12 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.group.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
@@ -26,11 +21,8 @@ import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.service.LoanStatusMapper;
|
||||
import org.mifosplatform.portfolio.group.api.GroupingTypesApiConstants;
|
||||
import org.mifosplatform.portfolio.group.data.CenterData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
import org.mifosplatform.portfolio.group.domain.GroupTypes;
|
||||
import org.mifosplatform.portfolio.group.exception.GroupNotFoundException;
|
||||
@@ -38,7 +30,6 @@ import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -209,114 +200,4 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
throw new GroupNotFoundException(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupAccountSummaryCollectionData retrieveGroupAccountDetails(final Long groupId) {
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
// Check if group exists
|
||||
// retrieveGroup(groupId);
|
||||
|
||||
final List<GroupAccountSummaryData> pendingApprovalLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> awaitingDisbursalLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> openLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> closedLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
|
||||
final GroupLoanAccountSummaryDataMapper rm = new GroupLoanAccountSummaryDataMapper();
|
||||
|
||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is null";
|
||||
|
||||
List<GroupAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
|
||||
if (results != null) {
|
||||
for (final GroupAccountSummaryData row : results) {
|
||||
|
||||
final LoanStatusMapper statusMapper = new LoanStatusMapper(row.getAccountStatusId());
|
||||
|
||||
if (statusMapper.isOpen()) {
|
||||
openLoans.add(row);
|
||||
} else if (statusMapper.isAwaitingDisbursal()) {
|
||||
awaitingDisbursalLoans.add(row);
|
||||
} else if (statusMapper.isPendingApproval()) {
|
||||
pendingApprovalLoans.add(row);
|
||||
} else {
|
||||
closedLoans.add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<GroupAccountSummaryData> pendingApprovalIndividualLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> awaitingDisbursalIndividualLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> openIndividualLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
final List<GroupAccountSummaryData> closedIndividualLoans = new ArrayList<GroupAccountSummaryData>();
|
||||
|
||||
sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is not null";
|
||||
|
||||
results = this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
|
||||
if (results != null) {
|
||||
for (final GroupAccountSummaryData row : results) {
|
||||
|
||||
final LoanStatusMapper statusMapper = new LoanStatusMapper(row.getAccountStatusId());
|
||||
|
||||
if (statusMapper.isOpen()) {
|
||||
openIndividualLoans.add(row);
|
||||
} else if (statusMapper.isAwaitingDisbursal()) {
|
||||
awaitingDisbursalIndividualLoans.add(row);
|
||||
} else if (statusMapper.isPendingApproval()) {
|
||||
pendingApprovalIndividualLoans.add(row);
|
||||
} else {
|
||||
closedIndividualLoans.add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new GroupAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans,
|
||||
pendingApprovalIndividualLoans, awaitingDisbursalIndividualLoans, openIndividualLoans, closedIndividualLoans);
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new GroupNotFoundException(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GroupAccountSummaryData> retrieveGroupLoanAccountsByLoanOfficerId(final Long groupId, final Long loanOfficerId) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
// Check if group exists
|
||||
// retrieveGroup(groupId);
|
||||
|
||||
final GroupLoanAccountSummaryDataMapper rm = new GroupLoanAccountSummaryDataMapper();
|
||||
|
||||
final String sql = "select " + rm.loanAccountSummarySchema()
|
||||
+ " where l.group_id = ? and l.client_id is null and l.loan_officer_id = ?";
|
||||
|
||||
final List<GroupAccountSummaryData> loanAccounts = this.jdbcTemplate.query(sql, rm, new Object[] { groupId, loanOfficerId });
|
||||
|
||||
return loanAccounts;
|
||||
}
|
||||
|
||||
private static final class GroupLoanAccountSummaryDataMapper implements RowMapper<GroupAccountSummaryData> {
|
||||
|
||||
public String loanAccountSummarySchema() {
|
||||
|
||||
final StringBuilder accountsSummary = new StringBuilder("l.id as id, l.external_id as externalId,");
|
||||
accountsSummary.append("l.product_id as productId, lp.name as productName,").append("l.loan_status_id as statusId, ")
|
||||
.append("l.account_no as accountNo ").append("from m_loan l ")
|
||||
.append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
||||
|
||||
return accountsSummary.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String loanProductName = rs.getString("productName");
|
||||
final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
return new GroupAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId, accountNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -55,6 +55,7 @@ import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.organisation.staff.domain.Staff;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDays;
|
||||
import org.mifosplatform.organisation.workingdays.service.WorkingDaysUtil;
|
||||
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
|
||||
import org.mifosplatform.portfolio.calendar.service.CalendarHelper;
|
||||
import org.mifosplatform.portfolio.charge.exception.LoanChargeCannotBeAddedException;
|
||||
import org.mifosplatform.portfolio.client.domain.Client;
|
||||
@@ -2499,7 +2500,7 @@ public class Loan extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
public boolean isGroupLoan() {
|
||||
return LoanType.fromInt(this.loanType).isGroupLoan();
|
||||
return AccountType.fromInt(this.loanType).isGroupAccount();
|
||||
}
|
||||
|
||||
public void updateInterestRateFrequencyType() {
|
||||
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.loanaccount.domain;
|
||||
|
||||
/**
|
||||
* Enum representation of loan types .
|
||||
*/
|
||||
public enum LoanType {
|
||||
|
||||
INVALID(0, "loanType.invalid"), //
|
||||
INDIVIDUAL(1, "loanType.individual"), //
|
||||
GROUP(2, "loanType.group"), //
|
||||
JLG(3, "loanType.jlg");//JLG loans given in group context
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private LoanType(final Integer value, final String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static LoanType fromInt(final Integer loanTypeValue) {
|
||||
|
||||
LoanType enumeration = LoanType.INVALID;
|
||||
switch (loanTypeValue) {
|
||||
case 1:
|
||||
enumeration = LoanType.INDIVIDUAL;
|
||||
break;
|
||||
case 2:
|
||||
enumeration = LoanType.GROUP;
|
||||
break;
|
||||
case 3:
|
||||
enumeration = LoanType.JLG;
|
||||
break;
|
||||
}
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
public static LoanType fromName(final String name){
|
||||
LoanType loanType = LoanType.INVALID;
|
||||
for (LoanType type : LoanType.values()) {
|
||||
if(type.getName().equals(name)) {
|
||||
loanType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return loanType;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public boolean isInvalid(){
|
||||
return this.value.equals(LoanType.INVALID.getValue());
|
||||
}
|
||||
|
||||
public boolean isIndividualLoan(){
|
||||
return this.value.equals(LoanType.INDIVIDUAL.getValue());
|
||||
}
|
||||
|
||||
public boolean isGroupLoan(){
|
||||
return this.value.equals(LoanType.GROUP.getValue());
|
||||
}
|
||||
|
||||
public boolean isJLGLoan(){
|
||||
return this.value.equals(LoanType.JLG.getValue());
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -22,7 +22,7 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanType;
|
||||
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -77,22 +77,22 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
baseDataValidator.reset().parameter(loanTypeParameterName).value(loanTypeStr).notNull();
|
||||
|
||||
if (!StringUtils.isBlank(loanTypeStr)) {
|
||||
final LoanType loanType = LoanType.fromName(loanTypeStr);
|
||||
final AccountType loanType = AccountType.fromName(loanTypeStr);
|
||||
baseDataValidator.reset().parameter(loanTypeParameterName).value(loanType.getValue()).inMinMaxRange(1, 3);
|
||||
|
||||
final Long clientId = fromApiJsonHelper.extractLongNamed("clientId", element);
|
||||
final Long groupId = fromApiJsonHelper.extractLongNamed("groupId", element);
|
||||
if (loanType.isIndividualLoan()) {
|
||||
if (loanType.isIndividualAccount()) {
|
||||
baseDataValidator.reset().parameter("clientId").value(clientId).notNull().longGreaterThanZero();
|
||||
baseDataValidator.reset().parameter("groupId").value(groupId).mustBeBlankWhenParameterProvided("clientId", clientId);
|
||||
}
|
||||
|
||||
if (loanType.isGroupLoan()) {
|
||||
if (loanType.isGroupAccount()) {
|
||||
baseDataValidator.reset().parameter("groupId").value(groupId).notNull().longGreaterThanZero();
|
||||
baseDataValidator.reset().parameter("clientId").value(clientId).mustBeBlankWhenParameterProvided("groupId", groupId);
|
||||
}
|
||||
|
||||
if (loanType.isJLGLoan()) {
|
||||
if (loanType.isJLGAccount()) {
|
||||
baseDataValidator.reset().parameter("clientId").value(clientId).notNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter("groupId").value(groupId).notNull().longGreaterThanZero();
|
||||
}
|
||||
|
||||
+17
-21
@@ -14,10 +14,8 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.staff.data.StaffAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientLoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
|
||||
import org.mifosplatform.portfolio.accountdetails.data.LoanAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
@@ -28,16 +26,14 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final GroupReadPlatformService groupReadPlatformService;
|
||||
private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public BulkLoansReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final ClientReadPlatformService clientReadPlatformService, final GroupReadPlatformService groupReadPlatformService) {
|
||||
final AccountDetailsReadPlatformService accountDetailsReadPlatformService) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.clientReadPlatformService = clientReadPlatformService;
|
||||
this.groupReadPlatformService = groupReadPlatformService;
|
||||
this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,23 +47,23 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
final StaffGroupMapper staffGroupMapper = new StaffGroupMapper();
|
||||
final String groupSql = "select distinct " + staffGroupMapper.schema();
|
||||
|
||||
final List<StaffAccountSummaryCollectionData.ClientSummary> clientSummaryList = this.jdbcTemplate.query(clientSql,
|
||||
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> clientSummaryList = this.jdbcTemplate.query(clientSql,
|
||||
staffClientMapper, new Object[] { loanOfficerId });
|
||||
|
||||
for (StaffAccountSummaryCollectionData.ClientSummary clientSummary : clientSummaryList) {
|
||||
for (StaffAccountSummaryCollectionData.LoanAccountSummary clientSummary : clientSummaryList) {
|
||||
|
||||
final Collection<ClientLoanAccountSummaryData> clientLoanAccounts = this.clientReadPlatformService
|
||||
final Collection<LoanAccountSummaryData> clientLoanAccounts = this.accountDetailsReadPlatformService
|
||||
.retrieveClientLoanAccountsByLoanOfficerId(clientSummary.getId(), loanOfficerId);
|
||||
|
||||
clientSummary.setLoans(clientLoanAccounts);
|
||||
}
|
||||
|
||||
final List<StaffAccountSummaryCollectionData.GroupSummary> groupSummaryList = this.jdbcTemplate.query(groupSql, staffGroupMapper,
|
||||
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> groupSummaryList = this.jdbcTemplate.query(groupSql, staffGroupMapper,
|
||||
new Object[] { loanOfficerId });
|
||||
|
||||
for (StaffAccountSummaryCollectionData.GroupSummary groupSummary : groupSummaryList) {
|
||||
for (StaffAccountSummaryCollectionData.LoanAccountSummary groupSummary : groupSummaryList) {
|
||||
|
||||
final Collection<GroupAccountSummaryData> groupLoanAccounts = this.groupReadPlatformService
|
||||
final Collection<LoanAccountSummaryData> groupLoanAccounts = this.accountDetailsReadPlatformService
|
||||
.retrieveGroupLoanAccountsByLoanOfficerId(groupSummary.getId(), loanOfficerId);
|
||||
|
||||
groupSummary.setLoans(groupLoanAccounts);
|
||||
@@ -76,7 +72,7 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
return new StaffAccountSummaryCollectionData(clientSummaryList, groupSummaryList);
|
||||
}
|
||||
|
||||
private static final class StaffClientMapper implements RowMapper<StaffAccountSummaryCollectionData.ClientSummary> {
|
||||
private static final class StaffClientMapper implements RowMapper<StaffAccountSummaryCollectionData.LoanAccountSummary> {
|
||||
|
||||
public String schema() {
|
||||
return " c.id as id, c.display_name as displayName from m_client c "
|
||||
@@ -84,16 +80,16 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffAccountSummaryCollectionData.ClientSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
public StaffAccountSummaryCollectionData.LoanAccountSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String displayName = rs.getString("displayName");
|
||||
|
||||
return new StaffAccountSummaryCollectionData.ClientSummary(id, displayName);
|
||||
return new StaffAccountSummaryCollectionData.LoanAccountSummary(id, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class StaffGroupMapper implements RowMapper<StaffAccountSummaryCollectionData.GroupSummary> {
|
||||
private static final class StaffGroupMapper implements RowMapper<StaffAccountSummaryCollectionData.LoanAccountSummary> {
|
||||
|
||||
public String schema() {
|
||||
return " g.id as id, g.display_name as name from m_group g"
|
||||
@@ -101,12 +97,12 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffAccountSummaryCollectionData.GroupSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
public StaffAccountSummaryCollectionData.LoanAccountSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String name = rs.getString("name");
|
||||
|
||||
return new StaffAccountSummaryCollectionData.GroupSummary(id, name);
|
||||
return new StaffAccountSummaryCollectionData.LoanAccountSummary(id, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -24,6 +24,7 @@ import org.mifosplatform.organisation.staff.exception.StaffNotFoundException;
|
||||
import org.mifosplatform.organisation.staff.exception.StaffRoleException;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDays;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountEnumerations;
|
||||
import org.mifosplatform.portfolio.client.domain.Client;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.collateral.domain.LoanCollateral;
|
||||
@@ -53,7 +54,6 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
|
||||
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
|
||||
import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -154,7 +154,7 @@ public class LoanAssembler {
|
||||
|
||||
final String loanTypeParameterName = "loanType";
|
||||
final String loanTypeStr = fromApiJsonHelper.extractStringNamed(loanTypeParameterName, element);
|
||||
final EnumOptionData loanType = LoanEnumerations.loanType(loanTypeStr);
|
||||
final EnumOptionData loanType = AccountEnumerations.loanType(loanTypeStr);
|
||||
|
||||
if (clientId != null) {
|
||||
client = this.clientRepository.findOneWithNotFoundDetection(clientId);
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@ import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountEnumerations;
|
||||
import org.mifosplatform.portfolio.calendar.data.CalendarData;
|
||||
import org.mifosplatform.portfolio.calendar.domain.CalendarEntityType;
|
||||
import org.mifosplatform.portfolio.calendar.service.CalendarReadPlatformService;
|
||||
@@ -492,7 +493,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final String groupHierarchy = rs.getString("groupHierarchy");
|
||||
|
||||
final Integer loanTypeId = JdbcSupport.getInteger(rs, "loanType");
|
||||
final EnumOptionData loanType = LoanEnumerations.loanType(loanTypeId);
|
||||
final EnumOptionData loanType = AccountEnumerations.loanType(loanTypeId);
|
||||
|
||||
final Long fundId = JdbcSupport.getLong(rs, "fundId");
|
||||
final String fundName = rs.getString("fundName");
|
||||
|
||||
+7
-7
@@ -34,6 +34,7 @@ import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.organisation.staff.domain.Staff;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDays;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
|
||||
import org.mifosplatform.portfolio.calendar.domain.Calendar;
|
||||
import org.mifosplatform.portfolio.calendar.domain.CalendarEntityType;
|
||||
import org.mifosplatform.portfolio.calendar.domain.CalendarInstance;
|
||||
@@ -65,7 +66,6 @@ import org.mifosplatform.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanSummaryWrapper;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransactionRepository;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanType;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.LoanDisbursalException;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.LoanNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.LoanOfficerAssignmentException;
|
||||
@@ -1040,7 +1040,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
final WorkingDays workingDays = this.workingDaysRepository.findOne();
|
||||
final Collection<Integer> loanStatuses = new ArrayList<Integer>(Arrays.asList(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(),
|
||||
LoanStatus.APPROVED.getValue(), LoanStatus.ACTIVE.getValue()));
|
||||
final Collection<Integer> loanTypes = new ArrayList<Integer>(Arrays.asList(LoanType.GROUP.getValue(), LoanType.JLG.getValue()));
|
||||
final Collection<Integer> loanTypes = new ArrayList<Integer>(Arrays.asList(AccountType.GROUP.getValue(), AccountType.JLG.getValue()));
|
||||
final Collection<Long> loanIds = new ArrayList<Long>(loanCalendarInstances.size());
|
||||
// loop through loanCalendarInstances to get loan ids
|
||||
for (CalendarInstance calendarInstance : loanCalendarInstances) {
|
||||
@@ -1064,10 +1064,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
if (loan.isGroupLoan()) {
|
||||
if (loan.loanProduct().isIncludeInBorrowerCycle()) {
|
||||
loansToUpdate = this.loanRepository.getGroupLoansToUpdateLoanCounter(loan.getCurrentLoanCounter(), loan.getGroupId(),
|
||||
LoanType.GROUP.getValue());
|
||||
AccountType.GROUP.getValue());
|
||||
} else {
|
||||
loansToUpdate = this.loanRepository.getGroupLoansToUpdateLoanProductCounter(loan.getLoanProductLoanCounter(),
|
||||
loan.getGroupId(), LoanType.GROUP.getValue());
|
||||
loan.getGroupId(), AccountType.GROUP.getValue());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1092,7 +1092,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
if (loan.isGroupLoan()) {
|
||||
final List<Loan> loansToUpdateForLoanCounter = this.loanRepository.getGroupLoansDisbursedAfter(actualDisbursementDate.toDate(),
|
||||
loan.getGroupId(), LoanType.GROUP.getValue());
|
||||
loan.getGroupId(), AccountType.GROUP.getValue());
|
||||
final Integer newLoanCounter = getNewGroupLoanCounter(loan);
|
||||
final Integer newLoanProductCounter = getNewGroupLoanProductCounter(loan);
|
||||
updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
|
||||
@@ -1107,7 +1107,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
private Integer getNewGroupLoanCounter(final Loan loan) {
|
||||
|
||||
Integer maxClientLoanCounter = this.loanRepository.getMaxGroupLoanCounter(loan.getGroupId(), LoanType.GROUP.getValue());
|
||||
Integer maxClientLoanCounter = this.loanRepository.getMaxGroupLoanCounter(loan.getGroupId(), AccountType.GROUP.getValue());
|
||||
if (maxClientLoanCounter == null) {
|
||||
maxClientLoanCounter = 1;
|
||||
} else {
|
||||
@@ -1119,7 +1119,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
private Integer getNewGroupLoanProductCounter(final Loan loan) {
|
||||
|
||||
Integer maxLoanProductLoanCounter = this.loanRepository.getMaxGroupLoanProductCounter(loan.loanProduct().getId(),
|
||||
loan.getGroupId(), LoanType.GROUP.getValue());
|
||||
loan.getGroupId(), AccountType.GROUP.getValue());
|
||||
if (maxLoanProductLoanCounter == null) {
|
||||
maxLoanProductLoanCounter = 1;
|
||||
} else {
|
||||
|
||||
+3
-31
@@ -6,17 +6,17 @@
|
||||
package org.mifosplatform.portfolio.loanproduct.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountEnumerations;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanType;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
||||
|
||||
public class LoanEnumerations {
|
||||
public class LoanEnumerations{
|
||||
|
||||
public static final String LOAN_TERM_FREQUENCY_TYPE = "loanTermFrequencyType";
|
||||
public static final String TERM_FREQUENCY_TYPE = "termFrequencyType";
|
||||
@@ -44,7 +44,7 @@ public class LoanEnumerations {
|
||||
return interestType(id);
|
||||
} else if (typeName.equals(INTEREST_CALCULATION_PERIOD_TYPE)) {
|
||||
return interestCalculationPeriodType(id);
|
||||
} else if (typeName.equals(LOAN_TYPE)) { return loanType(id); }
|
||||
} else if (typeName.equals(LOAN_TYPE)) { return AccountEnumerations.loanType(id); }
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -333,32 +333,4 @@ public class LoanEnumerations {
|
||||
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData loanType(final Integer loanTypeId) {
|
||||
return loanType(LoanType.fromInt(loanTypeId));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanType(final String name) {
|
||||
return loanType(LoanType.fromName(name));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanType(final LoanType type) {
|
||||
EnumOptionData optionData = new EnumOptionData(LoanType.INVALID.getValue().longValue(), LoanType.INVALID.getCode(), "Invalid");
|
||||
switch (type) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(LoanType.INVALID.getValue().longValue(), LoanType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
case INDIVIDUAL:
|
||||
optionData = new EnumOptionData(LoanType.INDIVIDUAL.getValue().longValue(), LoanType.INDIVIDUAL.getCode(), "Individual");
|
||||
break;
|
||||
case GROUP:
|
||||
optionData = new EnumOptionData(LoanType.GROUP.getValue().longValue(), LoanType.GROUP.getCode(), "Group");
|
||||
break;
|
||||
case JLG:
|
||||
optionData = new EnumOptionData(LoanType.JLG.getValue().longValue(), LoanType.JLG.getCode(), "JLG");
|
||||
break;
|
||||
}
|
||||
|
||||
return optionData;
|
||||
}
|
||||
}
|
||||
+5
@@ -38,6 +38,7 @@ import org.mifosplatform.portfolio.client.domain.Client;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.group.domain.Group;
|
||||
import org.mifosplatform.portfolio.group.domain.GroupRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.group.exception.ClientNotInGroupException;
|
||||
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
|
||||
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
|
||||
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
|
||||
@@ -106,6 +107,10 @@ public class SavingsAccountAssembler {
|
||||
if (groupId != null) {
|
||||
group = this.groupRepository.findOneWithNotFoundDetection(groupId);
|
||||
}
|
||||
|
||||
if(group != null && client != null){
|
||||
if (!group.hasClientAsMember(client)) { throw new ClientNotInGroupException(clientId, groupId); }
|
||||
}
|
||||
|
||||
final Long fieldOfficerId = fromApiJsonHelper.extractLongNamed(fieldOfficerIdParamName, element);
|
||||
if (fieldOfficerId != null) {
|
||||
|
||||
Reference in New Issue
Block a user