avoid use of Boolean object type. allow ability to update renewal and preClosure settings of product definition.
This commit is contained in:
+14
-11
@@ -19,8 +19,8 @@ public class DepositProductCommand {
|
||||
private final BigDecimal maturityDefaultInterestRate;
|
||||
private final BigDecimal maturityMinInterestRate;
|
||||
private final BigDecimal maturityMaxInterestRate;
|
||||
private final Boolean canRenew;
|
||||
private final Boolean canPreClose;
|
||||
private final boolean renewalAllowed;
|
||||
private final boolean preClosureAllowed;
|
||||
private final BigDecimal preClosureInterestRate;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
@@ -31,7 +31,7 @@ public class DepositProductCommand {
|
||||
final BigDecimal minimumBalance, final BigDecimal maximumBalance,
|
||||
final Integer tenureMonths, final BigDecimal maturityDefaultInterestRate,
|
||||
final BigDecimal maturityMinInterestRate, final BigDecimal maturityMaxInterestRate,
|
||||
final Boolean canRenew, final Boolean canPreClose, final BigDecimal preClosureInterestRate ) {
|
||||
final boolean canRenew, final boolean canPreClose, final BigDecimal preClosureInterestRate ) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -48,8 +48,8 @@ public class DepositProductCommand {
|
||||
this.maturityMaxInterestRate = maturityMaxInterestRate;
|
||||
this.preClosureInterestRate = preClosureInterestRate;
|
||||
|
||||
this.canRenew =(canRenew != null) ? canRenew : false;
|
||||
this.canPreClose = (canPreClose != null) ? canPreClose : false;
|
||||
this.renewalAllowed = canRenew;
|
||||
this.preClosureAllowed = canPreClose;
|
||||
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
|
||||
@@ -98,13 +98,13 @@ public class DepositProductCommand {
|
||||
public BigDecimal getMaturityMaxInterestRate() {
|
||||
return maturityMaxInterestRate;
|
||||
}
|
||||
|
||||
public Boolean getCanRenew() {
|
||||
return canRenew;
|
||||
|
||||
public boolean isRenewalAllowed() {
|
||||
return renewalAllowed;
|
||||
}
|
||||
|
||||
public Boolean getCanPreClose() {
|
||||
return canPreClose;
|
||||
public boolean isPreClosureAllowed() {
|
||||
return preClosureAllowed;
|
||||
}
|
||||
|
||||
public BigDecimal getPreClosureInterestRate() {
|
||||
@@ -167,4 +167,7 @@ public class DepositProductCommand {
|
||||
return this.modifiedParameters.contains("preClosureInterestRate");
|
||||
}
|
||||
|
||||
}
|
||||
public boolean isNoFieldChanged() {
|
||||
return this.modifiedParameters.isEmpty();
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -1183,8 +1183,8 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
private Boolean extractBooleanParameter(final String paramName, final Map<String, ?> requestMap, final Set<String> modifiedParameters) {
|
||||
Boolean paramValue = null;
|
||||
private boolean extractBooleanParameter(final String paramName, final Map<String, ?> requestMap, final Set<String> modifiedParameters) {
|
||||
boolean paramValue = false;
|
||||
String paramValueAsString = null;
|
||||
if (requestMap.containsKey(paramName)) {
|
||||
paramValueAsString = (String) requestMap.get(paramName);
|
||||
@@ -1562,7 +1562,10 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("name","description","currencyCode", "digitsAfterDecimal","locale","minimumBalance","maximumBalance","tenureMonths",
|
||||
"maturityDefaultInterestRate","maturityMinInterestRate","maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate")
|
||||
);
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
String name = extractStringParameter("name", requestMap,modifiedParameters);
|
||||
@@ -1576,10 +1579,9 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
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("canRenew", requestMap, modifiedParameters);
|
||||
boolean canPreClose = extractBooleanParameter("canPreClose", requestMap, modifiedParameters);
|
||||
BigDecimal preClosureInterestRate = extractBigDecimalParameter("preClosureInterestRate", requestMap, modifiedParameters);
|
||||
|
||||
|
||||
return new DepositProductCommand(modifiedParameters, resourceIdentifier, name, description, currencyCode, digitsAfterDecimalValue, minimumBalance,maximumBalance,
|
||||
tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate, maturityMaxInterestRate, canRenew, canPreClose, preClosureInterestRate);
|
||||
|
||||
+6
-12
@@ -32,19 +32,21 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
|
||||
protected DepositProduct(){
|
||||
this.name = null;
|
||||
this.description = null;
|
||||
depositProductRelatedDetail=null;
|
||||
this.depositProductRelatedDetail=null;
|
||||
}
|
||||
|
||||
public DepositProduct(final String name, final String description, final MonetaryCurrency currency, final BigDecimal minimumBalance,final BigDecimal maximumBalance,
|
||||
final Integer tenureMonths,final BigDecimal maturityDefaultInterestRate, final BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate, Boolean canRenew,
|
||||
Boolean canPreClose, BigDecimal preClosureInterestRate ){
|
||||
final Integer tenureMonths,final BigDecimal maturityDefaultInterestRate, final BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate,
|
||||
boolean canRenew,
|
||||
boolean canPreClose, BigDecimal preClosureInterestRate ){
|
||||
this.name = name.trim();
|
||||
if (StringUtils.isNotBlank(description)) {
|
||||
this.description = description.trim();
|
||||
} else {
|
||||
this.description = null;
|
||||
}
|
||||
this.depositProductRelatedDetail= new DepositProductRelatedDetail(currency, minimumBalance, maximumBalance, tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate, maturityMaxInterestRate, canRenew, canPreClose, preClosureInterestRate);
|
||||
this.depositProductRelatedDetail= new DepositProductRelatedDetail(currency, minimumBalance, maximumBalance, tenureMonths,
|
||||
maturityDefaultInterestRate, maturityMinInterestRate, maturityMaxInterestRate, canRenew, canPreClose, preClosureInterestRate);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -83,14 +85,6 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
|
||||
return this.depositProductRelatedDetail.getMaturityMaxInterestRate();
|
||||
}
|
||||
|
||||
public Boolean getCanRenew() {
|
||||
return this.depositProductRelatedDetail.getCanRenew();
|
||||
}
|
||||
|
||||
public Boolean getCanPreClose() {
|
||||
return this.depositProductRelatedDetail.getCanPreClose();
|
||||
}
|
||||
|
||||
public BigDecimal getPreClosureInterestRate() {
|
||||
return this.depositProductRelatedDetail.getPreClosureInterestRate();
|
||||
}
|
||||
|
||||
+13
-21
@@ -10,8 +10,8 @@ import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
|
||||
@Embeddable
|
||||
public class DepositProductRelatedDetail {
|
||||
@Embeddable
|
||||
public class DepositProductRelatedDetail {
|
||||
|
||||
@Embedded
|
||||
private MonetaryCurrency currency;
|
||||
@@ -35,10 +35,10 @@ import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
private BigDecimal maturityMaxInterestRate;
|
||||
|
||||
@Column(name = "can_renew", nullable=false)
|
||||
private Boolean canRenew;
|
||||
private boolean renewalAllowed = false;
|
||||
|
||||
@Column(name = "can_pre_close", nullable=false)
|
||||
private Boolean canPreClose;
|
||||
private boolean preClosureAllowed = false;
|
||||
|
||||
@Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal preClosureInterestRate;
|
||||
@@ -50,13 +50,14 @@ import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
this.maturityDefaultInterestRate = null;
|
||||
this.maturityMinInterestRate = null;
|
||||
this.maturityMaxInterestRate = null;
|
||||
this.canRenew = null;
|
||||
this.canPreClose = null;
|
||||
this.preClosureInterestRate = null;
|
||||
}
|
||||
|
||||
public DepositProductRelatedDetail(final MonetaryCurrency currency, final BigDecimal minimumBalance,final BigDecimal maximumBalance, final Integer tenureMonths,
|
||||
final BigDecimal maturityDefaultInterestRate, final BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate, Boolean canRenew, Boolean canPreClose, BigDecimal preClosureInterestRate){
|
||||
public DepositProductRelatedDetail(
|
||||
final MonetaryCurrency currency, 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.currency=currency;
|
||||
this.minimumBalance=minimumBalance;
|
||||
@@ -66,12 +67,11 @@ import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
this.maturityDefaultInterestRate = maturityDefaultInterestRate;
|
||||
this.maturityMinInterestRate = maturityMinInterestRate;
|
||||
this.maturityMaxInterestRate = maturityMaxInterestRate;
|
||||
this.canRenew = canRenew;
|
||||
this.canPreClose = canPreClose;
|
||||
this.renewalAllowed = renewalAllowed;
|
||||
this.preClosureAllowed = preClosureAllowed;
|
||||
this.preClosureInterestRate = preClosureInterestRate;
|
||||
}
|
||||
|
||||
|
||||
public MonetaryCurrency getCurrency() {
|
||||
return this.currency.copy();
|
||||
}
|
||||
@@ -100,14 +100,6 @@ import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
return BigDecimal.valueOf(Double.valueOf(this.maturityMaxInterestRate.stripTrailingZeros().toString()));
|
||||
}
|
||||
|
||||
public Boolean getCanRenew() {
|
||||
return this.canRenew;
|
||||
}
|
||||
|
||||
public Boolean getCanPreClose() {
|
||||
return this.canPreClose;
|
||||
}
|
||||
|
||||
public BigDecimal getPreClosureInterestRate() {
|
||||
return BigDecimal.valueOf(Double.valueOf(this.preClosureInterestRate.stripTrailingZeros().toString()));
|
||||
}
|
||||
@@ -153,11 +145,11 @@ import org.mifosng.platform.exceptions.InterestRateOutsideRangeException;
|
||||
}
|
||||
|
||||
if (command.isCanRenewChanged()) {
|
||||
this.canRenew=command.getCanRenew();
|
||||
this.renewalAllowed=command.isRenewalAllowed();
|
||||
}
|
||||
|
||||
if (command.isCanPreCloseChanged()) {
|
||||
this.canPreClose=command.getCanPreClose();
|
||||
this.preClosureAllowed=command.isPreClosureAllowed();
|
||||
}
|
||||
|
||||
if (command.isPreClosureInterestRateChanged()) {
|
||||
|
||||
+8
-5
@@ -32,8 +32,8 @@ public class DepositProductCommandValidator {
|
||||
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("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());
|
||||
@@ -65,8 +65,6 @@ public class DepositProductCommandValidator {
|
||||
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("canRenew").value(command.getCanRenew()).ignoreIfNull();
|
||||
baseDataValidator.reset().parameter("canPreClose").value(command.getCanPreClose()).ignoreIfNull();
|
||||
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).ignoreIfNull().zeroOrPositiveAmount();
|
||||
|
||||
baseDataValidator.reset().comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
|
||||
@@ -75,7 +73,12 @@ public class DepositProductCommandValidator {
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate());
|
||||
|
||||
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getDescription(),command.getCurrencyCode(),command.getDigitsAfterDecimal(),command.getMinimumBalance(),command.getMaximumBalance(),command.getTenureMonths(),command.getMaturityDefaultInterestRate(),command.getMaturityMaxInterestRate(),command.getMaturityMinInterestRate(),command.getPreClosureInterestRate());
|
||||
if (command.isNoFieldChanged()) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append("deposit.product").append(".no.parameters.for.update");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), "id");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
|
||||
+3
-3
@@ -36,7 +36,8 @@ 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.getCanRenew(),command.getCanPreClose(),command.getPreClosureInterestRate());
|
||||
command.isRenewalAllowed(), command.isPreClosureAllowed(),
|
||||
command.getPreClosureInterestRate());
|
||||
this.depositProductRepository.save(product);
|
||||
|
||||
return new EntityIdentifier(product.getId());
|
||||
@@ -74,5 +75,4 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements
|
||||
this.depositProductRepository.save(product);
|
||||
return new EntityIdentifier(Long.valueOf(product.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user