update api-docs around client and client account summary.

This commit is contained in:
Keith Woodlock
2012-12-24 13:57:30 +00:00
parent c99053d2a4
commit 8dc8dcad52
6 changed files with 226 additions and 250 deletions
+49 -65
View File
@@ -513,7 +513,7 @@ var jqxhr = $.ajax({
"firstname" : "Patrick", "firstname" : "Patrick",
"lastname" : "Asare-Frimpong", "lastname" : "Asare-Frimpong",
"displayName" : "Patrick Asare-Frimpong", "displayName" : "Patrick Asare-Frimpong",
"externalId" : null, "externalId" : "123AB",
"joinedDate" : [ 2012, 4, 18 ] "joinedDate" : [ 2012, 4, 18 ]
}, { }, {
"officeId" : 5, "officeId" : 5,
@@ -522,7 +522,6 @@ var jqxhr = $.ajax({
"firstname" : "firstMajmoua", "firstname" : "firstMajmoua",
"lastname" : "client", "lastname" : "client",
"displayName" : "firstMajmoua client", "displayName" : "firstMajmoua client",
"externalId" : null,
"joinedDate" : [ 2011, 12, 1 ] "joinedDate" : [ 2011, 12, 1 ]
}... ] }... ]
</code> </code>
@@ -589,7 +588,6 @@ var jqxhr = $.ajax({
"firstname" : "Patrick", "firstname" : "Patrick",
"lastname" : "O'Meara", "lastname" : "O'Meara",
"displayName" : "Patrick O'Meara", "displayName" : "Patrick O'Meara",
"externalId" : null,
"joinedDate" : [ 2009, 1, 4 ] "joinedDate" : [ 2009, 1, 4 ]
} }
</code> </code>
@@ -602,12 +600,11 @@ var jqxhr = $.ajax({
<h4>Create a Client</h4> <h4>Create a Client</h4>
<p> <b>Note:</b> You can enter either:<br> <p> <b>Note:</b> You can enter either:<br>
firstname/lastname - for a person OR<br> firstname/lastname - for a person OR<br>
clientOrBusinessName - for a business or organisation (or person known by one name).<br><br> clientOrBusinessName - for a business or organisation (or person known by one name).<br>
If you use clientOrBusinessName, the value is placed in the lastname field when you retrieve clients.
</p> </p>
<table class=matrixHeading> <table class=matrixHeading>
<tr class="matrixHeadingBG"><td><div class="mifosXHeading2">Mandatory Fields</div></td></tr> <tr class="matrixHeadingBG"><td><div class="mifosXHeading2">Mandatory Fields</div></td></tr>
<tr class=alt><td>firstname and lastname OR clientOrBusinessName<br>, joiningDate, officeId</td></tr> <tr class=alt><td>firstname and lastname OR clientOrBusinessName<br>, joinedDate, officeId</td></tr>
</table> </table>
</div> </div>
<div class="method-example"> <div class="method-example">
@@ -621,7 +618,8 @@ Request Body:
"lastname": "Yton", "lastname": "Yton",
"externalId": "786YYH7", "externalId": "786YYH7",
"dateFormat": "dd MMMM yyyy", "dateFormat": "dd MMMM yyyy",
"joiningDate": "04 March 2009" "locale": "en",
"joinedDate": "04 March 2009"
} }
</code> </code>
<code class="method-response"> <code class="method-response">
@@ -639,7 +637,8 @@ Request Body:
"clientOrBusinessName": "New Business to Create", "clientOrBusinessName": "New Business to Create",
"externalId": "one/78", "externalId": "one/78",
"dateFormat": "dd MMMM yyyy", "dateFormat": "dd MMMM yyyy",
"joiningDate": "13 June 2006" "locale": "en",
"joinedDate": "13 June 2006"
} }
</code> </code>
<code class="method-response"> <code class="method-response">
@@ -663,7 +662,8 @@ Request Body:
{ {
"externalId": "786444UUUYYH7", "externalId": "786444UUUYYH7",
"dateFormat": "dd MMMM yyyy", "dateFormat": "dd MMMM yyyy",
"joiningDate": "09 June 2006" "locale": "en",
"joinedDate": "09 June 2006"
} }
</code> </code>
<code class="method-response">{ "resourceId": 23}</code> <code class="method-response">{ "resourceId": 23}</code>
@@ -682,44 +682,48 @@ Request Body:
<p>Example Requests: </p> <p>Example Requests: </p>
<div class=apiClick>clients/1/loans</div> <div class=apiClick>clients/1/loans</div>
<br><br> <br><br>
<div class=apiClick>clients/1/loans?fields=openLoans,%20closedLoans,activeLoanCount</div> <div class=apiClick>clients/1/loans?fields=openLoans,closedLoans,activeLoanCount</div>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://Domain Name/api/v1/clients/{clientId}/loans</code> <code class="method-declaration">GET https://Domain Name/api/v1/clients/{clientId}/loans</code>
<code class="method-response">{ <code class="method-response">{
"pendingApprovalLoans" : [ ], "anyLoanCount": 3,
"awaitingDisbursalLoans" : [ { "activeLoanCount": 2,
"id" : 17, "openLoans": [
"externalId" : null, {
"loanProductId" : 1, "id": 22,
"loanProductName" : "Agricultural Loan", "productId": 1,
"loanStatusId" : 200, "productName": "Agricultural Loan",
"pendingApproval" : false, "status": {
"waitingForDisbursal" : true, "id": 300,
"open" : false, "code": "loanStatusType.active",
"closed" : false, "value": "Active"
"lifeCycleStatusText" : "Approved", }
"lifeCycleStatusDate" : null },
} ], {
"openLoans" : [ ], "id": 44,
"closedLoans" : [ { "productId": 1,
"id" : 1, "productName": "Agricultural Loan",
"externalId" : null, "status": {
"loanProductId" : 1, "id": 300,
"loanProductName" : "Agricultural Loan", "code": "loanStatusType.active",
"loanStatusId" : 600, "value": "Active"
"pendingApproval" : false, }
"waitingForDisbursal" : false, }
"open" : false, ],
"closed" : true, "closedLoanCount": 1,
"lifeCycleStatusText" : "Closed", "closedLoans": [
"lifeCycleStatusDate" : null {
} ], "id": 33,
"anyLoanCount" : 2, "productId": 1,
"pendingApprovalLoanCount" : 0, "productName": "Agricultural Loan",
"awaitingDisbursalLoanCount" : 1, "status": {
"activeLoanCount" : 0, "id": 601,
"closedLoanCount" : 1 "code": "loanStatusType.closed.written.off",
"value": "Closed (written off)"
}
}
]
} }
</code> </code>
</div> </div>
@@ -743,8 +747,6 @@ Request Body:
<code class="method-response">[ { <code class="method-response">[ {
"id" : 20, "id" : 20,
"clientId" : 2, "clientId" : 2,
"loanId" : null,
"loanTransactionId" : null,
"noteType" : { "noteType" : {
"id" : 100, "id" : 100,
"code" : "noteType.client", "code" : "noteType.client",
@@ -760,8 +762,6 @@ Request Body:
}, { }, {
"id" : 16, "id" : 16,
"clientId" : 2, "clientId" : 2,
"loanId" : null,
"loanTransactionId" : null,
"noteType" : { "noteType" : {
"id" : 100, "id" : 100,
"code" : "noteType.client", "code" : "noteType.client",
@@ -814,8 +814,6 @@ Request Body:
<code class="method-response">{ <code class="method-response">{
"id" : 20, "id" : 20,
"clientId" : 2, "clientId" : 2,
"loanId" : null,
"loanTransactionId" : null,
"noteType" : { "noteType" : {
"id" : 100, "id" : 100,
"code" : "noteType.client", "code" : "noteType.client",
@@ -1422,8 +1420,6 @@ Request Body:
<code class="method-response">{ <code class="method-response">{
"id" : 10, "id" : 10,
"date" : [ 2009, 1, 29 ], "date" : [ 2009, 1, 29 ],
"principal" : null,
"interest" : null,
"total" : { "total" : {
"currencyCode" : "XOF", "currencyCode" : "XOF",
"digitsAfterDecimal" : 0, "digitsAfterDecimal" : 0,
@@ -1435,8 +1431,6 @@ Request Body:
"greaterThanZero" : true, "greaterThanZero" : true,
"displaySymbolValue" : "300000 CFA" "displaySymbolValue" : "300000 CFA"
}, },
"totalWaived" : null,
"overpaid" : null,
"transactionOffsetFromToday" : -1218 "transactionOffsetFromToday" : -1218
} }
</code> </code>
@@ -1514,13 +1508,10 @@ Request Body:
"name" : "Demo MFI Head Office", "name" : "Demo MFI Head Office",
"externalId" : "1", "externalId" : "1",
"openingDate" : [ 2009, 1, 1 ], "openingDate" : [ 2009, 1, 1 ],
"hierarchy" : ".", "hierarchy" : "."
"parentName" : null,
"parentId" : null
}, { }, {
"id" : 2, "id" : 2,
"name" : "B1", "name" : "B1",
"externalId" : null,
"openingDate" : [ 2012, 4, 1 ], "openingDate" : [ 2012, 4, 1 ],
"hierarchy" : ".2.", "hierarchy" : ".2.",
"parentName" : "Demo MFI Head Office", "parentName" : "Demo MFI Head Office",
@@ -1528,7 +1519,6 @@ Request Body:
}, { }, {
"id" : 3, "id" : 3,
"name" : "B2", "name" : "B2",
"externalId" : null,
"openingDate" : [ 2012, 4, 4 ], "openingDate" : [ 2012, 4, 4 ],
"hierarchy" : ".3.", "hierarchy" : ".3.",
"parentName" : "Demo MFI Head Office", "parentName" : "Demo MFI Head Office",
@@ -1588,9 +1578,7 @@ Request Body:
"name" : "Demo MFI Head Office", "name" : "Demo MFI Head Office",
"externalId" : "1", "externalId" : "1",
"openingDate" : [ 2009, 1, 1 ], "openingDate" : [ 2009, 1, 1 ],
"hierarchy" : ".", "hierarchy" : "."
"parentName" : null,
"parentId" : null
} }
</code> </code>
</div> </div>
@@ -1775,7 +1763,6 @@ Request Body:
}, { }, {
"id" : 2, "id" : 2,
"name" : "Brunei Loan", "name" : "Brunei Loan",
"description" : null,
"principal" : { "principal" : {
"currencyCode" : "BND", "currencyCode" : "BND",
"digitsAfterDecimal" : 2, "digitsAfterDecimal" : 2,
@@ -2169,7 +2156,6 @@ Request Body:
"code" : "ETB", "code" : "ETB",
"name" : "Ethiopian Birr", "name" : "Ethiopian Birr",
"decimalPlaces" : 2, "decimalPlaces" : 2,
"displaySymbol" : null,
"nameCode" : "currency.ETB", "nameCode" : "currency.ETB",
"displayLabel" : "Ethiopian Birr [ETB]" "displayLabel" : "Ethiopian Birr [ETB]"
} ], } ],
@@ -2177,14 +2163,12 @@ Request Body:
"code" : "AED", "code" : "AED",
"name" : "UAE Dirham", "name" : "UAE Dirham",
"decimalPlaces" : 2, "decimalPlaces" : 2,
"displaySymbol" : null,
"nameCode" : "currency.AED", "nameCode" : "currency.AED",
"displayLabel" : "UAE Dirham [AED]" "displayLabel" : "UAE Dirham [AED]"
}, { }, {
"code" : "AFN", "code" : "AFN",
"name" : "Afghanistan Afghani", "name" : "Afghanistan Afghani",
"decimalPlaces" : 2, "decimalPlaces" : 2,
"displaySymbol" : null,
"nameCode" : "currency.AFN", "nameCode" : "currency.AFN",
"displayLabel" : "Afghanistan Afghani [AFN]" "displayLabel" : "Afghanistan Afghani [AFN]"
}, ... }, ...
@@ -254,11 +254,15 @@ public class ClientsApiResource {
final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("pendingApprovalLoans", final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("pendingApprovalLoans",
"awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount",
"awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount", "pendingApprovalDespositAccountsCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount", "pendingApprovalDepositAccountsCount",
"pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts", "pendingApprovalDepositAccounts", "approvedDepositAccountsCount", "approvedDepositAccounts",
"withdrawnByClientDespositAccountsCount", "withdrawnByClientDespositAccounts", "closedDepositAccountsCount", "withdrawnByClientDepositAccountsCount", "withdrawnByClientDepositAccounts", "closedDepositAccountsCount",
"closedDepositAccounts", "rejectedDepositAccountsCount", "rejectedDepositAccounts", "preclosedDepositAccountsCount", "closedDepositAccounts", "maturedDepositAccountsCount", "maturedDepositAccounts", "rejectedDepositAccountsCount",
"preclosedDepositAccounts")); "rejectedDepositAccounts", "preclosedDepositAccountsCount", "preclosedDepositAccounts",
"pendingApprovalSavingAccountsCount", "pendingApprovalSavingAccounts", "approvedSavingAccountsCount",
"approvedSavingAccounts", "withdrawnByClientSavingAccountsCount", "withdrawnByClientSavingAccounts",
"rejectedSavingAccountsCount", "rejectedSavingAccounts", "closedSavingAccountsCount", "closedSavingAccounts"));
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS); return this.clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS);
@@ -1,189 +1,152 @@
package org.mifosplatform.portfolio.client.data; package org.mifosplatform.portfolio.client.data;
import java.util.List; import java.util.Collection;
/** /**
* Immutable data object representing a summary of a clients various accounts. * Immutable data object representing a summary of a clients various accounts.
*/ */
public class ClientAccountSummaryCollectionData { public class ClientAccountSummaryCollectionData {
private final int anyLoanCount; @SuppressWarnings("unused")
private final int pendingApprovalLoanCount; private final Integer anyLoanCount;
private final List<ClientAccountSummaryData> pendingApprovalLoans; private final Integer pendingApprovalLoanCount;
private final int awaitingDisbursalLoanCount; private final Collection<ClientAccountSummaryData> pendingApprovalLoans;
private final List<ClientAccountSummaryData> awaitingDisbursalLoans; private final Integer awaitingDisbursalLoanCount;
private final int activeLoanCount; private final Collection<ClientAccountSummaryData> awaitingDisbursalLoans;
private final List<ClientAccountSummaryData> openLoans; private final Integer activeLoanCount;
private final int closedLoanCount; private final Collection<ClientAccountSummaryData> openLoans;
private final List<ClientAccountSummaryData> closedLoans; private final Integer closedLoanCount;
private final int pendingApprovalDespositAccountsCount; private final Collection<ClientAccountSummaryData> closedLoans;
private final List<ClientAccountSummaryData> pendingApprovalDepositAccounts; @SuppressWarnings("unused")
private final int approvedDespositAccountsCount; private final Integer pendingApprovalDepositAccountsCount;
private final List<ClientAccountSummaryData> approvedDepositAccounts; private final Collection<ClientAccountSummaryData> pendingApprovalDepositAccounts;
private final int withdrawnByClientDespositAccountsCount; @SuppressWarnings("unused")
private final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts; private final Integer approvedDepositAccountsCount;
private final int closedDepositAccountsCount; private final Collection<ClientAccountSummaryData> approvedDepositAccounts;
private final List<ClientAccountSummaryData> closedDepositAccounts; @SuppressWarnings("unused")
private final int rejectedDepositAccountsCount; private final Integer withdrawnByClientDepositAccountsCount;
private final List<ClientAccountSummaryData> rejectedDepositAccounts; private final Collection<ClientAccountSummaryData> withdrawnByClientDepositAccounts;
private final int preclosedDepositAccountsCount; @SuppressWarnings("unused")
private final List<ClientAccountSummaryData> preclosedDepositAccounts; private final Integer closedDepositAccountsCount;
private final int maturedDepositAccountsCount; private final Collection<ClientAccountSummaryData> closedDepositAccounts;
private final List<ClientAccountSummaryData> maturedDepositAccounts; @SuppressWarnings("unused")
private final int pendingApprovalSavingAccountsCount; private final Integer rejectedDepositAccountsCount;
private final List<ClientAccountSummaryData> pendingApprovalSavingAccounts; private final Collection<ClientAccountSummaryData> rejectedDepositAccounts;
private final int approvedSavingAccountsCount; @SuppressWarnings("unused")
private final List<ClientAccountSummaryData> approvedSavingAccounts; private final Integer preclosedDepositAccountsCount;
private final int withdrawnByClientSavingAccountsCount; private final Collection<ClientAccountSummaryData> preclosedDepositAccounts;
private final List<ClientAccountSummaryData> withdrawnByClientSavingAccounts; @SuppressWarnings("unused")
private final int rejectedSavingAccountsCount; private final Integer maturedDepositAccountsCount;
private final List<ClientAccountSummaryData> rejectedSavingAccounts; private final Collection<ClientAccountSummaryData> maturedDepositAccounts;
private final int closedSavingAccountsCount; @SuppressWarnings("unused")
private final List<ClientAccountSummaryData> closedSavingAccounts; private final Integer pendingApprovalSavingAccountsCount;
private final Collection<ClientAccountSummaryData> pendingApprovalSavingAccounts;
@SuppressWarnings("unused")
private final Integer approvedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> approvedSavingAccounts;
@SuppressWarnings("unused")
private final Integer withdrawnByClientSavingAccountsCount;
private final Collection<ClientAccountSummaryData> withdrawnByClientSavingAccounts;
@SuppressWarnings("unused")
private final Integer rejectedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> rejectedSavingAccounts;
@SuppressWarnings("unused")
private final Integer closedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> closedSavingAccounts;
public ClientAccountSummaryCollectionData( public ClientAccountSummaryCollectionData(final Collection<ClientAccountSummaryData> pendingApprovalLoans,
final List<ClientAccountSummaryData> pendingApprovalLoans, final Collection<ClientAccountSummaryData> awaitingDisbursalLoans, final Collection<ClientAccountSummaryData> openLoans,
final List<ClientAccountSummaryData> awaitingDisbursalLoans, final Collection<ClientAccountSummaryData> closedLoans,
final List<ClientAccountSummaryData> openLoans, final Collection<ClientAccountSummaryData> pendingApprovalDepositAccounts,
final List<ClientAccountSummaryData> closedLoans, final Collection<ClientAccountSummaryData> approvedDepositAccounts,
final List<ClientAccountSummaryData> pendingApprovalDepositAccounts, final Collection<ClientAccountSummaryData> withdrawnByClientDepositAccounts,
final List<ClientAccountSummaryData> approvedDepositAccounts, final Collection<ClientAccountSummaryData> rejectedDepositAccounts,
final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts, final Collection<ClientAccountSummaryData> closedDepositAccounts,
final List<ClientAccountSummaryData> rejectedDepositAccounts, final Collection<ClientAccountSummaryData> preclosedDepositAccounts,
final List<ClientAccountSummaryData> closedDepositAccounts, final Collection<ClientAccountSummaryData> maturedDepositAccounts,
final List<ClientAccountSummaryData> preclosedDepositAccounts, final Collection<ClientAccountSummaryData> pendingApprovalSavingAccounts,
final List<ClientAccountSummaryData> maturedDepositAccounts, final Collection<ClientAccountSummaryData> approvedSavingAccounts,
final List<ClientAccountSummaryData> pendingApprovalSavingAccounts, final Collection<ClientAccountSummaryData> withdrawnByClientSavingAccounts,
final List<ClientAccountSummaryData> approvedSavingAccounts, final Collection<ClientAccountSummaryData> rejectedSavingAccounts,
final List<ClientAccountSummaryData> withdrawnByClientSavingAccounts, final Collection<ClientAccountSummaryData> closedSavingAccounts) {
final List<ClientAccountSummaryData> rejectedSavingAccounts,
final List<ClientAccountSummaryData> closedSavingAccounts) {
this.pendingApprovalLoans = pendingApprovalLoans;
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
this.openLoans = openLoans;
this.closedLoans = closedLoans;
this.pendingApprovalDepositAccounts = pendingApprovalDepositAccounts;
this.approvedDepositAccounts = approvedDepositAccounts;
this.withdrawnByClientDespositAccounts = withdrawnByClientDespositAccounts;
this.closedDepositAccounts = closedDepositAccounts;
this.rejectedDepositAccounts = rejectedDepositAccounts;
this.preclosedDepositAccounts = preclosedDepositAccounts;
this.maturedDepositAccounts = maturedDepositAccounts;
// saving accounts this.pendingApprovalLoans = defaultIfEmpty(pendingApprovalLoans);
this.pendingApprovalSavingAccounts = pendingApprovalSavingAccounts; this.awaitingDisbursalLoans = defaultIfEmpty(awaitingDisbursalLoans);
this.approvedSavingAccounts = approvedSavingAccounts; this.openLoans = defaultIfEmpty(openLoans);
this.withdrawnByClientSavingAccounts = withdrawnByClientSavingAccounts; this.closedLoans = defaultIfEmpty(closedLoans);
this.rejectedSavingAccounts = rejectedSavingAccounts;
this.closedSavingAccounts = closedSavingAccounts;
this.pendingApprovalLoanCount = this.pendingApprovalLoans.size(); this.pendingApprovalDepositAccounts = defaultIfEmpty(pendingApprovalDepositAccounts);
this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size(); this.approvedDepositAccounts = defaultIfEmpty(approvedDepositAccounts);
this.activeLoanCount = this.openLoans.size(); this.withdrawnByClientDepositAccounts = defaultIfEmpty(withdrawnByClientDepositAccounts);
this.closedLoanCount = this.closedLoans.size(); this.closedDepositAccounts = defaultIfEmpty(closedDepositAccounts);
this.rejectedDepositAccounts = defaultIfEmpty(rejectedDepositAccounts);
this.preclosedDepositAccounts = defaultIfEmpty(preclosedDepositAccounts);
this.maturedDepositAccounts = defaultIfEmpty(maturedDepositAccounts);
this.pendingApprovalDespositAccountsCount = this.pendingApprovalDepositAccounts.size(); this.pendingApprovalSavingAccounts = defaultIfEmpty(pendingApprovalSavingAccounts);
this.approvedDespositAccountsCount = this.approvedDepositAccounts.size(); this.approvedSavingAccounts = defaultIfEmpty(approvedSavingAccounts);
this.withdrawnByClientDespositAccountsCount = this.withdrawnByClientDespositAccounts.size(); this.withdrawnByClientSavingAccounts = defaultIfEmpty(withdrawnByClientSavingAccounts);
this.closedDepositAccountsCount = this.closedDepositAccounts.size(); this.rejectedSavingAccounts = defaultIfEmpty(rejectedSavingAccounts);
this.rejectedDepositAccountsCount = this.rejectedDepositAccounts.size(); this.closedSavingAccounts = defaultIfEmpty(closedSavingAccounts);
this.preclosedDepositAccountsCount = this.preclosedDepositAccounts.size();
this.maturedDepositAccountsCount = this.maturedDepositAccounts.size();
this.pendingApprovalSavingAccountsCount = this.pendingApprovalSavingAccounts.size();
this.approvedSavingAccountsCount = this.approvedSavingAccounts.size();
this.withdrawnByClientSavingAccountsCount = this.withdrawnByClientSavingAccounts.size();
this.rejectedSavingAccountsCount = this.rejectedSavingAccounts.size();
this.closedSavingAccountsCount = this.closedSavingAccounts.size();
this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount this.pendingApprovalLoanCount = defaultToNullIfEmpty(this.pendingApprovalLoans);
+this.pendingApprovalDespositAccountsCount+this.approvedDespositAccountsCount+this.withdrawnByClientDespositAccountsCount+this.closedDepositAccountsCount this.awaitingDisbursalLoanCount = defaultToNullIfEmpty(this.awaitingDisbursalLoans);
+this.rejectedDepositAccountsCount+this.preclosedDepositAccountsCount+this.maturedDepositAccountsCount this.activeLoanCount = defaultToNullIfEmpty(this.openLoans);
+this.pendingApprovalSavingAccountsCount+this.approvedSavingAccountsCount+this.withdrawnByClientSavingAccountsCount this.closedLoanCount = defaultToNullIfEmpty(this.closedLoans);
+this.rejectedSavingAccountsCount+this.closedSavingAccountsCount;
} this.pendingApprovalDepositAccountsCount = defaultToNullIfEmpty(this.pendingApprovalDepositAccounts);
this.approvedDepositAccountsCount = defaultToNullIfEmpty(this.approvedDepositAccounts);
this.withdrawnByClientDepositAccountsCount = defaultToNullIfEmpty(this.withdrawnByClientDepositAccounts);
this.closedDepositAccountsCount = defaultToNullIfEmpty(this.closedDepositAccounts);
this.rejectedDepositAccountsCount = defaultToNullIfEmpty(this.rejectedDepositAccounts);
this.preclosedDepositAccountsCount = defaultToNullIfEmpty(this.preclosedDepositAccounts);
this.maturedDepositAccountsCount = defaultToNullIfEmpty(this.maturedDepositAccounts);
this.pendingApprovalSavingAccountsCount = defaultToNullIfEmpty(this.pendingApprovalSavingAccounts);
this.approvedSavingAccountsCount = defaultToNullIfEmpty(this.approvedSavingAccounts);
this.withdrawnByClientSavingAccountsCount = defaultToNullIfEmpty(this.withdrawnByClientSavingAccounts);
this.rejectedSavingAccountsCount = defaultToNullIfEmpty(this.rejectedSavingAccounts);
this.closedSavingAccountsCount = defaultToNullIfEmpty(this.closedSavingAccounts);
public int getAnyLoanCount() { this.anyLoanCount = countOf(this.pendingApprovalLoanCount, this.awaitingDisbursalLoanCount, this.activeLoanCount,
return anyLoanCount; this.closedLoanCount);
} //
// , this.pendingApprovalDepositAccountsCount,
// this.approvedDepositAccountsCount
// , this.withdrawnByClientDepositAccountsCount,
// this.closedDepositAccountsCount, this.rejectedDepositAccountsCount
// , this.preclosedDepositAccountsCount,
// this.maturedDepositAccountsCount,
// this.pendingApprovalSavingAccountsCount
// , this.approvedSavingAccountsCount,
// this.withdrawnByClientSavingAccountsCount,
// this.rejectedSavingAccountsCount
// , this.closedSavingAccountsCount);
public int getPendingApprovalLoanCount() { }
return pendingApprovalLoanCount;
}
public List<ClientAccountSummaryData> getPendingApprovalLoans() { private Integer countOf(final Integer... objects) {
return pendingApprovalLoans; Integer count = Integer.valueOf(0);
} for (Integer value : objects) {
if (value != null) {
count = count + value;
}
}
return count;
}
public int getAwaitingDisbursalLoanCount() { private Integer defaultToNullIfEmpty(final Collection<ClientAccountSummaryData> collection) {
return awaitingDisbursalLoanCount; Integer count = null;
} if (defaultIfEmpty(collection) != null) {
count = collection.size();
}
return count;
}
public List<ClientAccountSummaryData> getAwaitingDisbursalLoans() { private Collection<ClientAccountSummaryData> defaultIfEmpty(final Collection<ClientAccountSummaryData> collection) {
return awaitingDisbursalLoans; Collection<ClientAccountSummaryData> returnCollection = null;
} if (collection != null && !collection.isEmpty()) {
returnCollection = collection;
public int getActiveLoanCount() { }
return activeLoanCount; return returnCollection;
} }
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;
}
public int getWithdrawnByClientDespositAccountsCount() {
return withdrawnByClientDespositAccountsCount;
}
public List<ClientAccountSummaryData> getWithdrawnByClientDespositAccounts() {
return withdrawnByClientDespositAccounts;
}
public int getClosedDepositAccountsCount() {
return closedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getClosedDepositAccounts() {
return closedDepositAccounts;
}
public int getRejectedDepositAccountsCount() {
return rejectedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getRejectedDepositAccounts() {
return rejectedDepositAccounts;
}
public int getPreclosedDepositAccountsCount() {
return preclosedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getPreclosedDepositAccounts() {
return preclosedDepositAccounts;
}
} }
@@ -1,5 +1,7 @@
package org.mifosplatform.portfolio.client.data; package org.mifosplatform.portfolio.client.data;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
/** /**
* Immutable data object for client loan accounts. * Immutable data object for client loan accounts.
*/ */
@@ -13,7 +15,9 @@ public class ClientAccountSummaryData {
private final Long productId; private final Long productId;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final String productName; private final String productName;
private final Integer accountStatusId; private final Integer accountStatusId;
private final EnumOptionData status;
public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName, public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName,
final Integer loanStatusId) { final Integer loanStatusId) {
@@ -22,9 +26,28 @@ public class ClientAccountSummaryData {
this.productId = productId; this.productId = productId;
this.productName = loanProductName; this.productName = loanProductName;
this.accountStatusId = loanStatusId; this.accountStatusId = loanStatusId;
this.status = null;
}
/**
* Rather than use id, just be consistent and use EnumOptionData for the
* status of an account.
*/
public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName,
final EnumOptionData loanStatus) {
this.id = id;
this.externalId = externalId;
this.productId = productId;
this.productName = loanProductName;
this.accountStatusId = null;
this.status = loanStatus;
} }
public Integer accountStatusId() { public Integer accountStatusId() {
return accountStatusId; Integer accountStatus = this.accountStatusId;
if (accountStatus == null && this.status != null) {
accountStatus = this.status.getId().intValue();
}
return accountStatus;
} }
} }
@@ -103,7 +103,7 @@ final public class ClientData {
this.officeId = officeId; this.officeId = officeId;
this.officeName = officeName; this.officeName = officeName;
this.id = id; this.id = id;
this.firstname = firstname; this.firstname = StringUtils.defaultIfEmpty(firstname, null);
/*** unset last name for business name **/ /*** unset last name for business name **/
if (StringUtils.isBlank(firstname)) { if (StringUtils.isBlank(firstname)) {
@@ -114,7 +114,7 @@ final public class ClientData {
this.clientOrBusinessName = null; this.clientOrBusinessName = null;
} }
this.displayName = displayName; this.displayName = displayName;
this.externalId = externalId; this.externalId = StringUtils.defaultIfEmpty(externalId, null);
this.joinedDate = joinedDate; this.joinedDate = joinedDate;
this.imageKey = imageKey; this.imageKey = imageKey;
if (imageKey != null) { if (imageKey != null) {
@@ -25,6 +25,7 @@ import org.mifosplatform.portfolio.client.domain.NoteEnumerations;
import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException; import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException;
import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.client.exception.ClientNotFoundException;
import org.mifosplatform.portfolio.client.exception.NoteNotFoundException; import org.mifosplatform.portfolio.client.exception.NoteNotFoundException;
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
import org.mifosplatform.useradministration.data.AppUserData; import org.mifosplatform.useradministration.data.AppUserData;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
import org.mifosplatform.useradministration.service.AppUserReadPlatformService; import org.mifosplatform.useradministration.service.AppUserReadPlatformService;
@@ -314,13 +315,14 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
@Override @Override
public ClientAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { public ClientAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
Long id = JdbcSupport.getLong(rs, "id"); final Long id = JdbcSupport.getLong(rs, "id");
String externalId = rs.getString("externalId"); final String externalId = rs.getString("externalId");
Long productId = JdbcSupport.getLong(rs, "productId"); final Long productId = JdbcSupport.getLong(rs, "productId");
String loanProductName = rs.getString("productName"); final String loanProductName = rs.getString("productName");
Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId"); final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
final EnumOptionData loanStatus = LoanEnumerations.status(loanStatusId);
return new ClientAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId); return new ClientAccountSummaryData(id, externalId, productId, loanProductName, loanStatus);
} }
} }