josehernandezfintecheandomx commented on code in PR #2614:
URL: https://github.com/apache/fineract/pull/2614#discussion_r984577047
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java:
##########
@@ -212,7 +212,39 @@ public void validateTransaction(final String json) {
baseDataValidator.reset().parameter(LoanApiConstants.REVERSAL_EXTERNAL_ID_PARAMNAME).ignoreIfNull().value(reversalExternalId)
.notExceedingLengthOf(100);
- validatePaymentDetails(baseDataValidator, element);
+ validatePaymentDetails(baseDataValidator, element, false);
+ throwExceptionIfValidationWarningsExist(dataValidationErrors);
+ }
+
+ public void validateChargebackTransaction(final String json) {
+
+ if (StringUtils.isBlank(json)) {
+ throw new InvalidJsonException();
+ }
+
+ final Set<String> transactionParameters = new
HashSet<>(Arrays.asList("transactionAmount", "externalId", "note", "locale",
+ "dateFormat", "paymentTypeId",
LoanApiConstants.REVERSAL_EXTERNAL_ID_PARAMNAME));
+
+ final Type typeOfMap = new TypeToken<Map<String, Object>>()
{}.getType();
+ this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json,
transactionParameters);
+
+ final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
+ final DataValidatorBuilder baseDataValidator = new
DataValidatorBuilder(dataValidationErrors).resource("loan.transaction");
+
+ final JsonElement element = this.fromApiJsonHelper.parse(json);
+
+ final BigDecimal transactionAmount =
this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("transactionAmount",
element);
+
baseDataValidator.reset().parameter("transactionAmount").value(transactionAmount).notNull().zeroOrPositiveAmount();
+
+ final String note = this.fromApiJsonHelper.extractStringNamed("note",
element);
+
baseDataValidator.reset().parameter("note").value(note).notExceedingLengthOf(1000);
+
+ final String reversalExternalId =
this.fromApiJsonHelper.extractStringNamed(LoanApiConstants.REVERSAL_EXTERNAL_ID_PARAMNAME,
Review Comment:
Done
--
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]