MIFOSX-1842 Adding validation for add/delete tranche based on loan status.

This commit is contained in:
Chandrika
2015-04-14 13:44:50 -04:00
parent 5f888ca2f2
commit d45b3a504e
2 changed files with 4 additions and 3 deletions
@@ -885,7 +885,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
loan.regenerateRepaymentSchedule(scheduleGeneratorDTO, currentUser);
}
this.loanRepository.save(loan);
saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) {
@@ -2612,8 +2612,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String errorMessage = "loan.product.does.not.support.multiple.disbursals";
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
}
if(loan.isSubmittedAndPendingApproval()){
final String errorMessage = "loan.account.should.be.approved";
if(loan.isSubmittedAndPendingApproval() || loan.isClosed() || loan.isClosedWrittenOff() || loan.status().isClosedObligationsMet() ||
loan.status().isOverpaid()){
final String errorMessage = "cannot.modify.tranches.if.loan.is.pendingapproval.closed.overpaid.writtenoff";
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
}
validateMultiDisbursementData(command, expectedDisbursementDate);