thesmallstar commented on a change in pull request #1770:
URL: https://github.com/apache/fineract/pull/1770#discussion_r698035158
##########
File path:
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
##########
@@ -414,38 +422,93 @@ public void validateForCreate(final String json, final
boolean isMeetingMandator
}
}
- // 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();
+ // // 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 description =
this.fromApiJsonHelper.extractStringNamed("description", collateralItemElement);
+ //
baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("description",
+ // i).value(description).notBlank()
+ // .notExceedingLengthOf(500);
+ //
+ // }
+ // } else {
+ //
baseDataValidator.reset().parameter(collateralParameterName).expectedArrayButIsNot();
+ // }
+ // }
- final BigDecimal collateralValue =
this.fromApiJsonHelper.extractBigDecimalNamed("value", collateralItemElement,
- locale);
-
baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("value",
i).value(collateralValue)
- .ignoreIfNull().positiveAmount();
+ /**
+ * TODO: Add collaterals for group loan accounts. FOr now it's only
applicable for individual accounts.
+ * (loanType.isJLG() || loanType.isGLIM())
+ */
Review comment:
?
--
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]