ensure deposit account inherits details of product but allows for user to overriden core details where possible.

This commit is contained in:
Keith Woodlock
2012-08-15 11:35:25 +01:00
parent 9420d4fd14
commit 349e3f4a4e
8 changed files with 123 additions and 63 deletions
@@ -23,9 +23,12 @@ import org.mifosng.platform.api.commands.DepositAccountCommand;
import org.mifosng.platform.api.data.CurrencyData; import org.mifosng.platform.api.data.CurrencyData;
import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositAccountData;
import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.api.infrastructure.ApiDataConversionService; import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
import org.mifosng.platform.api.infrastructure.ApiParameterHelper; import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
import org.mifosng.platform.currency.service.CurrencyReadPlatformService; import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
import org.mifosng.platform.deposit.domain.SavingsDepositEnumerations;
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
import org.mifosng.platform.savingproduct.service.DepositAccountReadPlatformService; import org.mifosng.platform.savingproduct.service.DepositAccountReadPlatformService;
import org.mifosng.platform.savingproduct.service.DepositAccountWritePlatformService; import org.mifosng.platform.savingproduct.service.DepositAccountWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -106,8 +109,10 @@ public class DepositAccountsApiResource {
Set<String> typicalResponseParameters = new HashSet<String>( Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn", Arrays.asList("createdOn", "lastModifedOn",
"id", "clientId", "clientName", "productId", "productName", "id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate") "currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
); );
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
@@ -120,14 +125,12 @@ public class DepositAccountsApiResource {
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if (template) { if (template) {
responseParameters.addAll(Arrays.asList("currencyOptions")); account = handleTemplateRelatedData(responseParameters, account);
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
account = new DepositAccountData(account, allowedCurrencies);
} }
return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account); return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account);
} }
@GET @GET
@Path("template") @Path("template")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@@ -135,9 +138,12 @@ public class DepositAccountsApiResource {
public String retrieveNewDepositAccountDetails(@Context final UriInfo uriInfo) { public String retrieveNewDepositAccountDetails(@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>( Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn", Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions",
"id", "clientId", "clientName", "productId", "productName", "createdOn", "lastModifedOn",
"currency", "deposit", "maturityInterestRate", "currencyOptions") "id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
); );
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
@@ -147,8 +153,8 @@ public class DepositAccountsApiResource {
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
DepositAccountData account = this.depositAccountReadPlatformService.retrieveNewDepositAccountDetails(); DepositAccountData account = this.depositAccountReadPlatformService.retrieveNewDepositAccountDetails();
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
account = new DepositAccountData(account, allowedCurrencies); account = handleTemplateRelatedData(responseParameters, account);
return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account); return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account);
} }
@@ -163,4 +169,17 @@ public class DepositAccountsApiResource {
return Response.ok(new EntityIdentifier(accountId)).build(); return Response.ok(new EntityIdentifier(accountId)).build();
} }
private DepositAccountData handleTemplateRelatedData(
final Set<String> responseParameters,
final DepositAccountData account) {
responseParameters.addAll(Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions"));
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
EnumOptionData monthly = SavingsDepositEnumerations.interestCompoundingPeriodType(PeriodFrequencyType.MONTHS);
List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions = Arrays.asList(monthly);
return new DepositAccountData(account, allowedCurrencies, interestCompoundedEveryPeriodTypeOptions);
}
} }
@@ -3,6 +3,7 @@ package org.mifosng.platform.api;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@@ -19,12 +20,17 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.api.commands.DepositProductCommand;
import org.mifosng.platform.api.data.CurrencyData;
import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DepositProductData;
import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.api.infrastructure.ApiDataConversionService; import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
import org.mifosng.platform.api.infrastructure.ApiParameterHelper; import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
import org.mifosng.platform.deposit.domain.SavingsDepositEnumerations;
import org.mifosng.platform.depositproduct.service.DepositProductReadPlatformService; import org.mifosng.platform.depositproduct.service.DepositProductReadPlatformService;
import org.mifosng.platform.depositproduct.service.DepositProductWritePlatformService; import org.mifosng.platform.depositproduct.service.DepositProductWritePlatformService;
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -37,6 +43,9 @@ public class DepositProductsApiResource {
@Autowired @Autowired
private DepositProductReadPlatformService depositProductReadPlatformService; private DepositProductReadPlatformService depositProductReadPlatformService;
@Autowired
private CurrencyReadPlatformService currencyReadPlatformService;
@Autowired @Autowired
private DepositProductWritePlatformService depositProductWritePlatformService; private DepositProductWritePlatformService depositProductWritePlatformService;
@@ -117,13 +126,14 @@ public class DepositProductsApiResource {
responseParameters.addAll(typicalResponseParameters); responseParameters.addAll(typicalResponseParameters);
} }
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if (template) {
responseParameters.addAll(Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions"));
}
DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId); DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId);
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if (template) {
productData = handleTemplateRelatedData(responseParameters, productData);
}
return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, productData); return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, productData);
} }
@@ -149,6 +159,21 @@ public class DepositProductsApiResource {
DepositProductData depositProduct = this.depositProductReadPlatformService.retrieveNewDepositProductDetails(); DepositProductData depositProduct = this.depositProductReadPlatformService.retrieveNewDepositProductDetails();
depositProduct = handleTemplateRelatedData(responseParameters, depositProduct);
return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, depositProduct); return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, depositProduct);
} }
private DepositProductData handleTemplateRelatedData(
final Set<String> responseParameters,
final DepositProductData productData) {
responseParameters.addAll(Arrays.asList("currencyOptions", "interestCompoundedEveryPeriodTypeOptions"));
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
EnumOptionData monthly = SavingsDepositEnumerations.interestCompoundingPeriodType(PeriodFrequencyType.MONTHS);
List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions = Arrays.asList(monthly);
return new DepositProductData(productData, allowedCurrencies, interestCompoundedEveryPeriodTypeOptions);
}
} }
@@ -17,7 +17,7 @@ public class DepositAccountCommand {
private final BigDecimal depositAmount; private final BigDecimal depositAmount;
private final BigDecimal maturityInterestRate; private final BigDecimal maturityInterestRate;
private final Integer termInMonths; private final Integer tenureInMonths;
private final Integer interestCompoundedEvery; private final Integer interestCompoundedEvery;
private final Integer interestCompoundedEveryPeriodType; private final Integer interestCompoundedEveryPeriodType;
@@ -35,7 +35,7 @@ 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 tenureInMonths, final Integer compoundingInterestFrequency, final Integer compoundingInterestFrequencyType, final LocalDate commencementDate,
final boolean renewalAllowed, final boolean preClosureAllowed) { final boolean renewalAllowed, final boolean preClosureAllowed) {
this.id = id; this.id = id;
this.clientId = clientId; this.clientId = clientId;
@@ -44,7 +44,7 @@ public class DepositAccountCommand {
this.depositAmount = depositAmount; this.depositAmount = depositAmount;
this.maturityInterestRate = interestRate; this.maturityInterestRate = interestRate;
this.termInMonths = termInMonths; this.tenureInMonths = tenureInMonths;
this.modifiedParameters = modifiedParameters; this.modifiedParameters = modifiedParameters;
this.interestCompoundedEvery = compoundingInterestFrequency; this.interestCompoundedEvery = compoundingInterestFrequency;
@@ -77,11 +77,11 @@ public class DepositAccountCommand {
public BigDecimal getMaturityInterestRate() { public BigDecimal getMaturityInterestRate() {
return maturityInterestRate; return maturityInterestRate;
} }
public Integer getTermInMonths() {
return termInMonths;
}
public Integer getTenureInMonths() {
return tenureInMonths;
}
public Integer getInterestCompoundedEvery() { public Integer getInterestCompoundedEvery() {
return interestCompoundedEvery; return interestCompoundedEvery;
} }
@@ -106,12 +106,8 @@ public class DepositAccountCommand {
return this.modifiedParameters.isEmpty(); return this.modifiedParameters.isEmpty();
} }
public boolean isCurrencyCodeChanged() { public boolean isTenureInMonthsChanged() {
return this.modifiedParameters.contains("currencyCode"); return this.modifiedParameters.contains("tenureInMonths");
}
public boolean isDigitsAfterDecimalChanged() {
return this.modifiedParameters.contains("digitsAfterDecimal");
} }
public boolean isMaturityActualInterestRateChanged() { public boolean isMaturityActualInterestRateChanged() {
@@ -77,7 +77,7 @@ public class DepositAccountData {
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>(); this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
} }
public DepositAccountData(final DepositAccountData account, final List<CurrencyData> currencies) { public DepositAccountData(final DepositAccountData account, final List<CurrencyData> currencies, final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions) {
this.createdOn = account.getCreatedOn(); this.createdOn = account.getCreatedOn();
this.lastModifedOn = account.getLastModifedOn(); this.lastModifedOn = account.getLastModifedOn();
this.id = account.getId(); this.id = account.getId();
@@ -105,7 +105,7 @@ public class DepositAccountData {
this.preClosureInterestRate = account.getPreClosureInterestRate(); this.preClosureInterestRate = account.getPreClosureInterestRate();
this.currencyOptions = currencies; this.currencyOptions = currencies;
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>(); this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
} }
public DepositAccountData( public DepositAccountData(
@@ -45,15 +45,12 @@ 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 = "interest_compounded_every", nullable=false) @Column(name = "interest_compounded_every", nullable=false)
private Integer interestCompoundedEvery; private Integer interestCompoundedEvery;
@SuppressWarnings("unused")
@Column(name = "interest_compounded_every_period_enum", nullable=false) @Column(name = "interest_compounded_every_period_enum", nullable=false)
private PeriodFrequencyType interestCompoundedEveryPeriodType; private PeriodFrequencyType interestCompoundedEveryPeriodType;
@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;
@@ -63,7 +60,6 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "maturity_max_interest_rate", scale = 6, precision = 19, nullable = false) @Column(name = "maturity_max_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal maturityMaxInterestRate; private BigDecimal maturityMaxInterestRate;
@SuppressWarnings("unused")
@Column(name = "tenure_months", nullable=false) @Column(name = "tenure_months", nullable=false)
private Integer tenureInMonths; private Integer tenureInMonths;
@@ -122,6 +118,22 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
public MonetaryCurrency getCurrency() { public MonetaryCurrency getCurrency() {
return currency; return currency;
} }
public Integer getInterestCompoundedEvery() {
return interestCompoundedEvery;
}
public PeriodFrequencyType getInterestCompoundedEveryPeriodType() {
return interestCompoundedEveryPeriodType;
}
public Integer getTenureInMonths() {
return tenureInMonths;
}
public BigDecimal getMaturityDefaultInterestRate() {
return maturityDefaultInterestRate;
}
public boolean isRenewalAllowed() { public boolean isRenewalAllowed() {
return this.renewalAllowed; return this.renewalAllowed;
@@ -3,7 +3,6 @@ package org.mifosng.platform.depositproduct.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -12,7 +11,6 @@ import org.mifosng.platform.api.data.CurrencyData;
import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DepositProductData;
import org.mifosng.platform.api.data.DepositProductLookup; import org.mifosng.platform.api.data.DepositProductLookup;
import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
import org.mifosng.platform.deposit.domain.SavingsDepositEnumerations; import org.mifosng.platform.deposit.domain.SavingsDepositEnumerations;
import org.mifosng.platform.infrastructure.JdbcSupport; import org.mifosng.platform.infrastructure.JdbcSupport;
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
@@ -24,18 +22,15 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class DepositProductReadPlatformServiceImpl implements public class DepositProductReadPlatformServiceImpl implements DepositProductReadPlatformService {
DepositProductReadPlatformService {
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final CurrencyReadPlatformService currencyReadPlatformService;
@Autowired @Autowired
public DepositProductReadPlatformServiceImpl(final PlatformSecurityContext context,final TenantAwareRoutingDataSource dataSource,final CurrencyReadPlatformService currencyReadPlatformService) { public DepositProductReadPlatformServiceImpl(final PlatformSecurityContext context,final TenantAwareRoutingDataSource dataSource) {
this.context=context; this.context=context;
jdbcTemplate=new JdbcTemplate(dataSource); jdbcTemplate=new JdbcTemplate(dataSource);
this.currencyReadPlatformService=currencyReadPlatformService;
} }
@Override @Override
@@ -59,21 +54,15 @@ public class DepositProductReadPlatformServiceImpl implements
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}); return this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[]{productId});
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
EnumOptionData monthly = SavingsDepositEnumerations.interestCompoundingPeriodType(PeriodFrequencyType.MONTHS);
List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions = Arrays.asList(monthly);
return new DepositProductData(productData, currencyOptions, interestCompoundedEveryPeriodTypeOptions);
} }
@Override @Override
public DepositProductData retrieveNewDepositProductDetails() { public DepositProductData retrieveNewDepositProductDetails() {
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies(); List<CurrencyData> currencyOptions = null;
List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions = null;
EnumOptionData monthly = SavingsDepositEnumerations.interestCompoundingPeriodType(PeriodFrequencyType.MONTHS); EnumOptionData monthly = SavingsDepositEnumerations.interestCompoundingPeriodType(PeriodFrequencyType.MONTHS);
List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions = Arrays.asList(monthly);
return new DepositProductData(currencyOptions, monthly, interestCompoundedEveryPeriodTypeOptions); return new DepositProductData(currencyOptions, monthly, interestCompoundedEveryPeriodTypeOptions);
} }
@@ -1,5 +1,7 @@
package org.mifosng.platform.savingproduct.service; package org.mifosng.platform.savingproduct.service;
import java.math.BigDecimal;
import org.mifosng.platform.api.commands.DepositAccountCommand; import org.mifosng.platform.api.commands.DepositAccountCommand;
import org.mifosng.platform.client.domain.Client; import org.mifosng.platform.client.domain.Client;
import org.mifosng.platform.client.domain.ClientRepository; import org.mifosng.platform.client.domain.ClientRepository;
@@ -40,15 +42,28 @@ public class DepositAccountAssembler {
throw new DepositProductNotFoundException(command.getProductId()); throw new DepositProductNotFoundException(command.getProductId());
} }
// currency details inherited from product setting // details inherited from product setting (unless allowed to be overridden through account creation api
Money deposit = Money.of(product.getCurrency(), command.getDepositAmount()); Money deposit = Money.of(product.getCurrency(), command.getDepositAmount());
// default to months for now. Integer tenureInMonths = product.getTenureInMonths();
Integer interestCompoundingPeriodType = PeriodFrequencyType.MONTHS.getValue(); if (command.getTenureInMonths() != null) {
tenureInMonths = command.getTenureInMonths();
}
BigDecimal maturityInterestRate = product.getMaturityDefaultInterestRate();
if (command.getMaturityInterestRate() != null) {
maturityInterestRate = command.getMaturityInterestRate();
}
Integer compoundingInterestEvery = product.getInterestCompoundedEvery();
if (command.getInterestCompoundedEvery() != null) {
compoundingInterestEvery = command.getInterestCompoundedEvery();
}
PeriodFrequencyType compoundingInterestFrequency = product.getInterestCompoundedEveryPeriodType();
if (command.getInterestCompoundedEveryPeriodType() != null) { if (command.getInterestCompoundedEveryPeriodType() != null) {
interestCompoundingPeriodType = command.getInterestCompoundedEveryPeriodType(); compoundingInterestFrequency = PeriodFrequencyType.fromInt(command.getInterestCompoundedEveryPeriodType());
} }
PeriodFrequencyType compoundingInterestFrequency = PeriodFrequencyType.fromInt(interestCompoundingPeriodType);
boolean renewalAllowed = product.isRenewalAllowed(); boolean renewalAllowed = product.isRenewalAllowed();
if (command.isRenewalAllowedChanged()) { if (command.isRenewalAllowedChanged()) {
@@ -59,9 +74,13 @@ public class DepositAccountAssembler {
if (command.isPreClosureAllowedChanged()) { if (command.isPreClosureAllowedChanged()) {
preClosureAllowed = command.isPreClosureAllowed(); preClosureAllowed = command.isPreClosureAllowed();
} }
// end of details allowed to be overriden from product
DepositAccount account = DepositAccount.openNew(client, product, command.getExternalId(), deposit, command.getMaturityInterestRate(), DepositAccount account = DepositAccount.openNew(client, product, command.getExternalId(),
command.getTermInMonths(), command.getInterestCompoundedEvery(), compoundingInterestFrequency, command.getCommencementDate(), deposit,
maturityInterestRate,
tenureInMonths, compoundingInterestEvery, compoundingInterestFrequency,
command.getCommencementDate(),
renewalAllowed, preClosureAllowed); renewalAllowed, preClosureAllowed);
return account; return account;
@@ -29,7 +29,7 @@ public class DepositAccountCommandValidator {
baseDataValidator.reset().parameter("depositAmount").value(command.getDepositAmount()).ignoreIfNull().notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("depositAmount").value(command.getDepositAmount()).ignoreIfNull().notNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("maturityInterestRate").value(command.getMaturityInterestRate()).ignoreIfNull().notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityInterestRate").value(command.getMaturityInterestRate()).ignoreIfNull().notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("termInMonths").value(command.getTermInMonths()).ignoreIfNull().notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("tenureInMonths").value(command.getTenureInMonths()).ignoreIfNull().notNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("interestCompoundedEvery").value(command.getInterestCompoundedEvery()).ignoreIfNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("interestCompoundedEvery").value(command.getInterestCompoundedEvery()).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("interestCompoundedEveryPeriodType").value(command.getInterestCompoundedEveryPeriodType()).ignoreIfNull().inMinMaxRange(2, 2); baseDataValidator.reset().parameter("interestCompoundedEveryPeriodType").value(command.getInterestCompoundedEveryPeriodType()).ignoreIfNull().inMinMaxRange(2, 2);
@@ -58,11 +58,11 @@ public class DepositAccountCommandValidator {
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100); baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100);
baseDataValidator.reset().parameter("depositAmount").value(command.getDepositAmount()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("depositAmount").value(command.getDepositAmount()).notNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("maturityInterestRate").value(command.getMaturityInterestRate()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityInterestRate").value(command.getMaturityInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
baseDataValidator.reset().parameter("termInMonths").value(command.getTermInMonths()).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("tenureInMonths").value(command.getTenureInMonths()).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("interestCompoundedEvery").value(command.getInterestCompoundedEvery()).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("interestCompoundedEvery").value(command.getInterestCompoundedEvery()).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("interestCompoundedEveryPeriodType").value(command.getInterestCompoundedEveryPeriodType()).notNull().inMinMaxRange(2, 2); baseDataValidator.reset().parameter("interestCompoundedEveryPeriodType").value(command.getInterestCompoundedEveryPeriodType()).ignoreIfNull().inMinMaxRange(2, 2);
baseDataValidator.reset().parameter("commencementDate").value(command.getCommencementDate()).notNull(); baseDataValidator.reset().parameter("commencementDate").value(command.getCommencementDate()).notNull();
if (!dataValidationErrors.isEmpty()) { if (!dataValidationErrors.isEmpty()) {