return status with deposit account data.

This commit is contained in:
Keith Woodlock
2012-08-30 08:43:50 +01:00
parent 9da34579a0
commit b100fd16a1
6 changed files with 78 additions and 68 deletions
@@ -60,6 +60,15 @@ public class DepositAccountsApiResource {
@Autowired
private ApiJsonSerializerService apiJsonSerializerService;
private static final Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("id", "externalId", "clientId", "clientName",
"productId", "productName", "status", "currency",
"deposit", "maturityInterestRate", "tenureInMonths",
"interestCompoundedEvery",
"interestCompoundedEveryPeriodType", "renewalAllowed",
"preClosureAllowed", "preClosureInterestRate"));
@POST
@Consumes({MediaType.APPLICATION_JSON})
@@ -91,14 +100,6 @@ public class DepositAccountsApiResource {
@Produces({MediaType.APPLICATION_JSON})
public String retrieveAllDepositAccounts(@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters);
@@ -116,14 +117,6 @@ public class DepositAccountsApiResource {
@Produces({MediaType.APPLICATION_JSON})
public String retrieveDepositAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters);
@@ -149,15 +142,6 @@ public class DepositAccountsApiResource {
@QueryParam("productId") final Long productId,
@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList(
"createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters);
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
/**
@@ -15,7 +14,7 @@ public class DepositAccountData {
private final Long id;
private final String externalId;
private final EnumOptionData status;
private final Long clientId;
private final String clientName;
private final Long productId;
@@ -41,9 +40,6 @@ public class DepositAccountData {
private final boolean preClosureAllowed;
private final BigDecimal preClosureInterestRate;
private final DateTime createdOn;
private final DateTime lastModifedOn;
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
private final List<DepositProductLookup> productOptions;
@@ -58,10 +54,9 @@ public class DepositAccountData {
private DepositAccountData(
final Long clientId,
final String clientName) {
this.createdOn=null;
this.lastModifedOn=null;
this.id=null;
this.externalId = null;
this.status = null;
this.clientId = clientId;
this.clientName = clientName;
this.productId = null;
@@ -92,10 +87,9 @@ public class DepositAccountData {
final DepositAccountData account,
final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions,
final Collection<DepositProductLookup> productOptions) {
this.createdOn = account.getCreatedOn();
this.lastModifedOn = account.getLastModifedOn();
this.id = account.getId();
this.externalId = account.getExternalId();
this.status = account.getStatus();
this.clientId = account.getClientId();
this.clientName = account.getClientName();
this.productId = account.getProductId();
@@ -123,10 +117,9 @@ public class DepositAccountData {
}
public DepositAccountData(
final DateTime createdOn,
final DateTime lastModifedOn,
final Long id,
final String externalId,
final EnumOptionData status,
final Long clientId,
final String clientName,
final Long productId,
@@ -147,10 +140,9 @@ public class DepositAccountData {
final boolean renewalAllowed,
final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) {
this.createdOn=createdOn;
this.lastModifedOn=lastModifedOn;
this.id=id;
this.externalId = externalId;
this.status = status;
this.clientId = clientId;
this.clientName = clientName;
this.productId = productId;
@@ -190,10 +182,9 @@ public class DepositAccountData {
final boolean renewalAllowed,
final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) {
this.createdOn=null;
this.lastModifedOn=null;
this.id=null;
this.externalId = null;
this.status = null;
this.clientId = clientId;
this.clientName = clientName;
this.productId = productId;
@@ -227,6 +218,10 @@ public class DepositAccountData {
public String getExternalId() {
return externalId;
}
public EnumOptionData getStatus() {
return status;
}
public Long getClientId() {
return clientId;
@@ -312,14 +307,6 @@ public class DepositAccountData {
return preClosureInterestRate;
}
public DateTime getCreatedOn() {
return createdOn;
}
public DateTime getLastModifedOn() {
return lastModifedOn;
}
public List<EnumOptionData> getInterestCompoundedEveryPeriodTypeOptions() {
return interestCompoundedEveryPeriodTypeOptions;
}
@@ -97,15 +97,14 @@ public class GoogleGsonApiJsonSerializerService implements
"preClosureAllowed", "preClosureInterestRate"));
private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("productOptions",
"interestCompoundedEveryPeriodTypeOptions", "createdOn",
"lastModifedOn", "id", "externalId", "clientId",
"clientName", "productId", "productName", "currency",
"deposit", "maturityInterestRate", "tenureInMonths",
"interestCompoundedEvery",
"interestCompoundedEveryPeriodType", "renewalAllowed",
"preClosureAllowed", "preClosureInterestRate"));
Arrays.asList("productOptions", "interestCompoundedEveryPeriodTypeOptions",
"id", "externalId", "clientId", "clientName", "productId", "productName", "status",
"currency", "deposit", "maturityInterestRate", "tenureInMonths",
"interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("id", "officeId", "officeName", "externalId",
"firstname", "lastname", "joinedDate", "displayName",
@@ -8,9 +8,9 @@ public enum DepositStatus {
ACTIVE(300, "depositStatusType.active"), //
WITHDRAWN_BY_CLIENT(400, "depositStatusType.withdrawn.by.client"), //
REJECTED(500, "depositStatusType.rejected"), //
MATURED(700,"depositStatusType.matured"),
CLOSED(600, "depositStatusType.closed");
CLOSED(600, "depositStatusType.closed"), //
MATURED(700,"depositStatusType.matured");
private final Integer value;
private final String code;
@@ -0,0 +1,42 @@
package org.mifosng.platform.saving.service;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.saving.domain.DepositStatus;
public class DepositAccountEnumerations {
public static EnumOptionData status(final Integer statusId) {
return status(DepositStatus.fromInt(statusId));
}
public static EnumOptionData status(final DepositStatus status) {
EnumOptionData optionData = null;
switch (status) {
case SUBMITED_AND_PENDING_APPROVAL:
optionData = new EnumOptionData(DepositStatus.SUBMITED_AND_PENDING_APPROVAL.getValue().longValue(), DepositStatus.SUBMITED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval");
break;
case APPROVED:
optionData = new EnumOptionData(DepositStatus.APPROVED.getValue().longValue(), DepositStatus.APPROVED.getCode(), "Approved");
break;
case ACTIVE:
optionData = new EnumOptionData(DepositStatus.ACTIVE.getValue().longValue(), DepositStatus.ACTIVE.getCode(), "Active");
break;
case REJECTED:
optionData = new EnumOptionData(DepositStatus.REJECTED.getValue().longValue(), DepositStatus.REJECTED.getCode(), "Rejected");
break;
case WITHDRAWN_BY_CLIENT:
optionData = new EnumOptionData(DepositStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(), DepositStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant");
break;
case MATURED:
optionData = new EnumOptionData(DepositStatus.MATURED.getValue().longValue(), DepositStatus.MATURED.getCode(), "Matured");
break;
case CLOSED:
optionData = new EnumOptionData(DepositStatus.CLOSED.getValue().longValue(), DepositStatus.CLOSED.getCode(), "Closed");
break;
default:
optionData = new EnumOptionData(DepositStatus.INVALID.getValue().longValue(), DepositStatus.INVALID.getCode(), "Invalid");
break;
}
return optionData;
}
}
@@ -5,7 +5,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.mifosng.platform.api.data.ClientData;
import org.mifosng.platform.api.data.CurrencyData;
@@ -88,7 +87,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
CurrencyData currency = new CurrencyData(selectedProduct.getCurrencyCode(), "", selectedProduct.getDigitsAfterDecimal(), "", "");
accountData = new DepositAccountData(
clientAccount.getId(), clientAccount.getDisplayName(), selectedProduct.getId(), selectedProduct.getName(),
clientAccount.getId(), clientAccount.getDisplayName(), selectedProduct.getId(), selectedProduct.getName(),
currency, selectedProduct.getMinimumBalance(), selectedProduct.getMaturityDefaultInterestRate(),
selectedProduct.getTenureInMonths(), selectedProduct.getInterestCompoundedEvery(), selectedProduct.getInterestCompoundedEveryPeriodType(),
selectedProduct.isRenewalAllowed(), selectedProduct.isPreClosureAllowed(),
@@ -118,14 +117,13 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
public String schema() {
return "da.id as id, da.external_id as externalId, da.client_id as clientId, da.product_id as productId,"
+ " da.currency_code as currencyCode, da.currency_digits as currencyDigits, "
+ " da.deposit_amount as depositAmount, "
+ " da.deposit_amount as depositAmount, da.status_enum as statusId, "
+ " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate,"
+ " da.actual_commencement_date as actualCommencementDate, da.projected_maturity_date as projectedMaturityDate, da.actual_maturity_date as actualMaturityDate,"
+ " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, "
+ " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, "
+ " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, "
+ " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, "
+ " da.created_date as createdon, da.lastmodified_date as modifiedon, "
+ " c.firstname as firstname, c.lastname as lastname, pd.name as productName,"
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol"
+ " from m_deposit_account da "
@@ -145,6 +143,9 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
Long productId = rs.getLong("productId");
String productName = rs.getString("productName");
Integer statusId = JdbcSupport.getInteger(rs, "statusId");
EnumOptionData status = DepositAccountEnumerations.status(statusId);
String currencyCode = rs.getString("currencyCode");
String currencyName = rs.getString("currencyName");
String currencyNameCode = rs.getString("currencyNameCode");
@@ -176,10 +177,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
BigDecimal preClosureInterestRate = rs.getBigDecimal("preClosureInterestRate");
DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
return new DepositAccountData(createdOn, lastModifedOn, id, externalId, clientId, clientName, productId, productName, currencyData, depositAmount,
return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData, depositAmount,
interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, projectedMaturityDate, actualMaturityDate,
projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount,
interestCompoundedEvery, interestCompoundedEveryPeriodType,