Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBR-710 #1000

Merged
merged 1 commit into from
Aug 8, 2024
Merged

FBR-710 #1000

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static SearchParameters forBlacklist(final String displayName, final Stri

public static SearchParameters forPrequalification(final String displayName, final String status, final Integer offset,
final Integer limit, final String orderBy, final String sortOrder, final String type, String searchText,
final String groupingType, Long portfolioCenterId) {
final String groupingType, Long portfolioCenterId, Long agencyId) {

final Integer maxLimitAllowed = getCheckedLimit(limit);
final Long staffId = null;
Expand All @@ -139,7 +139,7 @@ public static SearchParameters forPrequalification(final String displayName, fin

return new SearchParameters(searchText, null, null, displayName, null, null, null, status, offset, maxLimitAllowed, orderBy,
sortOrder, staffId, accountNo, loanId, savingsId, null, false, null, type, null, null, null, groupingType,
portfolioCenterId);
portfolioCenterId,agencyId);
}

public static SearchParameters forBankCheques(final Long agencyId, final String chequeNo, final String bankAccNo, final Long batchId,
Expand Down Expand Up @@ -622,7 +622,7 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
final Integer limit, final String orderBy, final String sortOrder, final Long staffId, final String accountNo,
final Long loanId, final Long savingsId, final Boolean orphansOnly, boolean isSelfUser, final String dpiNumber,
final String type, final String groupName, final String groupNumber, final String centerName, final String groupingType,
Long portfolioCenterId) {
Long portfolioCenterId, Long agencyId) {
this.sqlSearch = sqlSearch;
this.officeId = officeId;
this.externalId = externalId;
Expand Down Expand Up @@ -659,7 +659,7 @@ private SearchParameters(final String sqlSearch, final Long officeId, final Stri
this.disbursementStartDate = null;
this.approvalEndDate = null;
this.approvalStartDate = null;
this.agencyId = null;
this.agencyId = agencyId;
this.clientNo = null;
this.groupId = null;
this.centerId = portfolioCenterId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public String retrieveAllBlacklistItems(@Context final UriInfo uriInfo,
@QueryParam("limit") @Parameter(description = "limit") final Integer limit,
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("status") @Parameter(description = "status") final String status,
@QueryParam("agencyId") @Parameter(description = "agencyId") final Long agencyId,
@QueryParam("type") @Parameter(description = "type") final String type,
@QueryParam("portfolioCenterId") @Parameter(description = "type") final Long portfolioCenterId,
@QueryParam("searchText") @Parameter(description = "searchText") final String searchText,
Expand All @@ -157,7 +158,7 @@ public String retrieveAllBlacklistItems(@Context final UriInfo uriInfo,

String clientName = queryParameters.getFirst("clientName");
SearchParameters searchParameters = SearchParameters.forPrequalification(clientName, status, offset, limit, orderBy, sortOrder,
type, searchText, groupingType, portfolioCenterId);
type, searchText, groupingType, portfolioCenterId, agencyId);
final Page<GroupPrequalificationData> clientData = this.prequalificationReadPlatformService.retrieveAll(searchParameters);

final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(queryParameters);
Expand All @@ -174,6 +175,7 @@ public String retrieveAllBlacklistItems(@Context final UriInfo uriInfo,
public String newClientIdentifierDetails(@Context final UriInfo uriInfo) {

this.context.authenticatedUser().validateHasViewPermission(this.resourceNameForPermissions);
final String hierarchy = this.context.authenticatedUser().getOffice().getHierarchy();

MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();

Expand All @@ -183,7 +185,7 @@ public String newClientIdentifierDetails(@Context final UriInfo uriInfo) {
Long agencyId = null;
Long centerId = null;
Collection<CenterData> centerData = null;
Collection<AgencyData> agencies = null;
Collection<AgencyData> agencies = this.agencyReadPlatformService.retrieveByOfficeHierarchy(hierarchy);
Collection<AppUserData> appUsers = null;
Collection<LoanProductData> loanProducts = null;
GlobalConfigurationPropertyData timespan = null;
Expand Down Expand Up @@ -226,7 +228,6 @@ public String newClientIdentifierDetails(@Context final UriInfo uriInfo) {
}
}

final String hierarchy = this.context.authenticatedUser().getOffice().getHierarchy();
centerData = this.centerReadPlatformService.retrieveByOfficeHierarchy(hierarchy, agencyId);
agencies = this.agencyReadPlatformService.retrieveAllByAgencyLeader();
if (agencies.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public String retrieveAllBlacklistItems(@Context final UriInfo uriInfo,

String clientName = queryParameters.getFirst("clientName");
SearchParameters searchParameters = SearchParameters.forPrequalification(clientName, status, offset, limit, orderBy, sortOrder,
type, searchText, groupingType, portfolioCenterId);
type, searchText, groupingType, portfolioCenterId,null);
final Page<MemberPrequalificationData> memberData = this.prequalificationReadPlatformService.retrieveAllMembers(searchParameters);

final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(queryParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ private String buildSqlStringFromBlacklistCriteria(final SearchParameters search
String sqlSearch = searchParameters.getSqlSearch();
final Long officeId = searchParameters.getOfficeId();
final Long centerId = searchParameters.getCenterId();
final Long agencyId = searchParameters.getAgencyId();
final String dpiNumber = searchParameters.getName();
final String status = searchParameters.getStatus();
final String type = searchParameters.getType();
Expand All @@ -298,12 +299,6 @@ private String buildSqlStringFromBlacklistCriteria(final SearchParameters search
paramList.add(appUser.getId());
}
}

// add hierrachy filter here.
extraCriteria += " and (mo.hierarchy LIKE CONCAT(?, '%') OR ? like CONCAT(mo.hierarchy, '%'))";
paramList.add(appUser.getOffice().getHierarchy());
paramList.add(appUser.getOffice().getHierarchy());

}

if (StringUtils.equals(groupingType, "individual")) {
Expand All @@ -314,6 +309,14 @@ private String buildSqlStringFromBlacklistCriteria(final SearchParameters search
paramList.add(dpiNumber);
}
}
extraCriteria += " and (moind.hierarchy LIKE CONCAT(?, '%') OR ? like CONCAT(moind.hierarchy, '%'))";
paramList.add(appUser.getOffice().getHierarchy());
paramList.add(appUser.getOffice().getHierarchy());

if (agencyId != null) {
extraCriteria += " and individualOffice.agency_id = ? ";
paramList.add(agencyId);
}
}

if (sqlSearch != null && !isGroup) {
Expand Down Expand Up @@ -457,12 +460,25 @@ LEFT JOIN (
FROM m_prequalification_group_members mpgm
GROUP BY mpgm.group_id
) prequalification_numbers ON prequalification_numbers.prequalification_id = g.id
LEFT JOIN(
select DISTINCT mc.office_id, ms.agency_id, mpgm.group_id, ms.linked_office_id as supervision_office
from m_prequalification_group_members mpgm
INNER JOIN m_client mc on mc.dpi = mpgm.dpi
INNER JOIN m_group_client mgc on mgc.client_id = mc.id
INNER JOIN m_group mg on mg.id = mgc.group_id
INNER JOIN m_group center on center.id = mg.parent_id
INNER JOIN m_portfolio mp on mp.id = center.portfolio_id
INNER JOIN m_supervision ms on ms.id = mp.supervision_id
) individualOffice ON individualOffice.group_id = g.id
LEFT JOIN m_agency ma ON
g.agency_id = ma.id
LEFT JOIN(
select agency_id, linked_office_id from m_supervision GROUP BY agency_id
) supv ON supv.agency_id = ma.id
LEFT JOIN m_office mo on mo.id = supv.linked_office_id
LEFT JOIN m_office moind on moind.id = individualOffice.supervision_office
LEFT JOIN
(
SELECT p.id AS groupid,
Expand Down
Loading