BLasan commented on a change in pull request #1770:
URL: https://github.com/apache/fineract/pull/1770#discussion_r701823521
##########
File path:
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
##########
@@ -847,38 +910,67 @@ public void validateForModify(final String json, final
LoanProduct loanProduct,
}
}
- // collateral
- final String collateralParameterName = "collateral";
- if (element.isJsonObject() &&
this.fromApiJsonHelper.parameterExists(collateralParameterName, element)) {
- final JsonObject topLevelJsonElement = element.getAsJsonObject();
- final Locale locale =
this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
- if (topLevelJsonElement.get("collateral").isJsonArray()) {
-
- final Type collateralParameterTypeOfMap = new
TypeToken<Map<String, Object>>() {}.getType();
- final Set<String> supportedParameters = new
HashSet<>(Arrays.asList("id", "type", "value", "description"));
- final JsonArray array =
topLevelJsonElement.get("collateral").getAsJsonArray();
- for (int i = 1; i <= array.size(); i++) {
- final JsonObject collateralItemElement = array.get(i -
1).getAsJsonObject();
-
- final String collateralJson =
this.fromApiJsonHelper.toJson(collateralItemElement);
-
this.fromApiJsonHelper.checkForUnsupportedParameters(collateralParameterTypeOfMap,
collateralJson, supportedParameters);
-
- final Long collateralTypeId =
this.fromApiJsonHelper.extractLongNamed("type", collateralItemElement);
-
baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("type",
i).value(collateralTypeId).notNull()
- .integerGreaterThanZero();
-
- final BigDecimal collateralValue =
this.fromApiJsonHelper.extractBigDecimalNamed("value", collateralItemElement,
- locale);
-
baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("value",
i).value(collateralValue)
- .ignoreIfNull().positiveAmount();
+ final String loanTypeParameterName = "loanType";
+ final String loanTypeStr =
this.fromApiJsonHelper.extractStringNamed(loanTypeParameterName, element);
+
baseDataValidator.reset().parameter(loanTypeParameterName).value(loanTypeStr).notNull();
- final String description =
this.fromApiJsonHelper.extractStringNamed("description", collateralItemElement);
-
baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("description",
i).value(description).notBlank()
- .notExceedingLengthOf(500);
+ if (!StringUtils.isBlank(loanTypeStr)) {
+ final AccountType loanType = AccountType.fromName(loanTypeStr);
+
baseDataValidator.reset().parameter(loanTypeParameterName).value(loanType.getValue()).inMinMaxRange(1,
4);
+ /**
+ * TODO: Allow for other loan account types.
Review comment:
Removed unwanted comments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]