support bringing back pending approval and approved deposit accounts first of with client account summary.
This commit is contained in:
@@ -24,7 +24,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.mifosng.platform.api.commands.ClientCommand;
|
import org.mifosng.platform.api.commands.ClientCommand;
|
||||||
import org.mifosng.platform.api.commands.NoteCommand;
|
import org.mifosng.platform.api.commands.NoteCommand;
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||||
import org.mifosng.platform.api.data.NoteData;
|
import org.mifosng.platform.api.data.NoteData;
|
||||||
import org.mifosng.platform.api.data.OfficeLookup;
|
import org.mifosng.platform.api.data.OfficeLookup;
|
||||||
@@ -216,7 +216,8 @@ public class ClientsApiResource {
|
|||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
||||||
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount")
|
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount",
|
||||||
|
"pendingApprovalDespositAccountsCount", "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts")
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
@@ -225,9 +226,9 @@ public class ClientsApiResource {
|
|||||||
}
|
}
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
ClientLoanAccountSummaryCollectionData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
ClientAccountSummaryCollectionData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serializeClientLoanAccountSummaryCollectionDataToJson(prettyPrint, responseParameters, clientAccount);
|
return this.apiJsonSerializerService.serializeClientAccountSummaryCollectionDataToJson(prettyPrint, responseParameters, clientAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
|||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object representing a summary of a clients various accounts.
|
||||||
|
*/
|
||||||
|
public class ClientAccountSummaryCollectionData {
|
||||||
|
|
||||||
|
private final int anyLoanCount;
|
||||||
|
private final int pendingApprovalLoanCount;
|
||||||
|
private final List<ClientAccountSummaryData> pendingApprovalLoans;
|
||||||
|
private final int awaitingDisbursalLoanCount;
|
||||||
|
private final List<ClientAccountSummaryData> awaitingDisbursalLoans;
|
||||||
|
private final int activeLoanCount;
|
||||||
|
private final List<ClientAccountSummaryData> openLoans;
|
||||||
|
private final int closedLoanCount;
|
||||||
|
private final List<ClientAccountSummaryData> closedLoans;
|
||||||
|
private final int pendingApprovalDespositAccountsCount;
|
||||||
|
private final List<ClientAccountSummaryData> pendingApprovalDepositAccounts;
|
||||||
|
private final int approvedDespositAccountsCount;
|
||||||
|
private final List<ClientAccountSummaryData> approvedDepositAccounts;
|
||||||
|
|
||||||
|
public ClientAccountSummaryCollectionData(
|
||||||
|
final List<ClientAccountSummaryData> pendingApprovalLoans,
|
||||||
|
final List<ClientAccountSummaryData> awaitingDisbursalLoans,
|
||||||
|
final List<ClientAccountSummaryData> openLoans,
|
||||||
|
final List<ClientAccountSummaryData> closedLoans,
|
||||||
|
final List<ClientAccountSummaryData> pendingApprovalDepositAccounts,
|
||||||
|
final List<ClientAccountSummaryData> approvedDepositAccounts) {
|
||||||
|
this.pendingApprovalLoans = pendingApprovalLoans;
|
||||||
|
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
||||||
|
this.openLoans = openLoans;
|
||||||
|
this.closedLoans = closedLoans;
|
||||||
|
this.pendingApprovalDepositAccounts = pendingApprovalDepositAccounts;
|
||||||
|
this.approvedDepositAccounts = approvedDepositAccounts;
|
||||||
|
|
||||||
|
this.pendingApprovalLoanCount = this.pendingApprovalLoans.size();
|
||||||
|
this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size();
|
||||||
|
this.activeLoanCount = this.openLoans.size();
|
||||||
|
this.closedLoanCount = this.closedLoans.size();
|
||||||
|
this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount;
|
||||||
|
|
||||||
|
this.pendingApprovalDespositAccountsCount = this.pendingApprovalDepositAccounts.size();
|
||||||
|
this.approvedDespositAccountsCount = this.approvedDepositAccounts.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnyLoanCount() {
|
||||||
|
return anyLoanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPendingApprovalLoanCount() {
|
||||||
|
return pendingApprovalLoanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getPendingApprovalLoans() {
|
||||||
|
return pendingApprovalLoans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAwaitingDisbursalLoanCount() {
|
||||||
|
return awaitingDisbursalLoanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getAwaitingDisbursalLoans() {
|
||||||
|
return awaitingDisbursalLoans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getActiveLoanCount() {
|
||||||
|
return activeLoanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getOpenLoans() {
|
||||||
|
return openLoans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClosedLoanCount() {
|
||||||
|
return closedLoanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getClosedLoans() {
|
||||||
|
return closedLoans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPendingApprovalDespositAccountsCount() {
|
||||||
|
return pendingApprovalDespositAccountsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getPendingApprovalDepositAccounts() {
|
||||||
|
return pendingApprovalDepositAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getApprovedDespositAccountsCount() {
|
||||||
|
return approvedDespositAccountsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientAccountSummaryData> getApprovedDepositAccounts() {
|
||||||
|
return approvedDepositAccounts;
|
||||||
|
}
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for client loan accounts.
|
||||||
|
*/
|
||||||
|
public class ClientAccountSummaryData {
|
||||||
|
|
||||||
|
private final Long id;
|
||||||
|
private final String externalId;
|
||||||
|
private final Long productId;
|
||||||
|
private final String productName;
|
||||||
|
private final Integer accountStatusId;
|
||||||
|
|
||||||
|
public ClientAccountSummaryData(
|
||||||
|
final Long id,
|
||||||
|
final String externalId,
|
||||||
|
final Long productId,
|
||||||
|
final String loanProductName,
|
||||||
|
final Integer loanStatusId) {
|
||||||
|
this.id = id;
|
||||||
|
this.externalId = externalId;
|
||||||
|
this.productId = productId;
|
||||||
|
this.productName = loanProductName;
|
||||||
|
this.accountStatusId = loanStatusId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExternalId() {
|
||||||
|
return externalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAccountStatusId() {
|
||||||
|
return accountStatusId;
|
||||||
|
}
|
||||||
|
}
|
||||||
-69
@@ -1,69 +0,0 @@
|
|||||||
package org.mifosng.platform.api.data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ClientLoanAccountSummaryCollectionData {
|
|
||||||
|
|
||||||
private List<ClientLoanAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
|
||||||
private List<ClientLoanAccountSummaryData> awaitingDisbursalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
|
||||||
private List<ClientLoanAccountSummaryData> openLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
|
||||||
private List<ClientLoanAccountSummaryData> closedLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
|
||||||
private int anyLoanCount;
|
|
||||||
private int pendingApprovalLoanCount;
|
|
||||||
private int awaitingDisbursalLoanCount;
|
|
||||||
private int activeLoanCount;
|
|
||||||
private int closedLoanCount;
|
|
||||||
|
|
||||||
public ClientLoanAccountSummaryCollectionData(
|
|
||||||
final List<ClientLoanAccountSummaryData> pendingApprovalLoans,
|
|
||||||
final List<ClientLoanAccountSummaryData> awaitingDisbursalLoans,
|
|
||||||
final List<ClientLoanAccountSummaryData> openLoans,
|
|
||||||
final List<ClientLoanAccountSummaryData> closedLoans) {
|
|
||||||
this.pendingApprovalLoans = pendingApprovalLoans;
|
|
||||||
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
|
||||||
this.openLoans = openLoans;
|
|
||||||
this.closedLoans = closedLoans;
|
|
||||||
this.pendingApprovalLoanCount = this.pendingApprovalLoans.size();
|
|
||||||
this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size();
|
|
||||||
this.activeLoanCount = this.openLoans.size();
|
|
||||||
this.closedLoanCount = this.closedLoans.size();
|
|
||||||
this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientLoanAccountSummaryData> getPendingApprovalLoans() {
|
|
||||||
return pendingApprovalLoans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientLoanAccountSummaryData> getAwaitingDisbursalLoans() {
|
|
||||||
return awaitingDisbursalLoans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientLoanAccountSummaryData> getOpenLoans() {
|
|
||||||
return openLoans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientLoanAccountSummaryData> getClosedLoans() {
|
|
||||||
return closedLoans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAnyLoanCount() {
|
|
||||||
return anyLoanCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPendingApprovalLoanCount() {
|
|
||||||
return pendingApprovalLoanCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAwaitingDisbursalLoanCount() {
|
|
||||||
return awaitingDisbursalLoanCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getActiveLoanCount() {
|
|
||||||
return activeLoanCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getClosedLoanCount() {
|
|
||||||
return closedLoanCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-65
@@ -1,65 +0,0 @@
|
|||||||
package org.mifosng.platform.api.data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public class ClientLoanAccountSummaryData implements Serializable {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
private String externalId;
|
|
||||||
private Long loanProductId;
|
|
||||||
private String loanProductName;
|
|
||||||
private Integer loanStatusId;
|
|
||||||
|
|
||||||
public ClientLoanAccountSummaryData() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientLoanAccountSummaryData(Long id, String externalId,
|
|
||||||
Long productId, String loanProductName, Integer loanStatusId) {
|
|
||||||
this.id = id;
|
|
||||||
this.externalId = externalId;
|
|
||||||
this.loanProductId = productId;
|
|
||||||
this.loanProductName = loanProductName;
|
|
||||||
this.loanStatusId = loanStatusId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExternalId() {
|
|
||||||
return externalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExternalId(String externalId) {
|
|
||||||
this.externalId = externalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoanProductName() {
|
|
||||||
return loanProductName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoanProductName(String loanProductName) {
|
|
||||||
this.loanProductName = loanProductName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getLoanProductId() {
|
|
||||||
return loanProductId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoanProductId(Long loanProductId) {
|
|
||||||
this.loanProductId = loanProductId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLoanStatusId() {
|
|
||||||
return loanStatusId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoanStatusId(Integer loanStatusId) {
|
|
||||||
this.loanStatusId = loanStatusId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -8,7 +8,7 @@ import org.mifosng.platform.api.data.AppUserData;
|
|||||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||||
import org.mifosng.platform.api.data.ChargeData;
|
import org.mifosng.platform.api.data.ChargeData;
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||||
import org.mifosng.platform.api.data.ConfigurationData;
|
import org.mifosng.platform.api.data.ConfigurationData;
|
||||||
import org.mifosng.platform.api.data.DepositAccountData;
|
import org.mifosng.platform.api.data.DepositAccountData;
|
||||||
import org.mifosng.platform.api.data.DepositProductData;
|
import org.mifosng.platform.api.data.DepositProductData;
|
||||||
@@ -76,7 +76,7 @@ public interface ApiJsonSerializerService {
|
|||||||
|
|
||||||
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
|
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
|
||||||
|
|
||||||
String serializeClientLoanAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientLoanAccountSummaryCollectionData clientAccount);
|
String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientAccountSummaryCollectionData clientAccount);
|
||||||
|
|
||||||
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups);
|
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups);
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -10,7 +10,7 @@ import org.mifosng.platform.api.data.AppUserData;
|
|||||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||||
import org.mifosng.platform.api.data.ChargeData;
|
import org.mifosng.platform.api.data.ChargeData;
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||||
import org.mifosng.platform.api.data.ConfigurationData;
|
import org.mifosng.platform.api.data.ConfigurationData;
|
||||||
import org.mifosng.platform.api.data.DepositAccountData;
|
import org.mifosng.platform.api.data.DepositAccountData;
|
||||||
import org.mifosng.platform.api.data.DepositProductData;
|
import org.mifosng.platform.api.data.DepositProductData;
|
||||||
@@ -90,7 +90,8 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
|||||||
|
|
||||||
private static final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
||||||
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount")
|
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount",
|
||||||
|
"pendingApprovalDespositAccountsCount", "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts")
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(
|
||||||
@@ -278,8 +279,8 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String serializeClientLoanAccountSummaryCollectionDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
public String serializeClientAccountSummaryCollectionDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||||
final ClientLoanAccountSummaryCollectionData clientAccount) {
|
final ClientAccountSummaryCollectionData clientAccount) {
|
||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_ACCOUNTS_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CLIENT_ACCOUNTS_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, clientAccount);
|
return helper.serializedJsonFrom(gsonDeserializer, clientAccount);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ package org.mifosng.platform.client.service;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||||
import org.mifosng.platform.api.data.ClientLookup;
|
import org.mifosng.platform.api.data.ClientLookup;
|
||||||
import org.mifosng.platform.api.data.NoteData;
|
import org.mifosng.platform.api.data.NoteData;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public interface ClientReadPlatformService {
|
|||||||
|
|
||||||
Collection<ClientLookup> retrieveAllIndividualClientsForLookup();
|
Collection<ClientLookup> retrieveAllIndividualClientsForLookup();
|
||||||
|
|
||||||
ClientLoanAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
ClientAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
||||||
|
|
||||||
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
||||||
|
|
||||||
|
|||||||
+65
-21
@@ -187,7 +187,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientLoanAccountSummaryCollectionData retrieveClientAccountDetails(final Long clientId) {
|
public ClientAccountSummaryCollectionData retrieveClientAccountDetails(final Long clientId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
@@ -195,22 +195,20 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
// Check if client exists
|
// Check if client exists
|
||||||
retrieveIndividualClient(clientId);
|
retrieveIndividualClient(clientId);
|
||||||
|
|
||||||
List<ClientLoanAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
List<ClientAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientAccountSummaryData>();
|
||||||
List<ClientLoanAccountSummaryData> awaitingDisbursalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
List<ClientAccountSummaryData> awaitingDisbursalLoans = new ArrayList<ClientAccountSummaryData>();
|
||||||
List<ClientLoanAccountSummaryData> openLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
List<ClientAccountSummaryData> openLoans = new ArrayList<ClientAccountSummaryData>();
|
||||||
List<ClientLoanAccountSummaryData> closedLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
List<ClientAccountSummaryData> closedLoans = new ArrayList<ClientAccountSummaryData>();
|
||||||
|
|
||||||
ClientLoanAccountSummaryDataMapper rm = new ClientLoanAccountSummaryDataMapper();
|
ClientLoanAccountSummaryDataMapper rm = new ClientLoanAccountSummaryDataMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.loanAccountSummarySchema()
|
String sql = "select " + rm.loanAccountSummarySchema() + " where l.client_id = ?";
|
||||||
+ " where l.client_id = ?";
|
|
||||||
|
|
||||||
List<ClientLoanAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] {clientId});
|
List<ClientAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] {clientId});
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
for (ClientLoanAccountSummaryData row : results) {
|
for (ClientAccountSummaryData row : results) {
|
||||||
|
|
||||||
LoanStatusMapper statusMapper = new LoanStatusMapper(
|
LoanStatusMapper statusMapper = new LoanStatusMapper(row.getAccountStatusId());
|
||||||
row.getLoanStatusId());
|
|
||||||
|
|
||||||
if (statusMapper.isOpen()) {
|
if (statusMapper.isOpen()) {
|
||||||
openLoans.add(row);
|
openLoans.add(row);
|
||||||
@@ -224,33 +222,50 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ClientLoanAccountSummaryCollectionData(
|
List<ClientAccountSummaryData> pendingApprovalDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||||
pendingApprovalLoans, awaitingDisbursalLoans, openLoans,
|
List<ClientAccountSummaryData> approvedDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||||
closedLoans);
|
// List<ClientLoanAccountSummaryData> openDepositAccounts = new ArrayList<ClientLoanAccountSummaryData>();
|
||||||
|
// List<ClientLoanAccountSummaryData> closedDepositAccounts = new ArrayList<ClientLoanAccountSummaryData>();
|
||||||
|
|
||||||
|
ClientDespoitAccountSummaryDataMapper depositAccountMapper = new ClientDespoitAccountSummaryDataMapper();
|
||||||
|
|
||||||
|
String depositAccountsSql = "select " + depositAccountMapper.schema() + " where da.client_id = ? and da.is_deleted=0";
|
||||||
|
List<ClientAccountSummaryData> depositAccountResults = this.jdbcTemplate.query(depositAccountsSql, depositAccountMapper, new Object[] {clientId});
|
||||||
|
if (depositAccountResults != null) {
|
||||||
|
for (ClientAccountSummaryData row : depositAccountResults) {
|
||||||
|
|
||||||
|
if (row.getAccountStatusId() == 100) {
|
||||||
|
pendingApprovalDepositAccounts.add(row);
|
||||||
|
} else if (row.getAccountStatusId() == 200) {
|
||||||
|
approvedDepositAccounts.add(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ClientAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans,
|
||||||
|
pendingApprovalDepositAccounts, approvedDepositAccounts);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
throw new ClientNotFoundException(clientId);
|
throw new ClientNotFoundException(clientId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ClientLoanAccountSummaryDataMapper implements
|
private static final class ClientLoanAccountSummaryDataMapper implements
|
||||||
RowMapper<ClientLoanAccountSummaryData> {
|
RowMapper<ClientAccountSummaryData> {
|
||||||
|
|
||||||
public String loanAccountSummarySchema() {
|
public String loanAccountSummarySchema() {
|
||||||
|
|
||||||
StringBuilder loanAccountSummary = new StringBuilder(
|
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.external_id as externalId,");
|
||||||
"l.id as id, l.external_id as externalId,");
|
accountsSummary
|
||||||
loanAccountSummary
|
|
||||||
.append("l.product_id as productId, lp.name as productName,")
|
.append("l.product_id as productId, lp.name as productName,")
|
||||||
.append("l.loan_status_id as statusId ")
|
.append("l.loan_status_id as statusId ")
|
||||||
.append("from m_loan l ")
|
.append("from m_loan l ")
|
||||||
.append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
.append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
||||||
|
|
||||||
return loanAccountSummary.toString();
|
return accountsSummary.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientLoanAccountSummaryData mapRow(final ResultSet rs,
|
public ClientAccountSummaryData mapRow(final ResultSet rs,
|
||||||
final int rowNum) throws SQLException {
|
final int rowNum) throws SQLException {
|
||||||
|
|
||||||
Long id = JdbcSupport.getLong(rs, "id");
|
Long id = JdbcSupport.getLong(rs, "id");
|
||||||
@@ -259,10 +274,39 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
String loanProductName = rs.getString("productName");
|
String loanProductName = rs.getString("productName");
|
||||||
Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||||
|
|
||||||
return new ClientLoanAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId);
|
return new ClientAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class ClientDespoitAccountSummaryDataMapper implements RowMapper<ClientAccountSummaryData> {
|
||||||
|
|
||||||
|
public String schema() {
|
||||||
|
|
||||||
|
StringBuilder accountsSummary = new StringBuilder("da.id as id, da.external_id as externalId,");
|
||||||
|
accountsSummary.append("da.product_id as productId, dp.name as productName,")
|
||||||
|
.append("da.status_enum as statusId ")
|
||||||
|
.append("from m_deposit_account da ")
|
||||||
|
.append("LEFT JOIN m_product_deposit AS dp ON dp.id = da.product_id ");
|
||||||
|
|
||||||
|
return accountsSummary.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientAccountSummaryData mapRow(final ResultSet rs,
|
||||||
|
final int rowNum) throws SQLException {
|
||||||
|
|
||||||
|
Long id = JdbcSupport.getLong(rs, "id");
|
||||||
|
String externalId = rs.getString("externalId");
|
||||||
|
Long productId = JdbcSupport.getLong(rs, "productId");
|
||||||
|
String productName = rs.getString("productName");
|
||||||
|
Integer accountStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||||
|
|
||||||
|
return new ClientAccountSummaryData(id, externalId, productId, productName, accountStatusId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NoteData retrieveClientNote(Long clientId, Long noteId) {
|
public NoteData retrieveClientNote(Long clientId, Long noteId) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user