Merge pull request #909 from erikbarbara/MIFOSX-709

MIFOSX-709: adding functionality to prevent closing of client with overd...
This commit is contained in:
Vishwas Babu A J
2014-05-15 12:33:17 +05:30
2 changed files with 8 additions and 1 deletions
@@ -426,7 +426,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
ClientApiConstants.CLIENT_CLOSURE_REASON, closureReasonId);
if (ClientStatus.fromInt(client.getStatus()).isClosed()) {
final String errorMessage = "Client is alread closed.";
final String errorMessage = "Client is already closed.";
throw new InvalidClientStateTransitionException("close", "is.already.closed", errorMessage);
} else if (ClientStatus.fromInt(client.getStatus()).isUnderTransfer()) {
final String errorMessage = "Cannot Close a Client under Transfer";
@@ -456,6 +456,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
} 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()) {
final String errorMessage = "Client cannot be closed because of overpaid loans.";
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
}
}
final List<SavingsAccount> clientSavingAccounts = this.savingsRepository.findSavingAccountByClientId(clientId);
@@ -36,4 +36,8 @@ public class LoanStatusMapper {
public boolean isClosed() {
return Integer.valueOf(600).equals(this.statusId) || isWithdrawnByClient() || isRejected();
}
public boolean isOverpaid() {
return Integer.valueOf(700).equals(this.statusId);
}
}