"Loan reschedule request approval is not allowed. "
+ "Loan reschedule request is not in submitted and pending approval state.");
}
LocalDate rescheduleFromDate = loanRescheduleRequest.getRescheduleFromDate();
final Loan loan = loanRescheduleRequest.getLoan();
if (loan != null) {
Long loanId = loan.getId();
if (!loan.status().isActive()) {
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode("loan.is.not.active", "Loan is not active");
}
if (rescheduleFromDate != null) {
LoanRepaymentScheduleInstallment installment = loan.getRepaymentScheduleInstallment(rescheduleFromDate);
if (installment == null) {
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(
"loan.repayment.schedule.installment.does.not.exist", "Repayment schedule installment does not exist");
}
if (installment != null && installment.isObligationsMet()) {
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(
"loan.repayment.schedule.installment." + "obligation.met", "Repayment schedule installment obligation met");
}
if (installment != null) {
if (installment.getPenaltyChargesOutstanding(loan.getCurrency()).isGreaterThanZero()) {
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(
"repayment.schedule.installment.has.an.outstanding.penalty.charge",
"Repayment schedule installment has an outsatnding penalty charge.");
}
if (installment.getFeeChargesOutstanding(loan.getCurrency()).isGreaterThanZero()) {
dataValidatorBuilder.reset().failWithCodeNoParameterAddedToErrorCode(
"repayment.schedule.installment.has.an.outstanding.fee.charge",
"Repayment schedule installment has an outsatnding fee charge.");
}
}