FINERACT-378 and 379 : Can not link a Saving account to during Group Loan Application and Bluck JLG Loan application
This commit is contained in:
+9
@@ -22,6 +22,7 @@ public class PortfolioAccountDTO {
|
|||||||
|
|
||||||
private final Integer accountTypeId;
|
private final Integer accountTypeId;
|
||||||
private final Long clientId;
|
private final Long clientId;
|
||||||
|
private Long groupId;
|
||||||
private final String currencyCode;
|
private final String currencyCode;
|
||||||
private final long[] accountStatus;
|
private final long[] accountStatus;
|
||||||
private final Integer depositType;
|
private final Integer depositType;
|
||||||
@@ -79,5 +80,13 @@ public class PortfolioAccountDTO {
|
|||||||
public boolean isExcludeOverDraftAccounts() {
|
public boolean isExcludeOverDraftAccounts() {
|
||||||
return this.excludeOverDraftAccounts;
|
return this.excludeOverDraftAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getGroupId() {
|
||||||
|
return this.groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(final Long groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-7
@@ -104,8 +104,8 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
|
|||||||
@Override
|
@Override
|
||||||
public Collection<PortfolioAccountData> retrieveAllForLookup(final PortfolioAccountDTO portfolioAccountDTO) {
|
public Collection<PortfolioAccountData> retrieveAllForLookup(final PortfolioAccountDTO portfolioAccountDTO) {
|
||||||
|
|
||||||
List<Object> sqlParams = new ArrayList<>();
|
final List<Object> sqlParams = new ArrayList<>();
|
||||||
sqlParams.add(portfolioAccountDTO.getClientId());
|
//sqlParams.add(portfolioAccountDTO.getClientId());
|
||||||
Collection<PortfolioAccountData> accounts = null;
|
Collection<PortfolioAccountData> accounts = null;
|
||||||
String sql = null;
|
String sql = null;
|
||||||
String defaultAccountStatus = "300";
|
String defaultAccountStatus = "300";
|
||||||
@@ -120,8 +120,13 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
|
|||||||
case INVALID:
|
case INVALID:
|
||||||
break;
|
break;
|
||||||
case LOAN:
|
case LOAN:
|
||||||
sql = "select " + this.loanAccountMapper.schema() + " where la.client_id = ? and la.loan_status_id in ("
|
sql = "select " + this.loanAccountMapper.schema() + " where ";
|
||||||
+ defaultAccountStatus.toString() + ")";
|
if (portfolioAccountDTO.getClientId() != null) {
|
||||||
|
sql += " la.client_id = ? and la.loan_status_id in (" + defaultAccountStatus.toString() + ") ";
|
||||||
|
sqlParams.add(portfolioAccountDTO.getClientId());
|
||||||
|
} else {
|
||||||
|
sql += " la.loan_status_id in (" + defaultAccountStatus.toString() + ") ";
|
||||||
|
}
|
||||||
if (portfolioAccountDTO.getCurrencyCode() != null) {
|
if (portfolioAccountDTO.getCurrencyCode() != null) {
|
||||||
sql += " and la.currency_code = ?";
|
sql += " and la.currency_code = ?";
|
||||||
sqlParams.add(portfolioAccountDTO.getCurrencyCode());
|
sqlParams.add(portfolioAccountDTO.getCurrencyCode());
|
||||||
@@ -130,8 +135,13 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
|
|||||||
accounts = this.jdbcTemplate.query(sql, this.loanAccountMapper, sqlParams.toArray());
|
accounts = this.jdbcTemplate.query(sql, this.loanAccountMapper, sqlParams.toArray());
|
||||||
break;
|
break;
|
||||||
case SAVINGS:
|
case SAVINGS:
|
||||||
sql = "select " + this.savingsAccountMapper.schema() + " where sa.client_id = ? and sa.status_enum in ("
|
sql = "select " + this.savingsAccountMapper.schema() + " where ";
|
||||||
+ defaultAccountStatus.toString() + ")";
|
if (portfolioAccountDTO.getClientId() != null) {
|
||||||
|
sql += " sa.client_id = ? and sa.status_enum in (" + defaultAccountStatus.toString() + ") ";
|
||||||
|
sqlParams.add(portfolioAccountDTO.getClientId());
|
||||||
|
} else {
|
||||||
|
sql += " sa.status_enum in (" + defaultAccountStatus.toString() + ") ";
|
||||||
|
}
|
||||||
if (portfolioAccountDTO.getCurrencyCode() != null) {
|
if (portfolioAccountDTO.getCurrencyCode() != null) {
|
||||||
sql += " and sa.currency_code = ?";
|
sql += " and sa.currency_code = ?";
|
||||||
sqlParams.add(portfolioAccountDTO.getCurrencyCode());
|
sqlParams.add(portfolioAccountDTO.getCurrencyCode());
|
||||||
@@ -145,7 +155,12 @@ public class PortfolioAccountReadPlatformServiceImpl implements PortfolioAccount
|
|||||||
if(portfolioAccountDTO.isExcludeOverDraftAccounts()){
|
if(portfolioAccountDTO.isExcludeOverDraftAccounts()){
|
||||||
sql += " and sa.allow_overdraft = 0";
|
sql += " and sa.allow_overdraft = 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(portfolioAccountDTO.getClientId() == null && portfolioAccountDTO.getGroupId() != null){
|
||||||
|
sql += " and sa.group_id = ? ";
|
||||||
|
sqlParams.add(portfolioAccountDTO.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
accounts = this.jdbcTemplate.query(sql, this.savingsAccountMapper, sqlParams.toArray());
|
accounts = this.jdbcTemplate.query(sql, this.savingsAccountMapper, sqlParams.toArray());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
+21
-11
@@ -267,6 +267,7 @@ public class LoansApiResource {
|
|||||||
Collection<CalendarData> calendarOptions = null;
|
Collection<CalendarData> calendarOptions = null;
|
||||||
LoanAccountData newLoanAccount = null;
|
LoanAccountData newLoanAccount = null;
|
||||||
Long officeId = null;
|
Long officeId = null;
|
||||||
|
Collection<PortfolioAccountData> accountLinkingOptions = null;
|
||||||
|
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
newLoanAccount = this.loanReadPlatformService.retrieveLoanProductDetailsTemplate(productId, clientId, groupId);
|
newLoanAccount = this.loanReadPlatformService.retrieveLoanProductDetailsTemplate(productId, clientId, groupId);
|
||||||
@@ -306,6 +307,7 @@ public class LoansApiResource {
|
|||||||
calendarOptions = this.loanReadPlatformService.retrieveCalendars(groupId);
|
calendarOptions = this.loanReadPlatformService.retrieveCalendars(groupId);
|
||||||
newLoanAccount = newLoanAccount == null ? loanAccountGroupData : LoanAccountData.populateGroupDefaults(newLoanAccount,
|
newLoanAccount = newLoanAccount == null ? loanAccountGroupData : LoanAccountData.populateGroupDefaults(newLoanAccount,
|
||||||
loanAccountGroupData);
|
loanAccountGroupData);
|
||||||
|
accountLinkingOptions = getaccountLinkingOptions(newLoanAccount, clientId, groupId);
|
||||||
|
|
||||||
} else if (templateType.equals("jlgbulk")) {
|
} else if (templateType.equals("jlgbulk")) {
|
||||||
// get group details along with members in that group
|
// get group details along with members in that group
|
||||||
@@ -317,9 +319,11 @@ public class LoansApiResource {
|
|||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
Map<Long, Integer> memberLoanCycle = new HashMap<>();
|
Map<Long, Integer> memberLoanCycle = new HashMap<>();
|
||||||
Collection<ClientData> members = loanAccountGroupData.groupData().clientMembers();
|
Collection<ClientData> members = loanAccountGroupData.groupData().clientMembers();
|
||||||
|
accountLinkingOptions = new ArrayList<>();
|
||||||
for (ClientData clientData : members) {
|
for (ClientData clientData : members) {
|
||||||
Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(), productId);
|
Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(), productId);
|
||||||
memberLoanCycle.put(clientData.id(), loanCounter);
|
memberLoanCycle.put(clientData.id(), loanCounter);
|
||||||
|
accountLinkingOptions.addAll(getaccountLinkingOptions(newLoanAccount, clientData.id(), groupId));
|
||||||
}
|
}
|
||||||
newLoanAccount = LoanAccountData.associateMemberVariations(newLoanAccount, memberLoanCycle);
|
newLoanAccount = LoanAccountData.associateMemberVariations(newLoanAccount, memberLoanCycle);
|
||||||
}
|
}
|
||||||
@@ -331,18 +335,8 @@ public class LoansApiResource {
|
|||||||
|
|
||||||
allowedLoanOfficers = this.loanReadPlatformService.retrieveAllowedLoanOfficers(officeId, staffInSelectedOfficeOnly);
|
allowedLoanOfficers = this.loanReadPlatformService.retrieveAllowedLoanOfficers(officeId, staffInSelectedOfficeOnly);
|
||||||
|
|
||||||
Collection<PortfolioAccountData> accountLinkingOptions = null;
|
|
||||||
if (clientId != null) {
|
if (clientId != null) {
|
||||||
final CurrencyData currencyData = newLoanAccount.currency();
|
accountLinkingOptions = getaccountLinkingOptions(newLoanAccount, clientId, groupId);
|
||||||
String currencyCode = null;
|
|
||||||
if (currencyData != null) {
|
|
||||||
currencyCode = currencyData.code();
|
|
||||||
}
|
|
||||||
final long[] accountStatus = { SavingsAccountStatusType.ACTIVE.getValue() };
|
|
||||||
PortfolioAccountDTO portfolioAccountDTO = new PortfolioAccountDTO(PortfolioAccountType.SAVINGS.getValue(), clientId,
|
|
||||||
currencyCode, accountStatus, DepositAccountType.SAVINGS_DEPOSIT.getValue());
|
|
||||||
accountLinkingOptions = this.portfolioAccountReadPlatformService.retrieveAllForLookup(portfolioAccountDTO);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add product options, allowed loan officers and calendar options
|
// add product options, allowed loan officers and calendar options
|
||||||
@@ -358,6 +352,22 @@ public class LoansApiResource {
|
|||||||
return this.toApiJsonSerializer.serialize(settings, newLoanAccount, this.LOAN_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, newLoanAccount, this.LOAN_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Collection<PortfolioAccountData> getaccountLinkingOptions(final LoanAccountData newLoanAccount, final Long clientId,
|
||||||
|
final Long groupId) {
|
||||||
|
final CurrencyData currencyData = newLoanAccount.currency();
|
||||||
|
String currencyCode = null;
|
||||||
|
if (currencyData != null) {
|
||||||
|
currencyCode = currencyData.code();
|
||||||
|
}
|
||||||
|
final long[] accountStatus = { SavingsAccountStatusType.ACTIVE.getValue() };
|
||||||
|
final PortfolioAccountDTO portfolioAccountDTO = new PortfolioAccountDTO(PortfolioAccountType.SAVINGS.getValue(), clientId, currencyCode,
|
||||||
|
accountStatus, DepositAccountType.SAVINGS_DEPOSIT.getValue());
|
||||||
|
if (groupId != null) {
|
||||||
|
portfolioAccountDTO.setGroupId(groupId);
|
||||||
|
}
|
||||||
|
return this.portfolioAccountReadPlatformService.retrieveAllForLookup(portfolioAccountDTO);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{loanId}")
|
@Path("{loanId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
|||||||
Reference in New Issue
Block a user