From c2e563bf6f5b012695c5286e19b3ac4311dea23e Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Tue, 14 Aug 2012 15:12:43 +0100 Subject: [PATCH] make parameter names consistent between product and account for deposits. --- .../platform/DataValidatorBuilder.java | 11 +- .../api/DepositProductsApiResource.java | 25 +- .../api/commands/DepositAccountCommand.java | 24 +- .../api/commands/DepositProductCommand.java | 24 +- .../platform/api/data/DepositAccountData.java | 18 +- .../platform/api/data/DepositProductData.java | 218 +++++++++--------- .../ApiDataConversionServiceImpl.java | 29 ++- .../deposit/domain/DepositProduct.java | 105 ++++++++- .../DepositProductCommandValidator.java | 21 +- ...DepositProductReadPlatformServiceImpl.java | 20 +- ...WritePlatformServiceJpaRepositoryImpl.java | 2 +- .../saving/domain/DepositAccount.java | 15 +- .../service/DepositAccountAssembler.java | 12 +- 13 files changed, 324 insertions(+), 200 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java b/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java index eb9c58167..ea4f09113 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java @@ -86,6 +86,16 @@ public class DataValidatorBuilder { 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() { if (value == null && !ignoreNullValue) { StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank"); @@ -275,5 +285,4 @@ public class DataValidatorBuilder { } return this; } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java index 72c49fc8d..749a479ef 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java @@ -81,10 +81,12 @@ public class DepositProductsApiResource { @GET @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) - public String retrieveAllDepositProducts(@Context final UriInfo uriInfo){ - Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", - "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", - "maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); + public String retrieveAllDepositProducts(@Context final UriInfo uriInfo) { + + Set typicalResponseParameters = new HashSet( + Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", + "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate", + "maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { @@ -100,10 +102,12 @@ public class DepositProductsApiResource { @Path("{productId}") @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) - public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo){ - Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", - "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", - "maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); + public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { + + Set typicalResponseParameters = new HashSet( + Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", + "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate", + "maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { @@ -125,8 +129,9 @@ public class DepositProductsApiResource { public String retrieveNewDepositProductDetails(@Context final UriInfo uriInfo) { Set typicalResponseParameters = new HashSet( - Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", - "maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); + Arrays.asList("currencyOptions", "id", "name", "description", "createdOn", "lastModifedOn", + "currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate", + "maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositAccountCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositAccountCommand.java index 248fe7481..ef1861e55 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositAccountCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositAccountCommand.java @@ -23,6 +23,9 @@ public class DepositAccountCommand { private final Integer interestCompoundedEveryPeriodType; private final LocalDate commencementDate; + private final boolean renewalAllowed; + private final boolean preClosureAllowed; + private final Set modifiedParameters; public DepositAccountCommand(final Set modifiedParameters, @@ -32,7 +35,8 @@ public class DepositAccountCommand { final String externalId, final BigDecimal depositAmount, 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.clientId = clientId; this.productId = productId; @@ -46,6 +50,8 @@ public class DepositAccountCommand { this.interestCompoundedEvery = compoundingInterestFrequency; this.interestCompoundedEveryPeriodType = compoundingInterestFrequencyType; this.commencementDate = commencementDate; + this.renewalAllowed = renewalAllowed; + this.preClosureAllowed = preClosureAllowed; } public Long getId() { @@ -88,6 +94,14 @@ public class DepositAccountCommand { return commencementDate; } + public boolean isRenewalAllowed() { + return renewalAllowed; + } + + public boolean isPreClosureAllowed() { + return preClosureAllowed; + } + public boolean isNoFieldChanged() { return this.modifiedParameters.isEmpty(); } @@ -103,4 +117,12 @@ public class DepositAccountCommand { public boolean isMaturityActualInterestRateChanged() { return this.modifiedParameters.contains("interestRate"); } + + public boolean isRenewalAllowedChanged() { + return this.modifiedParameters.contains("renewalAllowed"); + } + + public boolean isPreClosureAllowedChanged() { + return this.modifiedParameters.contains("preClosureAllowed"); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositProductCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositProductCommand.java index 70751c08a..54c7829af 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositProductCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/DepositProductCommand.java @@ -15,7 +15,7 @@ public class DepositProductCommand { private final BigDecimal minimumBalance; private final BigDecimal maximumBalance; - private final Integer tenureMonths; + private final Integer tenureInMonths; private final BigDecimal maturityDefaultInterestRate; private final BigDecimal maturityMinInterestRate; private final BigDecimal maturityMaxInterestRate; @@ -29,9 +29,9 @@ public class DepositProductCommand { 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 Integer tenureInMonths, final BigDecimal maturityDefaultInterestRate, 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.name = name; this.description = description; @@ -42,14 +42,14 @@ public class DepositProductCommand { this.minimumBalance=minimumBalance; this.maximumBalance=maximumBalance; - this.tenureMonths=tenureMonths; + this.tenureInMonths=tenureInMonths; this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityMinInterestRate = maturityMinInterestRate; this.maturityMaxInterestRate = maturityMaxInterestRate; this.preClosureInterestRate = preClosureInterestRate; - this.renewalAllowed = canRenew; - this.preClosureAllowed = canPreClose; + this.renewalAllowed = renewalAllowed; + this.preClosureAllowed = preClosureAllowed; this.modifiedParameters = modifiedParameters; @@ -83,8 +83,8 @@ public class DepositProductCommand { return maximumBalance; } - public Integer getTenureMonths() { - return tenureMonths; + public Integer getTenureInMonths() { + return tenureInMonths; } public BigDecimal getMaturityDefaultInterestRate() { @@ -155,12 +155,12 @@ public class DepositProductCommand { return this.modifiedParameters.contains("maturityMaxInterestRate"); } - public boolean isCanRenewChanged() { - return this.modifiedParameters.contains("canRenew"); + public boolean isRenewalAllowedChanged() { + return this.modifiedParameters.contains("renewalAllowed"); } - public boolean isCanPreCloseChanged() { - return this.modifiedParameters.contains("canPreClose"); + public boolean isPreClosureAllowedChanged() { + return this.modifiedParameters.contains("preClosureAllowed"); } public boolean isPreClosureInterestRateChanged() { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java index f68bee689..d57d6bc42 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java @@ -24,7 +24,7 @@ public class DepositAccountData { private final BigDecimal deposit; private final BigDecimal maturityInterestRate; - private final Integer termInMonths; + private final Integer tenureInMonths; private final LocalDate projectedCommencementDate; private final LocalDate actualCommencementDate; private final LocalDate projectedMaturityDate; @@ -53,7 +53,7 @@ public class DepositAccountData { this.currency = null; this.deposit = null; this.maturityInterestRate = null; - this.termInMonths = null; + this.tenureInMonths = null; this.projectedCommencementDate = null; this.actualCommencementDate = null; this.projectedMaturityDate = null; @@ -80,7 +80,7 @@ public class DepositAccountData { this.currency = account.getCurrency(); this.deposit = account.getDeposit(); this.maturityInterestRate = account.getMaturityInterestRate(); - this.termInMonths = account.getTermInMonths(); + this.tenureInMonths = account.getTenureInMonths(); this.projectedCommencementDate = account.getProjectedCommencementDate(); this.actualCommencementDate = account.getActualCommencementDate(); this.projectedMaturityDate = account.getProjectedMaturityDate(); @@ -106,7 +106,7 @@ public class DepositAccountData { final String productName, final CurrencyData currency, final BigDecimal deposit, final BigDecimal interestRate, - final Integer termInMonths, + final Integer tenureInMonths, final LocalDate projectedCommencementDate, final LocalDate actualCommencementDate, final LocalDate projectedMaturityDate, @@ -128,7 +128,7 @@ public class DepositAccountData { this.currency = currency; this.deposit = deposit; this.maturityInterestRate=interestRate; - this.termInMonths = termInMonths; + this.tenureInMonths = tenureInMonths; this.projectedCommencementDate = projectedCommencementDate; this.actualCommencementDate = actualCommencementDate; this.projectedMaturityDate = projectedMaturityDate; @@ -175,11 +175,11 @@ public class DepositAccountData { public BigDecimal getMaturityInterestRate() { return maturityInterestRate; } - - public Integer getTermInMonths() { - return termInMonths; + + public Integer getTenureInMonths() { + return tenureInMonths; } - + public LocalDate getProjectedCommencementDate() { return projectedCommencementDate; } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java index b795ec3fb..a72c8ef6d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java @@ -1,40 +1,53 @@ package org.mifosng.platform.api.data; -import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; 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 String name; - private String description; - private String currencyCode; - private Integer digitsAfterDecimal; - private BigDecimal minimumBalance = BigDecimal.ZERO; - private BigDecimal maximumBalance = BigDecimal.ZERO; - private Integer tenureMonths; - private BigDecimal maturityDefaultInterestRate = BigDecimal.ZERO; - private BigDecimal maturityMinInterestRate = BigDecimal.ZERO; - private BigDecimal maturityMaxInterestRate = BigDecimal.ZERO; - private Boolean canRenew; - private Boolean canPreClose; - private BigDecimal preClosureInterestRate = BigDecimal.ZERO; - private DateTime createdOn; - private DateTime lastModifedOn; + private final Long id; + private final String name; + private final String description; + private final String currencyCode; + private final Integer digitsAfterDecimal; + private final BigDecimal minimumBalance; + private final BigDecimal maximumBalance; + private final Integer tenureInMonths; + private final BigDecimal maturityDefaultInterestRate; + private final BigDecimal maturityMinInterestRate; + private final BigDecimal maturityMaxInterestRate; + private final boolean renewalAllowed; + private final boolean preClosureAllowed; + private final BigDecimal preClosureInterestRate; - private List currencyOptions = new ArrayList(); + private final DateTime createdOn; + private final DateTime lastModifedOn; - public DepositProductData() { - // - } + private final List currencyOptions; - public DepositProductData(DateTime createdOn, DateTime lastModifedOn, Long id,String name, String description, String currencyCode, Integer digitsAfterDecimal,BigDecimal minimumBalance,BigDecimal maximumBalance, - Integer tenureMonths, BigDecimal maturityDefaultInterestRate, BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate, - Boolean canRenew, Boolean canPreClose, BigDecimal preClosureInterestRate) { + public DepositProductData( + final DateTime createdOn, + 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.lastModifedOn=lastModifedOn; @@ -46,151 +59,126 @@ public class DepositProductData implements Serializable { this.minimumBalance=minimumBalance; this.maximumBalance=maximumBalance; - this.tenureMonths=tenureMonths; + this.tenureInMonths=tenureMonths; this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityMinInterestRate=maturityMinInterestRate; this.maturityMaxInterestRate=maturityMaxInterestRate; - this.canRenew=canRenew; - this.canPreClose=canPreClose; + this.renewalAllowed=renewalAllowed; + this.preClosureAllowed=preClosureAllowed; this.preClosureInterestRate=preClosureInterestRate; - + + this.currencyOptions = new ArrayList(); } + public DepositProductData(final List 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 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() { return id; } - public void setId(Long id) { - this.id = id; - } - public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - public String getDescription() { return description; } - public void setDescription(String description) { - this.description = description; - } - public String getCurrencyCode() { return currencyCode; } - public void setCurrencyCode(String currencyCode) { - this.currencyCode = currencyCode; - } - public Integer getDigitsAfterDecimal() { return digitsAfterDecimal; } - public void setDigitsAfterDecimal(Integer digitsAfterDecimal) { - this.digitsAfterDecimal = digitsAfterDecimal; - } - public BigDecimal getMinimumBalance() { return minimumBalance; } - public void setMinimumBalance(BigDecimal minimumBalance) { - this.minimumBalance = minimumBalance; - } - public BigDecimal getMaximumBalance() { return maximumBalance; } - public void setMaximumBalance(BigDecimal maximumBalance) { - this.maximumBalance = maximumBalance; - } - - 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 getCurrencyOptions() { - return currencyOptions; - } - - public void setCurrencyOptions(List currencyOptions) { - this.currencyOptions = currencyOptions; - } - - public Integer getTenureMonths() { - return tenureMonths; - } - - public void setTenureMonths(Integer tenureMonths) { - this.tenureMonths = tenureMonths; + public Integer getTenureInMonths() { + return tenureInMonths; } public BigDecimal getMaturityDefaultInterestRate() { return maturityDefaultInterestRate; } - public void setMaturityDefaultInterestRate( - BigDecimal maturityDefaultInterestRate) { - this.maturityDefaultInterestRate = maturityDefaultInterestRate; - } - public BigDecimal getMaturityMinInterestRate() { return maturityMinInterestRate; } - public void setMaturityMinInterestRate(BigDecimal maturityMinInterestRate) { - this.maturityMinInterestRate = maturityMinInterestRate; - } - public BigDecimal getMaturityMaxInterestRate() { return maturityMaxInterestRate; } - public void setMaturityMaxInterestRate(BigDecimal maturityMaxInterestRate) { - this.maturityMaxInterestRate = maturityMaxInterestRate; + public boolean isRenewalAllowed() { + return renewalAllowed; } - public Boolean getCanRenew() { - return canRenew; - } - - public void setCanRenew(Boolean canRenew) { - this.canRenew = canRenew; - } - - public Boolean getCanPreClose() { - return canPreClose; - } - - public void setCanPreClose(Boolean canPreClose) { - this.canPreClose = canPreClose; + public boolean isPreClosureAllowed() { + return preClosureAllowed; } public BigDecimal getPreClosureInterestRate() { return preClosureInterestRate; } - public void setPreClosureInterestRate(BigDecimal preClosureInterestRate) { - this.preClosureInterestRate = preClosureInterestRate; + public DateTime getCreatedOn() { + return createdOn; } -} + + public DateTime getLastModifedOn() { + return lastModifedOn; + } + + public List getCurrencyOptions() { + return currencyOptions; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java index bb4b2d2d3..de4c52e1a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java @@ -1492,9 +1492,11 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { Type typeOfMap = new TypeToken>() {}.getType(); Map requestMap = gsonConverter.fromJson(json, typeOfMap); + // preClosureInterestRate Set supportedParams = new HashSet( Arrays.asList("clientId", "productId", "externalId", "depositAmount", "maturityInterestRate", - "termInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate", + "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate", + "renewalAllowed", "preClosureAllowed", "locale", "dateFormat") ); checkForUnsupportedParameters(requestMap, supportedParams); @@ -1505,17 +1507,18 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { String externalId = extractStringParameter("externalId", requestMap,modifiedParameters); BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", 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 interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", 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, externalId, depositAmount, interestRate, termInMonths, - interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate); + interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate, renewalAllowed, preClosureAllowed); } @Override @@ -1569,8 +1572,8 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { Map requestMap = gsonConverter.fromJson(json, typeOfMap); Set supportedParams = new HashSet( - Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureMonths", - "maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate") + Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureInMonths", + "maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate") ); checkForUnsupportedParameters(requestMap, supportedParams); Set modifiedParameters = new HashSet(); @@ -1581,12 +1584,12 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { BigDecimal minimumBalance=extractBigDecimalParameter("minimumBalance", 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 maturityMinInterestRate = extractBigDecimalParameter("maturityMinInterestRate", requestMap, modifiedParameters); BigDecimal maturityMaxInterestRate = extractBigDecimalParameter("maturityMaxInterestRate", requestMap, modifiedParameters); - boolean canRenew = extractBooleanParameter("canRenew", requestMap, modifiedParameters); - boolean canPreClose = extractBooleanParameter("canPreClose", requestMap, modifiedParameters); + boolean canRenew = extractBooleanParameter("renewalAllowed", requestMap, modifiedParameters); + boolean canPreClose = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters); BigDecimal preClosureInterestRate = extractBigDecimalParameter("preClosureInterestRate", requestMap, modifiedParameters); 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, Set responseParameters, DepositProductData... products) { - Set supportedParameters = new HashSet(Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions", "minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate", - "maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")); + Set supportedParameters = new HashSet( + Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", + "currencyOptions", "minimumBalance","maximumBalance","tenureInMonths","maturityDefaultInterestRate","maturityMinInterestRate", + "maturityMaxInterestRate","renewalAllowed","preClosureAllowed","preClosureInterestRate")); final Set parameterNamesToSkip = new HashSet(); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/deposit/domain/DepositProduct.java b/mifosng-provider/src/main/java/org/mifosng/platform/deposit/domain/DepositProduct.java index 2f378916a..80a986a2d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/deposit/domain/DepositProduct.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/deposit/domain/DepositProduct.java @@ -10,6 +10,7 @@ import javax.persistence.Table; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.currency.domain.MonetaryCurrency; +import org.mifosng.platform.exceptions.ValueOutsideRangeException; import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.user.domain.AppUser; @@ -17,9 +18,11 @@ import org.mifosng.platform.user.domain.AppUser; @Table(name = "portfolio_product_deposit") public class DepositProduct extends AbstractAuditableCustom { + @SuppressWarnings("unused") @Column(name = "name", nullable = false) private String name; + @SuppressWarnings("unused") @Column(name = "description") private String description; @@ -35,9 +38,11 @@ public class DepositProduct extends AbstractAuditableCustom { @Column(name = "maximum_balance", scale = 6, precision = 19, nullable = false) private BigDecimal maximumBalance; + @SuppressWarnings("unused") @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) private BigDecimal maturityDefaultInterestRate; @@ -53,13 +58,13 @@ public class DepositProduct extends AbstractAuditableCustom { @Column(name = "can_pre_close", nullable=false) private boolean preClosureAllowed = false; + @SuppressWarnings("unused") @Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false) private BigDecimal preClosureInterestRate; - protected DepositProduct(){ - this.name = null; - this.description = null; - } + protected DepositProduct() { + // + } public DepositProduct(final String name, final String description, final MonetaryCurrency currency, final BigDecimal minimumBalance, @@ -78,7 +83,7 @@ public class DepositProduct extends AbstractAuditableCustom { this.currency = currency; this.minimumBalance = minimumBalance; this.maximumBalance = maximumBalance; - this.tenureMonths = tenureMonths; + this.tenureInMonths = tenureMonths; this.maturityDefaultInterestRate = maturityDefaultInterestRate; this.maturityMinInterestRate = maturityMinInterestRate; this.maturityMaxInterestRate = maturityMaxInterestRate; @@ -107,7 +112,7 @@ public class DepositProduct extends AbstractAuditableCustom { this.deleted = true; } - public void update(DepositProductCommand command){ + public void update(final DepositProductCommand command){ if (command.isNameChanged()) { this.name = command.getName(); @@ -116,13 +121,91 @@ public class DepositProduct extends AbstractAuditableCustom { if (command.isDescriptionChanged()) { 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) { -// 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) { -// 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"); + } } -} +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductCommandValidator.java index bbf849bbc..a7228f76e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductCommandValidator.java @@ -27,19 +27,20 @@ public class DepositProductCommandValidator { baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimal()).notNull().inMinMaxRange(0, 6); baseDataValidator.reset().parameter("minimumBalance").value(command.getMinimumBalance()).notNull().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("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).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("maturityDefaultInterestRate").comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate()); 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()); 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("minimumBalance").value(command.getMinimumBalance()).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("maturityMinInterestRate").value(command.getMaturityMinInterestRate()).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.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate()); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate()); + + baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate()); if (command.isNoFieldChanged()) { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductReadPlatformServiceImpl.java index 178da3303..6168ce6e4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductReadPlatformServiceImpl.java @@ -54,17 +54,18 @@ public class DepositProductReadPlatformServiceImpl implements public DepositProductData retrieveDepositProductData(Long productId) { DepositProductMapper depositProductMapper=new DepositProductMapper(); 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); - return productData; + + DepositProductData productData = this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[]{productId}); + + List currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies(); + return new DepositProductData(productData, currencyOptions); } @Override public DepositProductData retrieveNewDepositProductDetails() { - DepositProductData productData=new DepositProductData(); - populateProductDataWithDropdownOptions(productData); - return productData; + List currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies(); + return new DepositProductData(currencyOptions); } private static final class DepositProductMapper implements RowMapper{ @@ -127,9 +128,4 @@ public class DepositProductReadPlatformServiceImpl implements } } - - private void populateProductDataWithDropdownOptions(final DepositProductData productData) { - List currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies(); - productData.setCurrencyOptions(currencyOptions); - } -} +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java index 45afcafa0..808766d27 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/depositproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java @@ -35,7 +35,7 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements MonetaryCurrency currency = new MonetaryCurrency(command.getCurrencyCode(), command.getDigitsAfterDecimal()); 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.getPreClosureInterestRate()); this.depositProductRepository.save(product); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java index d38dec85e..86a7f864d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java @@ -53,7 +53,7 @@ public class DepositAccount extends AbstractAuditableCustom { @Column(name = "maturity_nominal_interest_rate", scale = 6, precision = 19, nullable = false) private BigDecimal interestRate; - @Column(name = "tenure_months", nullable = false) + @Column(name = "tenure_months", nullable=false) private Integer tenureInMonths; @SuppressWarnings("unused") @@ -121,9 +121,11 @@ public class DepositAccount extends AbstractAuditableCustom { final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths, final Integer interestCompoundedEvery, final PeriodFrequencyType interestCompoundedFrequencyPeriodType, - final LocalDate commencementDate) { + final LocalDate commencementDate, + final boolean renewalAllowed, + final boolean preClosureAllowed) { return new DepositAccount(client, product, externalId, deposit, interestRate, termInMonths, - interestCompoundedEvery, interestCompoundedFrequencyPeriodType, commencementDate); + interestCompoundedEvery, interestCompoundedFrequencyPeriodType, commencementDate, renewalAllowed, preClosureAllowed); } protected DepositAccount() { @@ -135,7 +137,9 @@ public class DepositAccount extends AbstractAuditableCustom { final String externalId, final Money deposit, final BigDecimal interestRate, final Integer termInMonths, final Integer interestCompoundedEvery, final PeriodFrequencyType interestCompoundedFrequencyPeriodType, - final LocalDate commencementDate) { + final LocalDate commencementDate, + final boolean renewalAllowed, + final boolean preClosureAllowed) { this.client = client; this.product = product; this.externalId = externalId; @@ -153,6 +157,9 @@ public class DepositAccount extends AbstractAuditableCustom { this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate(); } + this.renewalAllowed = renewalAllowed; + this.preClosureAllowed = preClosureAllowed; + this.preClosureInterestRate = BigDecimal.ZERO; // derived fields diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositAccountAssembler.java index 027ac7cf0..d68101c63 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositAccountAssembler.java @@ -51,10 +51,18 @@ public class DepositAccountAssembler { PeriodFrequencyType compoundingInterestFrequency = PeriodFrequencyType.fromInt(interestCompoundingPeriodType); 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(), - command.getTermInMonths(), command.getInterestCompoundedEvery(), compoundingInterestFrequency, command.getCommencementDate()); + command.getTermInMonths(), command.getInterestCompoundedEvery(), compoundingInterestFrequency, command.getCommencementDate(), + renewalAllowed, preClosureAllowed); return account; }