cleaning up PR for MIFOSX-709
This commit is contained in:
+4
-17
@@ -186,8 +186,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
CodeValue gender = null;
|
CodeValue gender = null;
|
||||||
final Long genderId = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName);
|
final Long genderId = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName);
|
||||||
if (genderId != null) {
|
if (genderId != null) {
|
||||||
gender = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.GENDER,
|
gender = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.GENDER, genderId);
|
||||||
genderId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SavingsProduct savingsProduct = null;
|
SavingsProduct savingsProduct = null;
|
||||||
@@ -443,34 +442,22 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
|
|
||||||
for (final Loan loan : clientLoans) {
|
for (final Loan loan : clientLoans) {
|
||||||
final LoanStatusMapper loanStatus = new LoanStatusMapper(loan.status().getValue());
|
final LoanStatusMapper loanStatus = new LoanStatusMapper(loan.status().getValue());
|
||||||
if (loanStatus.isOpen()) {
|
if (loanStatus.isOpen() || loanStatus.isPendingApproval() || loanStatus.isAwaitingDisbursal()) {
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed loans.";
|
final String errorMessage = "Client cannot be closed because of non-closed loans.";
|
||||||
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
|
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
|
||||||
} else if (loanStatus.isClosed() && loan.getClosedOnDate().after(closureDate.toDate())) {
|
} else if (loanStatus.isClosed() && loan.getClosedOnDate().after(closureDate.toDate())) {
|
||||||
final String errorMessage = "The client closureDate cannot be before the loan closedOnDate.";
|
final String errorMessage = "The client closureDate cannot be before the loan closedOnDate.";
|
||||||
throw new InvalidClientStateTransitionException("close", "date.cannot.before.loan.closed.date", errorMessage,
|
throw new InvalidClientStateTransitionException("close", "date.cannot.before.loan.closed.date", errorMessage,
|
||||||
closureDate, loan.getClosedOnDate());
|
closureDate, loan.getClosedOnDate());
|
||||||
} else if (loanStatus.isPendingApproval()) {
|
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed loans.";
|
|
||||||
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
|
|
||||||
} else if (loanStatus.isAwaitingDisbursal()) {
|
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed loans.";
|
|
||||||
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
|
|
||||||
} else if (loanStatus.isOverpaid()) {
|
} else if (loanStatus.isOverpaid()) {
|
||||||
final String errorMessage = "Client cannot be closed because of overpaid loans.";
|
final String errorMessage = "Client cannot be closed because of overpaid loans.";
|
||||||
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
|
throw new InvalidClientStateTransitionException("close", "loan.overpaid", errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final List<SavingsAccount> clientSavingAccounts = this.savingsRepository.findSavingAccountByClientId(clientId);
|
final List<SavingsAccount> clientSavingAccounts = this.savingsRepository.findSavingAccountByClientId(clientId);
|
||||||
|
|
||||||
for (final SavingsAccount saving : clientSavingAccounts) {
|
for (final SavingsAccount saving : clientSavingAccounts) {
|
||||||
if (saving.isActive()) {
|
if (saving.isActive() || saving.isSubmittedAndPendingApproval() || saving.isApproved()) {
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed savings account.";
|
|
||||||
throw new InvalidClientStateTransitionException("close", "non-closed.savings.account", errorMessage);
|
|
||||||
} else if (saving.isSubmittedAndPendingApproval()) {
|
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed savings account.";
|
|
||||||
throw new InvalidClientStateTransitionException("close", "non-closed.savings.account", errorMessage);
|
|
||||||
} else if (saving.isApproved()) {
|
|
||||||
final String errorMessage = "Client cannot be closed because of non-closed savings account.";
|
final String errorMessage = "Client cannot be closed because of non-closed savings account.";
|
||||||
throw new InvalidClientStateTransitionException("close", "non-closed.savings.account", errorMessage);
|
throw new InvalidClientStateTransitionException("close", "non-closed.savings.account", errorMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user