diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index 9266d5a02..20249b26f 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -1477,10 +1477,14 @@ public class Loan extends AbstractPersistable { } } - private boolean isInterestRecalculationEnabledForProduct() { + public boolean isInterestRecalculationEnabledForProduct() { return this.loanProduct.isInterestRecalculationEnabled(); } + public boolean isMultiDisburmentLoan() { + return this.loanProduct.isMultiDisburseLoan() ; + } + /** * Update interest recalculation settings if product configuration changes */ diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/RescheduleLoansApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/RescheduleLoansApiConstants.java index e0ca48b39..5ccc0b729 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/RescheduleLoansApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/RescheduleLoansApiConstants.java @@ -31,7 +31,9 @@ public class RescheduleLoansApiConstants { public static final String rescheduleReasonCommentParamName = "rescheduleReasonComment"; public static final String submittedOnDateParamName = "submittedOnDate"; public static final String adjustedDueDateParamName = "adjustedDueDate"; - + public static final String resheduleForMultiDisbursementNotSupportedErrorCode = "loan.reschedule.multidisbursement.error.code"; + public static final String resheduleWithInterestRecalculationNotSupportedErrorCode = "loan.reschedule.interestrecalculation.error.code"; + public static final Set CREATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName, dateFormatParamName, graceOnPrincipalParamName, graceOnInterestParamName, extraTermsParamName, rescheduleFromDateParamName, newInterestRateParamName, rescheduleReasonIdParamName, rescheduleReasonCommentParamName, submittedOnDateParamName, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java index 58320adf3..34b9b81d9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java @@ -161,7 +161,16 @@ public class LoanRescheduleRequestDataValidator { "The loan can only be rescheduled once."); } } - + if(loan.isMultiDisburmentLoan()) { + dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(RescheduleLoansApiConstants.resheduleForMultiDisbursementNotSupportedErrorCode, + "Loan rescheduling is not supported for multidisbursement loans"); + } + + if(loan.isInterestRecalculationEnabledForProduct()) { + dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(RescheduleLoansApiConstants.resheduleWithInterestRecalculationNotSupportedErrorCode, + "Loan rescheduling is not supported for the loan product with interest recalculation enabled"); + } + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } }