make parameter names consistent between product and account for deposits.

This commit is contained in:
Keith Woodlock
2012-08-14 15:14:56 +01:00
parent 2a1bb14c9f
commit c2e563bf6f
13 changed files with 324 additions and 200 deletions
@@ -86,6 +86,16 @@ public class DataValidatorBuilder {
return this; return this;
} }
public DataValidatorBuilder trueOrFalseRequired(boolean trueOfFalseFieldProvided) {
if (!trueOfFalseFieldProvided && !ignoreNullValue) {
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".must.be.true.or.false");
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be set as true or false.");
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter);
dataValidationErrors.add(error);
}
return this;
}
public DataValidatorBuilder notNull() { public DataValidatorBuilder notNull() {
if (value == null && !ignoreNullValue) { if (value == null && !ignoreNullValue) {
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank"); StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank");
@@ -275,5 +285,4 @@ public class DataValidatorBuilder {
} }
return this; return this;
} }
} }
@@ -81,10 +81,12 @@ public class DepositProductsApiResource {
@GET @GET
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public String retrieveAllDepositProducts(@Context final UriInfo uriInfo){ public String retrieveAllDepositProducts(@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", Set<String> typicalResponseParameters = new HashSet<String>(
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate",
"maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
@@ -100,10 +102,12 @@ public class DepositProductsApiResource {
@Path("{productId}") @Path("{productId}")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo){ public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", Set<String> typicalResponseParameters = new HashSet<String>(
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate",
"maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
@@ -125,8 +129,9 @@ public class DepositProductsApiResource {
public String retrieveNewDepositProductDetails(@Context final UriInfo uriInfo) { public String retrieveNewDepositProductDetails(@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>( Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", Arrays.asList("currencyOptions", "id", "name", "description", "createdOn", "lastModifedOn",
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate",
"maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
@@ -23,6 +23,9 @@ public class DepositAccountCommand {
private final Integer interestCompoundedEveryPeriodType; private final Integer interestCompoundedEveryPeriodType;
private final LocalDate commencementDate; private final LocalDate commencementDate;
private final boolean renewalAllowed;
private final boolean preClosureAllowed;
private final Set<String> modifiedParameters; private final Set<String> modifiedParameters;
public DepositAccountCommand(final Set<String> modifiedParameters, public DepositAccountCommand(final Set<String> modifiedParameters,
@@ -32,7 +35,8 @@ public class DepositAccountCommand {
final String externalId, final String externalId,
final BigDecimal depositAmount, final BigDecimal depositAmount,
final BigDecimal interestRate, final BigDecimal interestRate,
final Integer termInMonths, final Integer compoundingInterestFrequency, final Integer compoundingInterestFrequencyType, final LocalDate commencementDate) { final Integer termInMonths, final Integer compoundingInterestFrequency, final Integer compoundingInterestFrequencyType, final LocalDate commencementDate,
final boolean renewalAllowed, final boolean preClosureAllowed) {
this.id = id; this.id = id;
this.clientId = clientId; this.clientId = clientId;
this.productId = productId; this.productId = productId;
@@ -46,6 +50,8 @@ public class DepositAccountCommand {
this.interestCompoundedEvery = compoundingInterestFrequency; this.interestCompoundedEvery = compoundingInterestFrequency;
this.interestCompoundedEveryPeriodType = compoundingInterestFrequencyType; this.interestCompoundedEveryPeriodType = compoundingInterestFrequencyType;
this.commencementDate = commencementDate; this.commencementDate = commencementDate;
this.renewalAllowed = renewalAllowed;
this.preClosureAllowed = preClosureAllowed;
} }
public Long getId() { public Long getId() {
@@ -88,6 +94,14 @@ public class DepositAccountCommand {
return commencementDate; return commencementDate;
} }
public boolean isRenewalAllowed() {
return renewalAllowed;
}
public boolean isPreClosureAllowed() {
return preClosureAllowed;
}
public boolean isNoFieldChanged() { public boolean isNoFieldChanged() {
return this.modifiedParameters.isEmpty(); return this.modifiedParameters.isEmpty();
} }
@@ -103,4 +117,12 @@ public class DepositAccountCommand {
public boolean isMaturityActualInterestRateChanged() { public boolean isMaturityActualInterestRateChanged() {
return this.modifiedParameters.contains("interestRate"); return this.modifiedParameters.contains("interestRate");
} }
public boolean isRenewalAllowedChanged() {
return this.modifiedParameters.contains("renewalAllowed");
}
public boolean isPreClosureAllowedChanged() {
return this.modifiedParameters.contains("preClosureAllowed");
}
} }
@@ -15,7 +15,7 @@ public class DepositProductCommand {
private final BigDecimal minimumBalance; private final BigDecimal minimumBalance;
private final BigDecimal maximumBalance; private final BigDecimal maximumBalance;
private final Integer tenureMonths; private final Integer tenureInMonths;
private final BigDecimal maturityDefaultInterestRate; private final BigDecimal maturityDefaultInterestRate;
private final BigDecimal maturityMinInterestRate; private final BigDecimal maturityMinInterestRate;
private final BigDecimal maturityMaxInterestRate; private final BigDecimal maturityMaxInterestRate;
@@ -29,9 +29,9 @@ public class DepositProductCommand {
final Long id, final String name, final String description, final Long id, final String name, final String description,
final String currencyCode, final Integer digitsAfterDecimal, final String currencyCode, final Integer digitsAfterDecimal,
final BigDecimal minimumBalance, final BigDecimal maximumBalance, final BigDecimal minimumBalance, final BigDecimal maximumBalance,
final Integer tenureMonths, final BigDecimal maturityDefaultInterestRate, final Integer tenureInMonths, final BigDecimal maturityDefaultInterestRate,
final BigDecimal maturityMinInterestRate, final BigDecimal maturityMaxInterestRate, final BigDecimal maturityMinInterestRate, final BigDecimal maturityMaxInterestRate,
final boolean canRenew, final boolean canPreClose, final BigDecimal preClosureInterestRate ) { final boolean renewalAllowed, final boolean preClosureAllowed, final BigDecimal preClosureInterestRate ) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.description = description; this.description = description;
@@ -42,14 +42,14 @@ public class DepositProductCommand {
this.minimumBalance=minimumBalance; this.minimumBalance=minimumBalance;
this.maximumBalance=maximumBalance; this.maximumBalance=maximumBalance;
this.tenureMonths=tenureMonths; this.tenureInMonths=tenureInMonths;
this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityDefaultInterestRate = maturityDefaultInterestRate;
this.maturityMinInterestRate = maturityMinInterestRate; this.maturityMinInterestRate = maturityMinInterestRate;
this.maturityMaxInterestRate = maturityMaxInterestRate; this.maturityMaxInterestRate = maturityMaxInterestRate;
this.preClosureInterestRate = preClosureInterestRate; this.preClosureInterestRate = preClosureInterestRate;
this.renewalAllowed = canRenew; this.renewalAllowed = renewalAllowed;
this.preClosureAllowed = canPreClose; this.preClosureAllowed = preClosureAllowed;
this.modifiedParameters = modifiedParameters; this.modifiedParameters = modifiedParameters;
@@ -83,8 +83,8 @@ public class DepositProductCommand {
return maximumBalance; return maximumBalance;
} }
public Integer getTenureMonths() { public Integer getTenureInMonths() {
return tenureMonths; return tenureInMonths;
} }
public BigDecimal getMaturityDefaultInterestRate() { public BigDecimal getMaturityDefaultInterestRate() {
@@ -155,12 +155,12 @@ public class DepositProductCommand {
return this.modifiedParameters.contains("maturityMaxInterestRate"); return this.modifiedParameters.contains("maturityMaxInterestRate");
} }
public boolean isCanRenewChanged() { public boolean isRenewalAllowedChanged() {
return this.modifiedParameters.contains("canRenew"); return this.modifiedParameters.contains("renewalAllowed");
} }
public boolean isCanPreCloseChanged() { public boolean isPreClosureAllowedChanged() {
return this.modifiedParameters.contains("canPreClose"); return this.modifiedParameters.contains("preClosureAllowed");
} }
public boolean isPreClosureInterestRateChanged() { public boolean isPreClosureInterestRateChanged() {
@@ -24,7 +24,7 @@ public class DepositAccountData {
private final BigDecimal deposit; private final BigDecimal deposit;
private final BigDecimal maturityInterestRate; private final BigDecimal maturityInterestRate;
private final Integer termInMonths; private final Integer tenureInMonths;
private final LocalDate projectedCommencementDate; private final LocalDate projectedCommencementDate;
private final LocalDate actualCommencementDate; private final LocalDate actualCommencementDate;
private final LocalDate projectedMaturityDate; private final LocalDate projectedMaturityDate;
@@ -53,7 +53,7 @@ public class DepositAccountData {
this.currency = null; this.currency = null;
this.deposit = null; this.deposit = null;
this.maturityInterestRate = null; this.maturityInterestRate = null;
this.termInMonths = null; this.tenureInMonths = null;
this.projectedCommencementDate = null; this.projectedCommencementDate = null;
this.actualCommencementDate = null; this.actualCommencementDate = null;
this.projectedMaturityDate = null; this.projectedMaturityDate = null;
@@ -80,7 +80,7 @@ public class DepositAccountData {
this.currency = account.getCurrency(); this.currency = account.getCurrency();
this.deposit = account.getDeposit(); this.deposit = account.getDeposit();
this.maturityInterestRate = account.getMaturityInterestRate(); this.maturityInterestRate = account.getMaturityInterestRate();
this.termInMonths = account.getTermInMonths(); this.tenureInMonths = account.getTenureInMonths();
this.projectedCommencementDate = account.getProjectedCommencementDate(); this.projectedCommencementDate = account.getProjectedCommencementDate();
this.actualCommencementDate = account.getActualCommencementDate(); this.actualCommencementDate = account.getActualCommencementDate();
this.projectedMaturityDate = account.getProjectedMaturityDate(); this.projectedMaturityDate = account.getProjectedMaturityDate();
@@ -106,7 +106,7 @@ public class DepositAccountData {
final String productName, final String productName,
final CurrencyData currency, final CurrencyData currency,
final BigDecimal deposit, final BigDecimal interestRate, final BigDecimal deposit, final BigDecimal interestRate,
final Integer termInMonths, final Integer tenureInMonths,
final LocalDate projectedCommencementDate, final LocalDate projectedCommencementDate,
final LocalDate actualCommencementDate, final LocalDate actualCommencementDate,
final LocalDate projectedMaturityDate, final LocalDate projectedMaturityDate,
@@ -128,7 +128,7 @@ public class DepositAccountData {
this.currency = currency; this.currency = currency;
this.deposit = deposit; this.deposit = deposit;
this.maturityInterestRate=interestRate; this.maturityInterestRate=interestRate;
this.termInMonths = termInMonths; this.tenureInMonths = tenureInMonths;
this.projectedCommencementDate = projectedCommencementDate; this.projectedCommencementDate = projectedCommencementDate;
this.actualCommencementDate = actualCommencementDate; this.actualCommencementDate = actualCommencementDate;
this.projectedMaturityDate = projectedMaturityDate; this.projectedMaturityDate = projectedMaturityDate;
@@ -175,11 +175,11 @@ public class DepositAccountData {
public BigDecimal getMaturityInterestRate() { public BigDecimal getMaturityInterestRate() {
return maturityInterestRate; return maturityInterestRate;
} }
public Integer getTermInMonths() { public Integer getTenureInMonths() {
return termInMonths; return tenureInMonths;
} }
public LocalDate getProjectedCommencementDate() { public LocalDate getProjectedCommencementDate() {
return projectedCommencementDate; return projectedCommencementDate;
} }
@@ -1,40 +1,53 @@
package org.mifosng.platform.api.data; package org.mifosng.platform.api.data;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.joda.time.DateTime; import org.joda.time.DateTime;
public class DepositProductData implements Serializable { /**
* Immutable data object representing details of a deposit product.
*/
public class DepositProductData {
private Long id; private final Long id;
private String name; private final String name;
private String description; private final String description;
private String currencyCode; private final String currencyCode;
private Integer digitsAfterDecimal; private final Integer digitsAfterDecimal;
private BigDecimal minimumBalance = BigDecimal.ZERO; private final BigDecimal minimumBalance;
private BigDecimal maximumBalance = BigDecimal.ZERO; private final BigDecimal maximumBalance;
private Integer tenureMonths; private final Integer tenureInMonths;
private BigDecimal maturityDefaultInterestRate = BigDecimal.ZERO; private final BigDecimal maturityDefaultInterestRate;
private BigDecimal maturityMinInterestRate = BigDecimal.ZERO; private final BigDecimal maturityMinInterestRate;
private BigDecimal maturityMaxInterestRate = BigDecimal.ZERO; private final BigDecimal maturityMaxInterestRate;
private Boolean canRenew; private final boolean renewalAllowed;
private Boolean canPreClose; private final boolean preClosureAllowed;
private BigDecimal preClosureInterestRate = BigDecimal.ZERO; private final BigDecimal preClosureInterestRate;
private DateTime createdOn;
private DateTime lastModifedOn;
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>(); private final DateTime createdOn;
private final DateTime lastModifedOn;
public DepositProductData() { private final List<CurrencyData> currencyOptions;
//
}
public DepositProductData(DateTime createdOn, DateTime lastModifedOn, Long id,String name, String description, String currencyCode, Integer digitsAfterDecimal,BigDecimal minimumBalance,BigDecimal maximumBalance, public DepositProductData(
Integer tenureMonths, BigDecimal maturityDefaultInterestRate, BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate, final DateTime createdOn,
Boolean canRenew, Boolean canPreClose, BigDecimal preClosureInterestRate) { final DateTime lastModifedOn,
final Long id,
final String name,
final String description,
final String currencyCode,
final Integer digitsAfterDecimal,
final BigDecimal minimumBalance,
final BigDecimal maximumBalance,
final Integer tenureMonths,
final BigDecimal maturityDefaultInterestRate,
final BigDecimal maturityMinInterestRate,
final BigDecimal maturityMaxInterestRate,
final boolean renewalAllowed,
final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) {
this.createdOn=createdOn; this.createdOn=createdOn;
this.lastModifedOn=lastModifedOn; this.lastModifedOn=lastModifedOn;
@@ -46,151 +59,126 @@ public class DepositProductData implements Serializable {
this.minimumBalance=minimumBalance; this.minimumBalance=minimumBalance;
this.maximumBalance=maximumBalance; this.maximumBalance=maximumBalance;
this.tenureMonths=tenureMonths; this.tenureInMonths=tenureMonths;
this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityDefaultInterestRate = maturityDefaultInterestRate;
this.maturityMinInterestRate=maturityMinInterestRate; this.maturityMinInterestRate=maturityMinInterestRate;
this.maturityMaxInterestRate=maturityMaxInterestRate; this.maturityMaxInterestRate=maturityMaxInterestRate;
this.canRenew=canRenew; this.renewalAllowed=renewalAllowed;
this.canPreClose=canPreClose; this.preClosureAllowed=preClosureAllowed;
this.preClosureInterestRate=preClosureInterestRate; this.preClosureInterestRate=preClosureInterestRate;
this.currencyOptions = new ArrayList<CurrencyData>();
} }
public DepositProductData(final List<CurrencyData> currencyOptions) {
this.createdOn=null;
this.lastModifedOn=null;
this.id=null;
this.name=null;
this.description=null;
this.currencyCode=null;
this.digitsAfterDecimal=Integer.valueOf(0);
this.minimumBalance=BigDecimal.ZERO;
this.maximumBalance=null;
this.tenureInMonths=Integer.valueOf(0);
this.maturityDefaultInterestRate = null;
this.maturityMinInterestRate=BigDecimal.ZERO;
this.maturityMaxInterestRate=BigDecimal.ZERO;
this.renewalAllowed=true;
this.preClosureAllowed=true;
this.preClosureInterestRate=BigDecimal.ZERO;
this.currencyOptions = currencyOptions;
}
public DepositProductData(final DepositProductData product, final List<CurrencyData> currencyOptions) {
this.createdOn=product.getCreatedOn();
this.lastModifedOn=product.getLastModifedOn();
this.id=product.getId();
this.name=product.getName();
this.description=product.getDescription();
this.currencyCode=product.getCurrencyCode();
this.digitsAfterDecimal=product.getDigitsAfterDecimal();
this.minimumBalance=product.getMinimumBalance();
this.maximumBalance=product.getMaximumBalance();
this.tenureInMonths=product.getTenureInMonths();
this.maturityDefaultInterestRate = product.getMaturityDefaultInterestRate();
this.maturityMinInterestRate=product.getMaturityMinInterestRate();
this.maturityMaxInterestRate=product.getMaturityMaxInterestRate();
this.renewalAllowed=product.isRenewalAllowed();
this.preClosureAllowed=product.isPreClosureAllowed();
this.preClosureInterestRate=product.getPreClosureInterestRate();
this.currencyOptions = currencyOptions;
}
public Long getId() { public Long getId() {
return id; return id;
} }
public void setId(Long id) {
this.id = id;
}
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) {
this.description = description;
}
public String getCurrencyCode() { public String getCurrencyCode() {
return currencyCode; return currencyCode;
} }
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
public Integer getDigitsAfterDecimal() { public Integer getDigitsAfterDecimal() {
return digitsAfterDecimal; return digitsAfterDecimal;
} }
public void setDigitsAfterDecimal(Integer digitsAfterDecimal) {
this.digitsAfterDecimal = digitsAfterDecimal;
}
public BigDecimal getMinimumBalance() { public BigDecimal getMinimumBalance() {
return minimumBalance; return minimumBalance;
} }
public void setMinimumBalance(BigDecimal minimumBalance) {
this.minimumBalance = minimumBalance;
}
public BigDecimal getMaximumBalance() { public BigDecimal getMaximumBalance() {
return maximumBalance; return maximumBalance;
} }
public void setMaximumBalance(BigDecimal maximumBalance) { public Integer getTenureInMonths() {
this.maximumBalance = maximumBalance; return tenureInMonths;
}
public DateTime getCreatedOn() {
return createdOn;
}
public void setCreatedOn(DateTime createdOn) {
this.createdOn = createdOn;
}
public DateTime getLastModifedOn() {
return lastModifedOn;
}
public void setLastModifedOn(DateTime lastModifedOn) {
this.lastModifedOn = lastModifedOn;
}
public List<CurrencyData> getCurrencyOptions() {
return currencyOptions;
}
public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
this.currencyOptions = currencyOptions;
}
public Integer getTenureMonths() {
return tenureMonths;
}
public void setTenureMonths(Integer tenureMonths) {
this.tenureMonths = tenureMonths;
} }
public BigDecimal getMaturityDefaultInterestRate() { public BigDecimal getMaturityDefaultInterestRate() {
return maturityDefaultInterestRate; return maturityDefaultInterestRate;
} }
public void setMaturityDefaultInterestRate(
BigDecimal maturityDefaultInterestRate) {
this.maturityDefaultInterestRate = maturityDefaultInterestRate;
}
public BigDecimal getMaturityMinInterestRate() { public BigDecimal getMaturityMinInterestRate() {
return maturityMinInterestRate; return maturityMinInterestRate;
} }
public void setMaturityMinInterestRate(BigDecimal maturityMinInterestRate) {
this.maturityMinInterestRate = maturityMinInterestRate;
}
public BigDecimal getMaturityMaxInterestRate() { public BigDecimal getMaturityMaxInterestRate() {
return maturityMaxInterestRate; return maturityMaxInterestRate;
} }
public void setMaturityMaxInterestRate(BigDecimal maturityMaxInterestRate) { public boolean isRenewalAllowed() {
this.maturityMaxInterestRate = maturityMaxInterestRate; return renewalAllowed;
} }
public Boolean getCanRenew() { public boolean isPreClosureAllowed() {
return canRenew; return preClosureAllowed;
}
public void setCanRenew(Boolean canRenew) {
this.canRenew = canRenew;
}
public Boolean getCanPreClose() {
return canPreClose;
}
public void setCanPreClose(Boolean canPreClose) {
this.canPreClose = canPreClose;
} }
public BigDecimal getPreClosureInterestRate() { public BigDecimal getPreClosureInterestRate() {
return preClosureInterestRate; return preClosureInterestRate;
} }
public void setPreClosureInterestRate(BigDecimal preClosureInterestRate) { public DateTime getCreatedOn() {
this.preClosureInterestRate = preClosureInterestRate; return createdOn;
} }
}
public DateTime getLastModifedOn() {
return lastModifedOn;
}
public List<CurrencyData> getCurrencyOptions() {
return currencyOptions;
}
}
@@ -1492,9 +1492,11 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType(); Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap); Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
// preClosureInterestRate
Set<String> supportedParams = new HashSet<String>( Set<String> supportedParams = new HashSet<String>(
Arrays.asList("clientId", "productId", "externalId", "depositAmount", "maturityInterestRate", Arrays.asList("clientId", "productId", "externalId", "depositAmount", "maturityInterestRate",
"termInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate",
"renewalAllowed", "preClosureAllowed",
"locale", "dateFormat") "locale", "dateFormat")
); );
checkForUnsupportedParameters(requestMap, supportedParams); checkForUnsupportedParameters(requestMap, supportedParams);
@@ -1505,17 +1507,18 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
String externalId = extractStringParameter("externalId", requestMap,modifiedParameters); String externalId = extractStringParameter("externalId", requestMap,modifiedParameters);
BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters); BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters);
BigDecimal interestRate = extractBigDecimalParameter("maturityInterestRate", requestMap, modifiedParameters); BigDecimal interestRate = extractBigDecimalParameter("maturityInterestRate", requestMap, modifiedParameters);
Integer termInMonths = extractIntegerParameter("termInMonths", requestMap, modifiedParameters); Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters); Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters);
Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters); Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters);
LocalDate commencementDate = extractLocalDateParameter("commencementDate", requestMap, modifiedParameters); LocalDate commencementDate = extractLocalDateParameter("commencementDate", requestMap, modifiedParameters);
// TODO - isRenewable, isPreClosureAllowed boolean renewalAllowed = extractBooleanParameter("renewalAllowed", requestMap, modifiedParameters);
boolean preClosureAllowed = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters);
return new DepositAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId, return new DepositAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId,
externalId, depositAmount, interestRate, termInMonths, externalId, depositAmount, interestRate, termInMonths,
interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate); interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate, renewalAllowed, preClosureAllowed);
} }
@Override @Override
@@ -1569,8 +1572,8 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap); Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
Set<String> supportedParams = new HashSet<String>( Set<String> supportedParams = new HashSet<String>(
Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureMonths", Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureInMonths",
"maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate") "maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate")
); );
checkForUnsupportedParameters(requestMap, supportedParams); checkForUnsupportedParameters(requestMap, supportedParams);
Set<String> modifiedParameters = new HashSet<String>(); Set<String> modifiedParameters = new HashSet<String>();
@@ -1581,12 +1584,12 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
BigDecimal minimumBalance=extractBigDecimalParameter("minimumBalance", requestMap, modifiedParameters); BigDecimal minimumBalance=extractBigDecimalParameter("minimumBalance", requestMap, modifiedParameters);
BigDecimal maximumBalance=extractBigDecimalParameter("maximumBalance", requestMap, modifiedParameters); BigDecimal maximumBalance=extractBigDecimalParameter("maximumBalance", requestMap, modifiedParameters);
Integer tenureMonths = extractIntegerParameter("tenureMonths", requestMap, modifiedParameters); Integer tenureMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
BigDecimal maturityDefaultInterestRate = extractBigDecimalParameter("maturityDefaultInterestRate", requestMap, modifiedParameters); BigDecimal maturityDefaultInterestRate = extractBigDecimalParameter("maturityDefaultInterestRate", requestMap, modifiedParameters);
BigDecimal maturityMinInterestRate = extractBigDecimalParameter("maturityMinInterestRate", requestMap, modifiedParameters); BigDecimal maturityMinInterestRate = extractBigDecimalParameter("maturityMinInterestRate", requestMap, modifiedParameters);
BigDecimal maturityMaxInterestRate = extractBigDecimalParameter("maturityMaxInterestRate", requestMap, modifiedParameters); BigDecimal maturityMaxInterestRate = extractBigDecimalParameter("maturityMaxInterestRate", requestMap, modifiedParameters);
boolean canRenew = extractBooleanParameter("canRenew", requestMap, modifiedParameters); boolean canRenew = extractBooleanParameter("renewalAllowed", requestMap, modifiedParameters);
boolean canPreClose = extractBooleanParameter("canPreClose", requestMap, modifiedParameters); boolean canPreClose = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters);
BigDecimal preClosureInterestRate = extractBigDecimalParameter("preClosureInterestRate", requestMap, modifiedParameters); BigDecimal preClosureInterestRate = extractBigDecimalParameter("preClosureInterestRate", requestMap, modifiedParameters);
return new DepositProductCommand(modifiedParameters, resourceIdentifier, name, description, currencyCode, digitsAfterDecimalValue, minimumBalance,maximumBalance, return new DepositProductCommand(modifiedParameters, resourceIdentifier, name, description, currencyCode, digitsAfterDecimalValue, minimumBalance,maximumBalance,
@@ -1597,8 +1600,10 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
public String convertDepositProductDataToJson(boolean prettyPrint, public String convertDepositProductDataToJson(boolean prettyPrint,
Set<String> responseParameters, DepositProductData... products) { Set<String> responseParameters, DepositProductData... products) {
Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions", "minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", Set<String> supportedParameters = new HashSet<String>(
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal",
"currencyOptions", "minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate",
"maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate"));
final Set<String> parameterNamesToSkip = new HashSet<String>(); final Set<String> parameterNamesToSkip = new HashSet<String>();
@@ -10,6 +10,7 @@ import javax.persistence.Table;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.api.commands.DepositProductCommand;
import org.mifosng.platform.currency.domain.MonetaryCurrency; import org.mifosng.platform.currency.domain.MonetaryCurrency;
import org.mifosng.platform.exceptions.ValueOutsideRangeException;
import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
import org.mifosng.platform.user.domain.AppUser; import org.mifosng.platform.user.domain.AppUser;
@@ -17,9 +18,11 @@ import org.mifosng.platform.user.domain.AppUser;
@Table(name = "portfolio_product_deposit") @Table(name = "portfolio_product_deposit")
public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> { public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused")
@Column(name = "name", nullable = false) @Column(name = "name", nullable = false)
private String name; private String name;
@SuppressWarnings("unused")
@Column(name = "description") @Column(name = "description")
private String description; private String description;
@@ -35,9 +38,11 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "maximum_balance", scale = 6, precision = 19, nullable = false) @Column(name = "maximum_balance", scale = 6, precision = 19, nullable = false)
private BigDecimal maximumBalance; private BigDecimal maximumBalance;
@SuppressWarnings("unused")
@Column(name = "tenure_months", nullable=false) @Column(name = "tenure_months", nullable=false)
private Integer tenureMonths; private Integer tenureInMonths;
@SuppressWarnings("unused")
@Column(name = "maturity_default_interest_rate", scale = 6, precision = 19, nullable = false) @Column(name = "maturity_default_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal maturityDefaultInterestRate; private BigDecimal maturityDefaultInterestRate;
@@ -53,13 +58,13 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "can_pre_close", nullable=false) @Column(name = "can_pre_close", nullable=false)
private boolean preClosureAllowed = false; private boolean preClosureAllowed = false;
@SuppressWarnings("unused")
@Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false) @Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal preClosureInterestRate; private BigDecimal preClosureInterestRate;
protected DepositProduct(){ protected DepositProduct() {
this.name = null; //
this.description = null; }
}
public DepositProduct(final String name, final String description, public DepositProduct(final String name, final String description,
final MonetaryCurrency currency, final BigDecimal minimumBalance, final MonetaryCurrency currency, final BigDecimal minimumBalance,
@@ -78,7 +83,7 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
this.currency = currency; this.currency = currency;
this.minimumBalance = minimumBalance; this.minimumBalance = minimumBalance;
this.maximumBalance = maximumBalance; this.maximumBalance = maximumBalance;
this.tenureMonths = tenureMonths; this.tenureInMonths = tenureMonths;
this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityDefaultInterestRate = maturityDefaultInterestRate;
this.maturityMinInterestRate = maturityMinInterestRate; this.maturityMinInterestRate = maturityMinInterestRate;
this.maturityMaxInterestRate = maturityMaxInterestRate; this.maturityMaxInterestRate = maturityMaxInterestRate;
@@ -107,7 +112,7 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
this.deleted = true; this.deleted = true;
} }
public void update(DepositProductCommand command){ public void update(final DepositProductCommand command){
if (command.isNameChanged()) { if (command.isNameChanged()) {
this.name = command.getName(); this.name = command.getName();
@@ -116,13 +121,91 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
if (command.isDescriptionChanged()) { if (command.isDescriptionChanged()) {
this.description = command.getDescription(); this.description = command.getDescription();
} }
Integer digitsAfterDecimalChanged = this.currency.getDigitsAfterDecimal();
if (command.isDigitsAfterDecimalChanged()) {
digitsAfterDecimalChanged = command.getDigitsAfterDecimal();
}
String currencyCodeChanged = this.currency.getCode();
if (command.isCurrencyCodeChanged()) {
currencyCodeChanged = command.getCurrencyCode();
}
if (command.isDigitsAfterDecimalChanged() || command.isCurrencyCodeChanged()) {
this.currency = new MonetaryCurrency(currencyCodeChanged, digitsAfterDecimalChanged);
}
if(command.isMinimumBalanceChanged()){
this.minimumBalance=command.getMinimumBalance();
}
if(command.isMaximumBalanceChanged()){
this.maximumBalance=command.getMaximumBalance();
}
if(command.isTenureMonthsChanged()){
this.tenureInMonths=command.getTenureInMonths();
}
if (command.isMaturityDefaultInterestRateChanged()) {
this.maturityDefaultInterestRate=command.getMaturityDefaultInterestRate();
}
if(command.isMaturityMaxInterestRateChanged()){
this.maturityMaxInterestRate=command.getMaturityMaxInterestRate();
}
if (command.isMaturityMinInterestRateChanged()) {
this.maturityMinInterestRate=command.getMaturityMinInterestRate();
}
if (command.isRenewalAllowedChanged()) {
this.renewalAllowed=command.isRenewalAllowed();
}
if (command.isPreClosureAllowed()) {
this.preClosureAllowed=command.isPreClosureAllowed();
}
if (command.isPreClosureInterestRateChanged()) {
this.preClosureInterestRate=command.getPreClosureInterestRate();
}
} }
public void validateInterestRateInRange(final BigDecimal interestRate) { public void validateInterestRateInRange(final BigDecimal interestRate) {
// this.depositProductRelatedDetail.validateInterestRateInRange(interestRate); boolean inRange = true;
if (interestRate.compareTo(this.maturityMinInterestRate) < 0) {
inRange = false;
}
if (this.maturityMaxInterestRate.compareTo(interestRate) < 0) {
inRange = false;
}
if (!inRange) {
final String actualValue = interestRate.toPlainString();
final String minValue = (this.maturityMinInterestRate == null) ? "" : this.maturityMinInterestRate.toPlainString();
final String maxValue = (this.maturityMaxInterestRate == null) ? "" : this.maturityMaxInterestRate.toPlainString();
throw new ValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.maturityInterestRate");
}
} }
public void validateDepositInRange(final BigDecimal depositAmount) { public void validateDepositInRange(final BigDecimal depositAmount) {
// this.depositProductRelatedDetail.validateDepositInRange(depositAmount); boolean inRange = true;
if (depositAmount.compareTo(this.minimumBalance) < 0) {
inRange = false;
}
if (this.maximumBalance != null && this.maximumBalance.compareTo(depositAmount) < 0) {
inRange = false;
}
if (!inRange) {
final String actualValue = depositAmount.toPlainString();
final String minValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString();
final String maxValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString();
throw new ValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.deposit.amount");
}
} }
} }
@@ -27,19 +27,20 @@ public class DepositProductCommandValidator {
baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimal()).notNull().inMinMaxRange(0, 6); baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimal()).notNull().inMinMaxRange(0, 6);
baseDataValidator.reset().parameter("minimumBalance").value(command.getMinimumBalance()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("minimumBalance").value(command.getMinimumBalance()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maximumBalance").value(command.getMaximumBalance()).zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maximumBalance").value(command.getMaximumBalance()).zeroOrPositiveAmount();
baseDataValidator.reset().parameter("minimumBalance").comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
baseDataValidator.reset().parameter("tenureMonths").value(command.getTenureMonths()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("tenureInMonths").value(command.getTenureInMonths()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityDefaultInterestRate").value(command.getMaturityDefaultInterestRate()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityDefaultInterestRate").value(command.getMaturityDefaultInterestRate()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityMaxInterestRate").value(command.getMaturityMaxInterestRate()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityMaxInterestRate").value(command.getMaturityMaxInterestRate()).notNull().zeroOrPositiveAmount();
// baseDataValidator.reset().parameter("canRenew").value(command.getCanRenew()).ignoreIfNull();
// baseDataValidator.reset().parameter("canPreClose").value(command.getCanPreClose()).ignoreIfNull();
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("minimumBalance").comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
baseDataValidator.reset().parameter("maturityMinInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate()); baseDataValidator.reset().parameter("maturityMinInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate());
baseDataValidator.reset().parameter("maturityDefaultInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate()); baseDataValidator.reset().parameter("maturityDefaultInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate());
baseDataValidator.reset().parameter("maturityMinInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate()); baseDataValidator.reset().parameter("maturityMinInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate());
baseDataValidator.reset().parameter("renewalAllowed").trueOrFalseRequired(command.isRenewalAllowedChanged());
baseDataValidator.reset().parameter("preClosureAllowed").trueOrFalseRequired(command.isPreClosureAllowedChanged());
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("preClosureInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate()); baseDataValidator.reset().parameter("preClosureInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate());
if (!dataValidationErrors.isEmpty()) { if (!dataValidationErrors.isEmpty()) {
@@ -60,17 +61,17 @@ public class DepositProductCommandValidator {
baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimal()).ignoreIfNull().notNull().inMinMaxRange(0, 6); baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimal()).ignoreIfNull().notNull().inMinMaxRange(0, 6);
baseDataValidator.reset().parameter("minimumBalance").value(command.getMinimumBalance()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("minimumBalance").value(command.getMinimumBalance()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maximumBalance").value(command.getMaximumBalance()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maximumBalance").value(command.getMaximumBalance()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
baseDataValidator.reset().parameter("tenureMonths").value(command.getTenureMonths()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("tenureMonths").value(command.getTenureInMonths()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityDefaultInterestRate").value(command.getMaturityDefaultInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityDefaultInterestRate").value(command.getMaturityDefaultInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityMaxInterestRate").value(command.getMaturityMaxInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityMaxInterestRate").value(command.getMaturityMaxInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate()); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate());
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate()); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate());
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate()); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate());
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate()); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate());
if (command.isNoFieldChanged()) { if (command.isNoFieldChanged()) {
@@ -54,17 +54,18 @@ public class DepositProductReadPlatformServiceImpl implements
public DepositProductData retrieveDepositProductData(Long productId) { public DepositProductData retrieveDepositProductData(Long productId) {
DepositProductMapper depositProductMapper=new DepositProductMapper(); DepositProductMapper depositProductMapper=new DepositProductMapper();
String sql = "select "+ depositProductMapper.depositProductSchema() +" where dp.id = ? and dp.is_deleted=0"; String sql = "select "+ depositProductMapper.depositProductSchema() +" where dp.id = ? and dp.is_deleted=0";
DepositProductData productData=this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[]{productId});
populateProductDataWithDropdownOptions(productData); DepositProductData productData = this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[]{productId});
return productData;
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
return new DepositProductData(productData, currencyOptions);
} }
@Override @Override
public DepositProductData retrieveNewDepositProductDetails() { public DepositProductData retrieveNewDepositProductDetails() {
DepositProductData productData=new DepositProductData(); List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
populateProductDataWithDropdownOptions(productData); return new DepositProductData(currencyOptions);
return productData;
} }
private static final class DepositProductMapper implements RowMapper<DepositProductData>{ private static final class DepositProductMapper implements RowMapper<DepositProductData>{
@@ -127,9 +128,4 @@ public class DepositProductReadPlatformServiceImpl implements
} }
} }
}
private void populateProductDataWithDropdownOptions(final DepositProductData productData) {
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
productData.setCurrencyOptions(currencyOptions);
}
}
@@ -35,7 +35,7 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements
MonetaryCurrency currency = new MonetaryCurrency(command.getCurrencyCode(), command.getDigitsAfterDecimal()); MonetaryCurrency currency = new MonetaryCurrency(command.getCurrencyCode(), command.getDigitsAfterDecimal());
DepositProduct product = new DepositProduct(command.getName(),command.getDescription(),currency,command.getMinimumBalance(),command.getMaximumBalance(), DepositProduct product = new DepositProduct(command.getName(),command.getDescription(),currency,command.getMinimumBalance(),command.getMaximumBalance(),
command.getTenureMonths(),command.getMaturityDefaultInterestRate(),command.getMaturityMinInterestRate(),command.getMaturityMaxInterestRate(), command.getTenureInMonths(),command.getMaturityDefaultInterestRate(),command.getMaturityMinInterestRate(),command.getMaturityMaxInterestRate(),
command.isRenewalAllowed(), command.isPreClosureAllowed(), command.isRenewalAllowed(), command.isPreClosureAllowed(),
command.getPreClosureInterestRate()); command.getPreClosureInterestRate());
this.depositProductRepository.save(product); this.depositProductRepository.save(product);
@@ -53,7 +53,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "maturity_nominal_interest_rate", scale = 6, precision = 19, nullable = false) @Column(name = "maturity_nominal_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal interestRate; private BigDecimal interestRate;
@Column(name = "tenure_months", nullable = false) @Column(name = "tenure_months", nullable=false)
private Integer tenureInMonths; private Integer tenureInMonths;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@@ -121,9 +121,11 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths, final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths,
final Integer interestCompoundedEvery, final Integer interestCompoundedEvery,
final PeriodFrequencyType interestCompoundedFrequencyPeriodType, final PeriodFrequencyType interestCompoundedFrequencyPeriodType,
final LocalDate commencementDate) { final LocalDate commencementDate,
final boolean renewalAllowed,
final boolean preClosureAllowed) {
return new DepositAccount(client, product, externalId, deposit, interestRate, termInMonths, return new DepositAccount(client, product, externalId, deposit, interestRate, termInMonths,
interestCompoundedEvery, interestCompoundedFrequencyPeriodType, commencementDate); interestCompoundedEvery, interestCompoundedFrequencyPeriodType, commencementDate, renewalAllowed, preClosureAllowed);
} }
protected DepositAccount() { protected DepositAccount() {
@@ -135,7 +137,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths, final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths,
final Integer interestCompoundedEvery, final Integer interestCompoundedEvery,
final PeriodFrequencyType interestCompoundedFrequencyPeriodType, final PeriodFrequencyType interestCompoundedFrequencyPeriodType,
final LocalDate commencementDate) { final LocalDate commencementDate,
final boolean renewalAllowed,
final boolean preClosureAllowed) {
this.client = client; this.client = client;
this.product = product; this.product = product;
this.externalId = externalId; this.externalId = externalId;
@@ -153,6 +157,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate(); this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate();
} }
this.renewalAllowed = renewalAllowed;
this.preClosureAllowed = preClosureAllowed;
this.preClosureInterestRate = BigDecimal.ZERO; this.preClosureInterestRate = BigDecimal.ZERO;
// derived fields // derived fields
@@ -51,10 +51,18 @@ public class DepositAccountAssembler {
PeriodFrequencyType compoundingInterestFrequency = PeriodFrequencyType.fromInt(interestCompoundingPeriodType); PeriodFrequencyType compoundingInterestFrequency = PeriodFrequencyType.fromInt(interestCompoundingPeriodType);
boolean renewalAllowed = product.isRenewalAllowed(); boolean renewalAllowed = product.isRenewalAllowed();
// if (command.get) if (command.isRenewalAllowedChanged()) {
renewalAllowed = command.isRenewalAllowed();
}
boolean preClosureAllowed = product.isPreClosureAllowed();
if (command.isPreClosureAllowedChanged()) {
preClosureAllowed = command.isPreClosureAllowed();
}
DepositAccount account = DepositAccount.openNew(client, product, command.getExternalId(), deposit, command.getMaturityInterestRate(), DepositAccount account = DepositAccount.openNew(client, product, command.getExternalId(), deposit, command.getMaturityInterestRate(),
command.getTermInMonths(), command.getInterestCompoundedEvery(), compoundingInterestFrequency, command.getCommencementDate()); command.getTermInMonths(), command.getInterestCompoundedEvery(), compoundingInterestFrequency, command.getCommencementDate(),
renewalAllowed, preClosureAllowed);
return account; return account;
} }