Merge pull request #802 from pramodn02/MIFOSX-994

MIFOSX-994 - removed the constrain for overdraft account
This commit is contained in:
Vishwas Babu A J
2014-03-17 20:30:33 -07:00
5 changed files with 14 additions and 19 deletions
@@ -140,7 +140,7 @@ public class ClientsApiResource {
staffInSelectedOfficeOnly);
clientData = ClientData.templateOnTop(clientData, templateData);
Collection<SavingsAccountData> savingAccountOptions = this.savingsAccountReadPlatformService.retrieveForLookup(
clientId, true);
clientId, null);
if (savingAccountOptions != null && savingAccountOptions.size() > 0) {
clientData = ClientData.templateWithSavingAccountOptions(clientData, savingAccountOptions);
}
@@ -80,7 +80,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final Collection<OfficeData> offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
final Collection<SavingsProductData> savingsProductDatas = this.savingsProductReadPlatformService.retrieveAllForLookupByType(true);
final Collection<SavingsProductData> savingsProductDatas = this.savingsProductReadPlatformService.retrieveAllForLookupByType(null);
Collection<StaffData> staffOptions = null;
@@ -209,7 +209,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
CommandProcessingResult result = openOverdraftSavingsAccount(newClient, fmt);
CommandProcessingResult result = openSavingsAccount(newClient, fmt);
if (result.getSavingsId() != null) {
this.clientRepository.save(newClient);
}
@@ -298,7 +298,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
final AppUser currentUser = this.context.authenticatedUser();
client.activate(currentUser, fmt, activationDate);
CommandProcessingResult result = openOverdraftSavingsAccount(client, fmt);
CommandProcessingResult result = openSavingsAccount(client, fmt);
this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() //
@@ -315,20 +315,16 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
}
}
private CommandProcessingResult openOverdraftSavingsAccount(final Client client, final DateTimeFormatter fmt) {
private CommandProcessingResult openSavingsAccount(final Client client, final DateTimeFormatter fmt) {
CommandProcessingResult commandProcessingResult = CommandProcessingResult.empty();
if (client.isActive() && client.SavingsProduct() != null) {
if (!client.SavingsProduct().isAllowOverdraft()) {
String defaultUserMessage = "Client's saving account must be a overdraft account";
throw new InvalidClientSavingProductException("saving.product", "must.be.ovrdraft.account", defaultUserMessage, client
.SavingsProduct().getId(), client.getId());
}
SavingsAccountDataDTO savingsAccountDataDTO = new SavingsAccountDataDTO(client, null, client.SavingsProduct(),
client.getActivationLocalDate(), client.activatedBy(), fmt);
commandProcessingResult = this.savingsApplicationProcessWritePlatformService.createActiveApplication(savingsAccountDataDTO);
if (commandProcessingResult.getSavingsId() != null) {
SavingsAccount savingsAccount = this.savingsRepository.findOne(commandProcessingResult.getSavingsId());
client.updateSavingsAccount(savingsAccount);
client.updateSavingsProduct(null);
}
}
return commandProcessingResult;
@@ -505,11 +501,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientSavingProductException("saving.account", "must.belongs.to.client", defaultUserMessage, savingsId,
clientForUpdate.getId());
}
if (!savingsAccount.allowOverdraft()) {
String defaultUserMessage = "Client's saving account must be a overdraft account";
throw new InvalidClientSavingProductException("saving.account", "must.be.ovrdraft.account", defaultUserMessage, savingsId,
clientForUpdate.getId());
}
clientForUpdate.updateSavingsAccount(savingsAccount);
}
@@ -15,7 +15,7 @@ public interface SavingsProductReadPlatformService {
Collection<SavingsProductData> retrieveAllForLookup();
Collection<SavingsProductData> retrieveAllForLookupByType(boolean isOverdraftType);
Collection<SavingsProductData> retrieveAllForLookupByType(Boolean isOverdraftType);
SavingsProductData retrieveOne(Long productId);
@@ -201,10 +201,14 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
}
@Override
public Collection<SavingsProductData> retrieveAllForLookupByType(boolean isOverdraftType) {
final String sql = "select " + this.savingsProductLookupsRowMapper.schema() + " where sp.allow_overdraft=?";
public Collection<SavingsProductData> retrieveAllForLookupByType(Boolean isOverdraftType) {
String sql = "select " + this.savingsProductLookupsRowMapper.schema();
if(isOverdraftType != null){
sql += " where sp.allow_overdraft=?";
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, isOverdraftType);
}
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, isOverdraftType);
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper);
}
}