MIFOSX-311: cherry pick of fix from 0.11.4 branch.
This commit is contained in:
+8
-7
@@ -36,12 +36,12 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
|
||||
/**
|
||||
* The parameters supported for this command.
|
||||
*/
|
||||
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "clientId", "groupId", "loanType", "calendarId", "productId", "accountNo",
|
||||
"externalId", "fundId", "loanOfficerId", "loanPurposeId", "transactionProcessingStrategyId", "principal", "inArrearsTolerance",
|
||||
"interestRatePerPeriod", "repaymentEvery", "numberOfRepayments", "loanTermFrequency", "loanTermFrequencyType",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"expectedDisbursementDate", "repaymentsStartingFromDate", "interestChargedFromDate", "submittedOnDate", "submittedOnNote",
|
||||
"locale", "dateFormat", "charges", "collateral"));
|
||||
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "clientId", "groupId", "loanType", "calendarId",
|
||||
"productId", "accountNo", "externalId", "fundId", "loanOfficerId", "loanPurposeId", "transactionProcessingStrategyId",
|
||||
"principal", "inArrearsTolerance", "interestRatePerPeriod", "repaymentEvery", "numberOfRepayments", "loanTermFrequency",
|
||||
"loanTermFrequencyType", "repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType",
|
||||
"interestCalculationPeriodType", "expectedDisbursementDate", "repaymentsStartingFromDate", "interestChargedFromDate",
|
||||
"submittedOnDate", "submittedOnNote", "locale", "dateFormat", "charges", "collateral"));
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
|
||||
@@ -98,7 +98,8 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
|
||||
final String interestRatePerPeriodParameterName = "interestRatePerPeriod";
|
||||
final BigDecimal interestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull()
|
||||
.zeroOrPositiveAmount();
|
||||
|
||||
final String interestTypeParameterName = "interestType";
|
||||
final Integer interestType = fromApiJsonHelper.extractIntegerWithLocaleNamed(interestTypeParameterName, element);
|
||||
|
||||
+17
-5
@@ -160,7 +160,8 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
final String interestRatePerPeriodParameterName = "interestRatePerPeriod";
|
||||
final BigDecimal interestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull()
|
||||
.zeroOrPositiveAmount();
|
||||
|
||||
final String interestTypeParameterName = "interestType";
|
||||
final Integer interestType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestTypeParameterName, element);
|
||||
@@ -427,7 +428,8 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final BigDecimal interestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notNull()
|
||||
.zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
final String interestTypeParameterName = "interestType";
|
||||
@@ -600,11 +602,21 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
public void validateMinMaxConstraintsForModification(final String json, final LoanProduct loanProduct) {
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
public void validateMinMaxConstraintValues(final JsonElement element, final LoanProduct loanProduct) {
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
|
||||
this.loanProductCommandFromApiJsonDeserializer.validateMinMaxConstraints(element, baseDataValidator, loanProduct);
|
||||
|
||||
final BigDecimal minPrincipal = loanProduct.getMinPrincipalAmount().getAmount();
|
||||
final BigDecimal maxPrincipal = loanProduct.getMaxPrincipalAmount().getAmount();
|
||||
final String principalParameterName = "principal";
|
||||
|
||||
if (fromApiJsonHelper.parameterExists(principalParameterName, element)) {
|
||||
final BigDecimal principal = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(principalParameterName, element);
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principal).notNull().positiveAmount()
|
||||
.inMinAndMaxAmountRange(minPrincipal, maxPrincipal);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
+3
-2
@@ -232,7 +232,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
}
|
||||
|
||||
// validate min and maximum constraints
|
||||
this.fromApiJsonDeserializer.validateMinMaxConstraintsForModification(command.json(), existingLoanApplication.loanProduct());
|
||||
this.fromApiJsonDeserializer.validateForModify(command.json());
|
||||
|
||||
final String fundIdParamName = "fundId";
|
||||
if (changes.containsKey(fundIdParamName)) {
|
||||
@@ -308,7 +308,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
}
|
||||
} else {
|
||||
// attaching new calendar
|
||||
CalendarInstance calendarInstance = new CalendarInstance(calendar, existingLoanApplication.getId(), CalendarEntityType.LOANS.getValue());
|
||||
CalendarInstance calendarInstance = new CalendarInstance(calendar, existingLoanApplication.getId(),
|
||||
CalendarEntityType.LOANS.getValue());
|
||||
this.calendarInstanceRepository.save(calendarInstance);
|
||||
}
|
||||
|
||||
|
||||
+67
-34
@@ -104,7 +104,8 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) != -1) {
|
||||
baseDataValidator.reset().parameter(maxPrincipalParameterName).value(maxPrincipalAmount).notLessThanMin(minPrincipalAmount);
|
||||
if (minPrincipalAmount.compareTo(maxPrincipalAmount) <= 0) {
|
||||
baseDataValidator.reset().parameter("principal").value(principal).inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
|
||||
baseDataValidator.reset().parameter("principal").value(principal)
|
||||
.inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
|
||||
}
|
||||
} else {
|
||||
baseDataValidator.reset().parameter("principal").value(principal).notGreaterThanMax(maxPrincipalAmount);
|
||||
@@ -120,24 +121,29 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
Integer minNumberOfRepayments = null;
|
||||
if (fromApiJsonHelper.parameterExists(minNumberOfRepaymentsParameterName, element)) {
|
||||
minNumberOfRepayments = fromApiJsonHelper.extractIntegerWithLocaleNamed(minNumberOfRepaymentsParameterName, element);
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull()
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
String maxNumberOfRepaymentsParameterName = "maxNumberOfRepayments";
|
||||
Integer maxNumberOfRepayments = null;
|
||||
if (fromApiJsonHelper.parameterExists(maxNumberOfRepaymentsParameterName, element)) {
|
||||
maxNumberOfRepayments = fromApiJsonHelper.extractIntegerWithLocaleNamed(maxNumberOfRepaymentsParameterName, element);
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).ignoreIfNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).ignoreIfNull()
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) {
|
||||
if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) {
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).notLessThanMin(minNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments)
|
||||
.notLessThanMin(minNumberOfRepayments);
|
||||
if (minNumberOfRepayments.compareTo(maxNumberOfRepayments) <= 0) {
|
||||
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments).inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments)
|
||||
.inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
|
||||
}
|
||||
} else {
|
||||
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments).notGreaterThanMax(maxNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments)
|
||||
.notGreaterThanMax(maxNumberOfRepayments);
|
||||
}
|
||||
} else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) {
|
||||
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments).notLessThanMin(minNumberOfRepayments);
|
||||
@@ -157,27 +163,33 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
BigDecimal minInterestRatePerPeriod = null;
|
||||
if (fromApiJsonHelper.parameterExists(minInterestRatePerPeriodParameterName, element)) {
|
||||
minInterestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(minInterestRatePerPeriodParameterName, element);
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull().zeroOrPositiveAmount();
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull()
|
||||
.zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
String maxInterestRatePerPeriodParameterName = "maxInterestRatePerPeriod";
|
||||
BigDecimal maxInterestRatePerPeriod = null;
|
||||
if (fromApiJsonHelper.parameterExists(maxInterestRatePerPeriodParameterName, element)) {
|
||||
maxInterestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(maxInterestRatePerPeriodParameterName, element);
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull().zeroOrPositiveAmount();
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull()
|
||||
.zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
if (maxInterestRatePerPeriod != null && maxInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) {
|
||||
if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) {
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).notLessThanMin(minInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod)
|
||||
.notLessThanMin(minInterestRatePerPeriod);
|
||||
if (minInterestRatePerPeriod.compareTo(maxInterestRatePerPeriod) <= 0) {
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod).inMinAndMaxAmountRange(minInterestRatePerPeriod, maxInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod)
|
||||
.inMinAndMaxAmountRange(minInterestRatePerPeriod, maxInterestRatePerPeriod);
|
||||
}
|
||||
} else {
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod).notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod)
|
||||
.notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
}
|
||||
} else if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) {
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod).notLessThanMin(minInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod)
|
||||
.notLessThanMin(minInterestRatePerPeriod);
|
||||
}
|
||||
|
||||
final Integer interestRateFrequencyType = fromApiJsonHelper.extractIntegerNamed("interestRateFrequencyType", element,
|
||||
@@ -324,33 +336,37 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
BigDecimal minInterestRatePerPeriod = null;
|
||||
if (fromApiJsonHelper.parameterExists(minInterestRatePerPeriodParameterName, element)) {
|
||||
minInterestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(minInterestRatePerPeriodParameterName, element);
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull().zeroOrPositiveAmount();
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull()
|
||||
.zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
String maxInterestRatePerPeriodParameterName = "maxInterestRatePerPeriod";
|
||||
BigDecimal maxInterestRatePerPeriod = null;
|
||||
if (fromApiJsonHelper.parameterExists(maxInterestRatePerPeriodParameterName, element)) {
|
||||
maxInterestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(maxInterestRatePerPeriodParameterName, element);
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull().zeroOrPositiveAmount();
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull()
|
||||
.zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("interestRatePerPeriod", element)) {
|
||||
final BigDecimal interestRatePerPeriod = fromApiJsonHelper.extractBigDecimalWithLocaleNamed("interestRatePerPeriod", element);
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod).notNull().zeroOrPositiveAmount();
|
||||
}
|
||||
|
||||
String minNumberOfRepaymentsParameterName = "minNumberOfRepayments";
|
||||
Integer minNumberOfRepayments = null;
|
||||
if (fromApiJsonHelper.parameterExists(minNumberOfRepaymentsParameterName, element)) {
|
||||
minNumberOfRepayments = fromApiJsonHelper.extractIntegerWithLocaleNamed(minNumberOfRepaymentsParameterName, element);
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull()
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
String maxNumberOfRepaymentsParameterName = "maxNumberOfRepayments";
|
||||
Integer maxNumberOfRepayments = null;
|
||||
if (fromApiJsonHelper.parameterExists(maxNumberOfRepaymentsParameterName, element)) {
|
||||
maxNumberOfRepayments = fromApiJsonHelper.extractIntegerWithLocaleNamed(maxNumberOfRepaymentsParameterName, element);
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).ignoreIfNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).ignoreIfNull()
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("numberOfRepayments", element)) {
|
||||
@@ -450,7 +466,8 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
public void validateMinMaxConstraints(final JsonElement element, final DataValidatorBuilder baseDataValidator, final LoanProduct loanProduct){
|
||||
public void validateMinMaxConstraints(final JsonElement element, final DataValidatorBuilder baseDataValidator,
|
||||
final LoanProduct loanProduct) {
|
||||
|
||||
validatePrincipalMinMaxConstraint(element, loanProduct, baseDataValidator);
|
||||
|
||||
@@ -459,7 +476,8 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
validateNominalInterestRatePerPeriodMinMaxConstraint(element, loanProduct, baseDataValidator);
|
||||
}
|
||||
|
||||
private void validatePrincipalMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct, final DataValidatorBuilder baseDataValidator) {
|
||||
private void validatePrincipalMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct,
|
||||
final DataValidatorBuilder baseDataValidator) {
|
||||
|
||||
boolean principalUpdated = false;
|
||||
boolean minPrincipalUpdated = false;
|
||||
@@ -501,19 +519,23 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
|
||||
if ((principalUpdated || minPrincipalUpdated || maxPrincipalUpdated)) {
|
||||
|
||||
if((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) && (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)){
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
|
||||
if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)
|
||||
&& (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)) {
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount)
|
||||
.inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
|
||||
} else {
|
||||
if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) {
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount);
|
||||
} else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) {
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notGreaterThanMax(maxPrincipalAmount);
|
||||
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount)
|
||||
.notGreaterThanMax(maxPrincipalAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateNumberOfRepaymentsMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct, final DataValidatorBuilder baseDataValidator) {
|
||||
private void validateNumberOfRepaymentsMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct,
|
||||
final DataValidatorBuilder baseDataValidator) {
|
||||
boolean numberOfRepaymentsUpdated = false;
|
||||
boolean minNumberOfRepaymentsUpdated = false;
|
||||
boolean maxNumberOfRepaymentsUpdated = false;
|
||||
@@ -546,27 +568,33 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
if (minNumberOfRepaymentsUpdated) {
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull().notGreaterThanMax(maxNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(minNumberOfRepaymentsParameterName).value(minNumberOfRepayments).ignoreIfNull()
|
||||
.notGreaterThanMax(maxNumberOfRepayments);
|
||||
}
|
||||
|
||||
if (maxNumberOfRepaymentsUpdated) {
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments).notLessThanMin(minNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments)
|
||||
.notLessThanMin(minNumberOfRepayments);
|
||||
}
|
||||
|
||||
if (numberOfRepaymentsUpdated || minNumberOfRepaymentsUpdated || maxNumberOfRepaymentsUpdated) {
|
||||
if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) {
|
||||
if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) {
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments).inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
|
||||
.inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
|
||||
} else {
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments).notGreaterThanMax(maxNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
|
||||
.notGreaterThanMax(maxNumberOfRepayments);
|
||||
}
|
||||
} else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) {
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments).notLessThanMin(minNumberOfRepayments);
|
||||
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
|
||||
.notLessThanMin(minNumberOfRepayments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateNominalInterestRatePerPeriodMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct, final DataValidatorBuilder baseDataValidator) {
|
||||
private void validateNominalInterestRatePerPeriodMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct,
|
||||
final DataValidatorBuilder baseDataValidator) {
|
||||
|
||||
boolean iRPUpdated = false;
|
||||
boolean minIRPUpdated = false;
|
||||
@@ -600,22 +628,27 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
if (minIRPUpdated) {
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull().notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(minInterestRatePerPeriodParameterName).value(minInterestRatePerPeriod).ignoreIfNull()
|
||||
.notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
}
|
||||
|
||||
if (maxIRPUpdated) {
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull().notLessThanMin(minInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod).ignoreIfNull()
|
||||
.notLessThanMin(minInterestRatePerPeriod);
|
||||
}
|
||||
|
||||
if (iRPUpdated || minIRPUpdated || maxIRPUpdated) {
|
||||
if (maxInterestRatePerPeriod != null) {
|
||||
if (minInterestRatePerPeriod != null) {
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).inMinAndMaxAmountRange(minInterestRatePerPeriod, maxInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod)
|
||||
.inMinAndMaxAmountRange(minInterestRatePerPeriod, maxInterestRatePerPeriod);
|
||||
} else {
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod)
|
||||
.notGreaterThanMax(maxInterestRatePerPeriod);
|
||||
}
|
||||
} else if (minInterestRatePerPeriod != null) {
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod).notLessThanMin(minInterestRatePerPeriod);
|
||||
baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod)
|
||||
.notLessThanMin(minInterestRatePerPeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user