fix up deposit account fields to be consistent with product.

This commit is contained in:
Keith Woodlock
2012-08-15 02:41:12 +01:00
parent f30e8645a3
commit 9420d4fd14
5 changed files with 69 additions and 18 deletions
@@ -81,8 +81,10 @@ public class DepositAccountsApiResource {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate")
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
@@ -13,7 +13,7 @@ import org.joda.time.LocalDate;
public class DepositAccountData {
private final Long id;
private final String externalId;
private final Long clientId;
private final String clientName;
@@ -33,6 +33,9 @@ public class DepositAccountData {
private final BigDecimal actualInterestAccrued;
private final BigDecimal projectedMaturityAmount;
private final BigDecimal actualMaturityAmount;
private final Integer interestCompoundedEvery;
private final EnumOptionData interestCompoundedEveryPeriodType;
private final boolean renewalAllowed;
private final boolean preClosureAllowed;
private final BigDecimal preClosureInterestRate;
@@ -41,11 +44,13 @@ public class DepositAccountData {
private final DateTime lastModifedOn;
private final List<CurrencyData> currencyOptions;
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
public DepositAccountData() {
this.createdOn = null;
this.lastModifedOn = null;
this.id = null;
this.externalId = null;
this.clientId = null;
this.clientName = null;
this.productId = null;
@@ -62,17 +67,21 @@ public class DepositAccountData {
this.actualInterestAccrued = null;
this.projectedMaturityAmount = null;
this.actualMaturityAmount = null;
this.interestCompoundedEvery = null;
this.interestCompoundedEveryPeriodType = null;
this.renewalAllowed = false;
this.preClosureAllowed = false;
this.preClosureInterestRate = null;
this.currencyOptions = new ArrayList<CurrencyData>();
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
}
public DepositAccountData(final DepositAccountData account, final List<CurrencyData> currencies) {
this.createdOn = account.getCreatedOn();
this.lastModifedOn = account.getLastModifedOn();
this.id = account.getId();
this.externalId = account.getExternalId();
this.clientId = account.getClientId();
this.clientName = account.getClientName();
this.productId = account.getProductId();
@@ -89,17 +98,21 @@ public class DepositAccountData {
this.actualInterestAccrued = account.getActualInterestAccrued();
this.projectedMaturityAmount = account.getProjectedMaturityAmount();
this.actualMaturityAmount = account.getActualMaturityAmount();
this.interestCompoundedEvery = account.getInterestCompoundedEvery();
this.interestCompoundedEveryPeriodType = account.getInterestCompoundedEveryPeriodType();
this.renewalAllowed = account.isRenewalAllowed();
this.preClosureAllowed = account.isPreClosureAllowed();
this.preClosureInterestRate = account.getPreClosureInterestRate();
this.currencyOptions = currencies;
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
}
public DepositAccountData(
final DateTime createdOn,
final DateTime lastModifedOn,
final Long id,
final String externalId,
final Long clientId,
final String clientName,
final Long productId,
@@ -114,13 +127,16 @@ public class DepositAccountData {
final BigDecimal projectedInterestAccrued,
final BigDecimal actualInterestAccrued,
final BigDecimal projectedMaturityAmount,
final BigDecimal actualMaturityAmount,
final BigDecimal actualMaturityAmount,
final Integer interestCompoundedEvery,
final EnumOptionData interestCompoundedEveryPeriodType,
final boolean renewalAllowed,
final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) {
this.createdOn=createdOn;
this.lastModifedOn=lastModifedOn;
this.id=id;
this.externalId = externalId;
this.clientId = clientId;
this.clientName = clientName;
this.productId = productId;
@@ -137,17 +153,24 @@ public class DepositAccountData {
this.actualInterestAccrued = actualInterestAccrued;
this.projectedMaturityAmount = projectedMaturityAmount;
this.actualMaturityAmount = actualMaturityAmount;
this.interestCompoundedEvery = interestCompoundedEvery;
this.interestCompoundedEveryPeriodType = interestCompoundedEveryPeriodType;
this.renewalAllowed = renewalAllowed;
this.preClosureAllowed = preClosureAllowed;
this.preClosureInterestRate = preClosureInterestRate;
this.currencyOptions = new ArrayList<CurrencyData>();
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
}
public Long getId() {
return id;
}
public String getExternalId() {
return externalId;
}
public Long getClientId() {
return clientId;
}
@@ -211,6 +234,14 @@ public class DepositAccountData {
public BigDecimal getActualMaturityAmount() {
return actualMaturityAmount;
}
public Integer getInterestCompoundedEvery() {
return interestCompoundedEvery;
}
public EnumOptionData getInterestCompoundedEveryPeriodType() {
return interestCompoundedEveryPeriodType;
}
public boolean isRenewalAllowed() {
return renewalAllowed;
@@ -235,4 +266,8 @@ public class DepositAccountData {
public List<CurrencyData> getCurrencyOptions() {
return currencyOptions;
}
public List<EnumOptionData> getInterestCompoundedEveryPeriodTypeOptions() {
return interestCompoundedEveryPeriodTypeOptions;
}
}
@@ -1658,13 +1658,17 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
final boolean prettyPrint,
final Set<String> responseParameters,
final DepositAccountData... accounts) {
Set<String> supportedParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "currencyOptions")
);
Set<String> supportedParameters = new HashSet<String>(
Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions",
"createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths",
"interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
final Set<String> parameterNamesToSkip = new HashSet<String>();
if (!responseParameters.isEmpty()) {
@@ -57,12 +57,12 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
private Integer tenureInMonths;
@SuppressWarnings("unused")
@Column(name = "interest_compounding_frequency", nullable = false)
@Column(name = "interest_compounded_every", nullable = false)
private Integer interestCompoundedEvery;
@SuppressWarnings("unused")
@Enumerated(EnumType.ORDINAL)
@Column(name = "interest_compounding_frequency_enum", nullable = false)
@Column(name = "interest_compounded_every_period_enum", nullable = false)
private PeriodFrequencyType interestCompoundedFrequencyType;
@SuppressWarnings("unused")
@@ -106,11 +106,11 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
private BigDecimal preClosureInterestRate;
@SuppressWarnings("unused")
@Column(name = "can_renew", nullable = false)
@Column(name = "is_renewal_allowed", nullable = false)
private boolean renewalAllowed = false;
@SuppressWarnings("unused")
@Column(name = "can_pre_close", nullable = false)
@Column(name = "is_preclosure_allowed", nullable = false)
private boolean preClosureAllowed = false;
@Column(name = "is_deleted", nullable=false)
@@ -9,6 +9,8 @@ import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.mifosng.platform.api.data.CurrencyData;
import org.mifosng.platform.api.data.DepositAccountData;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.deposit.domain.SavingsDepositEnumerations;
import org.mifosng.platform.exceptions.LoanProductNotFoundException;
import org.mifosng.platform.infrastructure.JdbcSupport;
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
@@ -71,14 +73,15 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
private static final class DepositAccountMapper implements RowMapper<DepositAccountData> {
public String schema() {
return "da.id as id, da.client_id as clientId, da.product_id as productId,"
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.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.can_renew as renewalAllowed, da.can_pre_close as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, "
+ " 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"
@@ -93,6 +96,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
throws SQLException {
Long id = rs.getLong("id");
String externalId = rs.getString("externalId");
Long clientId = rs.getLong("clientId");
String clientName = rs.getString("firstname") + " " + rs.getString("lastname");
Long productId = rs.getLong("productId");
@@ -120,6 +124,10 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
BigDecimal projectedMaturityAmount = rs.getBigDecimal("projectedMaturityAmount");
BigDecimal actualMaturityAmount = rs.getBigDecimal("actualMaturityAmount");
Integer interestCompoundedEvery = JdbcSupport.getInteger(rs, "interestCompoundedEvery");
Integer interestCompoundedEveryPeriodTypeValue = JdbcSupport.getInteger(rs, "interestCompoundedEveryPeriodType");
EnumOptionData interestCompoundedEveryPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(interestCompoundedEveryPeriodTypeValue);
boolean renewalAllowed = rs.getBoolean("renewalAllowed");
boolean preClosureAllowed = rs.getBoolean("preClosureAllowed");
@@ -128,9 +136,11 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
return new DepositAccountData(createdOn, lastModifedOn, id, clientId, clientName, productId, productName, currencyData, depositAmount,
return new DepositAccountData(createdOn, lastModifedOn, id, externalId, clientId, clientName, productId, productName, currencyData, depositAmount,
interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, projectedMaturityDate, actualMaturityDate,
projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount, renewalAllowed, preClosureAllowed, preClosureInterestRate);
projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount,
interestCompoundedEvery, interestCompoundedEveryPeriodType,
renewalAllowed, preClosureAllowed, preClosureInterestRate);
}
}
}