From 37b61d156cc53b6505544cbaff84c039cb981777 Mon Sep 17 00:00:00 2001 From: ShruthiRajaram Date: Wed, 19 Dec 2018 18:38:25 +0530 Subject: [PATCH] FINERACT-671 loan charge specific due date fix --- .../fineract/portfolio/loanaccount/domain/LoanCharge.java | 5 +++++ .../loanaccount/serialization/LoanEventApiJsonValidator.java | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java index 8c82ebf095f..780057915f1 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java @@ -134,6 +134,11 @@ public class LoanCharge extends AbstractPersistableCustom { public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) { final LocalDate dueDate = command.localDateValueOfParameterNamed("dueDate"); + if (dueDate == null) { + final String defaultUserMessage = "Loan charge is missing due date."; + throw new LoanChargeWithoutMandatoryFieldException("loanCharge", "dueDate", defaultUserMessage, chargeDefinition.getId(), + chargeDefinition.getName()); + } return createNewFromJson(loan, chargeDefinition, command, dueDate); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java index d28413033fc..3f70aec4a48 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java @@ -248,7 +248,8 @@ public void validateAddLoanCharge(final String json) { baseDataValidator.reset().parameter("amount").value(amount).notNull().positiveAmount(); if (this.fromApiJsonHelper.parameterExists("dueDate", element)) { - this.fromApiJsonHelper.extractLocalDateNamed("dueDate", element); + final LocalDate dueDate = this.fromApiJsonHelper.extractLocalDateNamed("dueDate", element); + baseDataValidator.reset().parameter("dueDate").value(dueDate).notBlank(); } throwExceptionIfValidationWarningsExist(dataValidationErrors);