From 81b5e0414f746f539a968dcd947cb5685dabb324 Mon Sep 17 00:00:00 2001 From: Brian Muhimbura Date: Thu, 15 Aug 2024 14:55:37 +0300 Subject: [PATCH] feature/FBR-710-714-QA (#1019) * fix FSF-9 * fix FSF-4 (#945) * Fix/fsf 11 (#947) * fix FSF-4 * fix FSF-11 * Fix/fsf 11 (#950) * fix FSF-4 * fix FSF-11 * fix FSF-11 * fix FSF-17 (#957) * fix FSF-15 * fix FSF-12 * fix FSF-19 * fix FSF-19 (#969) * Fix/fs 18 (#977) * fix FSF-19 * FIX FSF-18 * Fix/fsf 20 (#980) * fix FSF-19 * FIX FSF-18 * FIX FSF-20 * QA-FSF-18-20 * Fix/fsf 21 (#989) * FSF 22 * FSF 22 * Fix/fsf 21 (#990) * FSF 22 * FSF 22 * FSF 22 * FSF 23 (#992) * FBR-710 (#1000) * Fix/fsf 24 (#1014) * FBR-710 * FSF-24 * Feature/fbr 714 (#1018) * FBR-710 * FBR-714 --- .../core/service/SearchParameters.java | 8 +- .../api/GroupPrequalificationApiResource.java | 7 +- ...IndividualPrequalificationApiResource.java | 2 +- ...tionChecklistWritePlatformServiceImpl.java | 2 +- ...equalificationReadPlatformServiceImpl.java | 28 +++-- .../db/changelog/tenant/changelog-tenant.xml | 1 + .../tenant/commands/BACCOMMEDA/client_age.sql | 76 +++++++++++++ .../commands/BACCOMMEDA/investment_plan.sql | 27 +++++ .../BACCOMMEDA/maxium_and_minimum_amount.sql | 58 ++++++++++ .../commands/BACCOMMEDA/number_of_members.sql | 35 ++++++ .../commands/BACCOMMEDA/own_home_policy.sql | 40 +++++++ .../BACCOMMEDA/percentage_increase.sql | 73 +++++++++++++ .../presidet_board_of_directors.sql | 61 +++++++++++ .../commands/BACCOMMEDA/value_disparity.sql | 76 +++++++++++++ .../0135_FBR-714-BANCO_COMMUNAL_MEDA.xml | 102 ++++++++++++++++++ 15 files changed, 581 insertions(+), 15 deletions(-) create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/client_age.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/investment_plan.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/maxium_and_minimum_amount.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/number_of_members.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/own_home_policy.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/percentage_increase.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/presidet_board_of_directors.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/value_disparity.sql create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0135_FBR-714-BANCO_COMMUNAL_MEDA.xml diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/SearchParameters.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/SearchParameters.java index 469cd9f1175..05ebcee45bb 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/SearchParameters.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/SearchParameters.java @@ -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; @@ -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, @@ -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; @@ -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; diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java index cc89eac4c5c..91b0659ea7e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java @@ -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, @@ -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 clientData = this.prequalificationReadPlatformService.retrieveAll(searchParameters); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(queryParameters); @@ -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 queryParameters = uriInfo.getQueryParameters(); @@ -183,7 +185,7 @@ public String newClientIdentifierDetails(@Context final UriInfo uriInfo) { Long agencyId = null; Long centerId = null; Collection centerData = null; - Collection agencies = null; + Collection agencies = this.agencyReadPlatformService.retrieveByOfficeHierarchy(hierarchy); Collection appUsers = null; Collection loanProducts = null; GlobalConfigurationPropertyData timespan = null; @@ -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()) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/IndividualPrequalificationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/IndividualPrequalificationApiResource.java index 8a47ee41742..25a45a39e75 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/IndividualPrequalificationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/IndividualPrequalificationApiResource.java @@ -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 memberData = this.prequalificationReadPlatformService.retrieveAllMembers(searchParameters); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(queryParameters); diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationChecklistWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationChecklistWritePlatformServiceImpl.java index 0c561a09078..69f2942a7a3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationChecklistWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationChecklistWritePlatformServiceImpl.java @@ -605,7 +605,7 @@ private CheckValidationColor runCheck7(final ClientData clientData) { reportParams.put("${prequalificationId}", prequalificationId); reportParams.put("${loanProductId}", productId); reportParams.put("${clientArea}", clientArea); - reportParams.put("${categorization}", clientData.getCategorization()); + reportParams.put("${categorization}", clientData.getRecreditCategorization()); reportParams.put("${isTopup}", String.valueOf(clientData.getIsLoanTopup())); reportParams.put("${requestedAmount}", String.valueOf(clientData.getRequestedAmount())); final GenericResultsetData result = this.readReportingService.retrieveGenericResultset(reportName, "report", reportParams, false); diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java index ee2cb0f05db..231d380ec30 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java @@ -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(); @@ -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")) { @@ -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) { @@ -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, diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index ee0b7047449..5ede958db2f 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -154,4 +154,5 @@ + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/client_age.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/client_age.sql new file mode 100644 index 00000000000..1183afe4d0c --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/client_age.sql @@ -0,0 +1,76 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat('SELECT mc.id, + client_age.client_age AS client_age, + mc.date_of_birth AS date_of_birth, + CASE + -- Banco Comunal normal + WHEN (${loanProductId} = 2) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = 2) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = 2) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + + -- Banco Comunal normal meda + WHEN (${loanProductId} = ',@productId,') AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = ',@productId,') AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = ',@productId,') AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + + -- Banco Comunal temporal + WHEN (${loanProductId} = 9) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = 9) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = 9) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + + + -- Banco Comunal Agricola + WHEN (${loanProductId} = 8) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = 8) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + + + -- Grupo Solidario + WHEN (${loanProductId} = 4) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = 4) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = 4) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = 4) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = 4) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + + + -- Grupo Solidario Agricola + WHEN (${loanProductId} = 5) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 70) THEN ''GREEN'' + WHEN (${loanProductId} = 5) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) BETWEEN 71 AND 75) THEN ''YELLOW'' + WHEN (${loanProductId} = 5) AND (''${clientCategorization}'' = ''NEW'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + WHEN (${loanProductId} = 5) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) BETWEEN 18 AND 75) THEN ''GREEN'' + WHEN (${loanProductId} = 5) AND (''${clientCategorization}'' = ''RECURRING'') AND (IFNULL(client_age.client_age, 0) NOT BETWEEN 18 AND 75) THEN ''RED'' + END AS color + FROM m_client mc + INNER JOIN ( + SELECT mct.id AS client_id, mct.date_of_birth AS date_of_birth, IFNULL(TIMESTAMPDIFF(YEAR, mct.date_of_birth, CURDATE()), 0) AS client_age + FROM m_client mct + ) client_age ON client_age.client_id = mc.id + WHERE mc.id = ${clientId}') +WHERE report_name = 'Client age Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/investment_plan.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/investment_plan.sql new file mode 100644 index 00000000000..390c28036d6 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/investment_plan.sql @@ -0,0 +1,27 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat(' SELECT CASE + WHEN (${loanProductId} IN (9)) AND ''${categorization}'' = ''RECREDITO'' AND ${requestedAmount} <= 6000 THEN ''GREEN'' + WHEN (${loanProductId} IN (2,',@productId,',8)) AND ${requestedAmount} <= 6000 THEN ''GREEN'' + WHEN (${loanProductId} IN (2,',@productId,',9,8,4,5,7)) AND (${photographs} <= 0 OR ${investmentPlan} <= 0) THEN ''RED'' + ELSE ''GREEN'' + END AS color') +WHERE report_name = 'Mandatory to attach photographs and investment plan Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/maxium_and_minimum_amount.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/maxium_and_minimum_amount.sql new file mode 100644 index 00000000000..e858bf55af5 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/maxium_and_minimum_amount.sql @@ -0,0 +1,58 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat('SELECT + CASE + WHEN (${isTopup} = true) AND (${loanProductId} IN (2,8,9,',@productId,')) AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = true) AND (${loanProductId} IN (4,5)) AND (${requestedAmount} BETWEEN 5000 AND 25000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 5000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 1500 AND 20000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = 4) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 5000 AND 10000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 4) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 5000 AND 25000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 4) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 5000 AND 10000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 4) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 5000 AND 25000) THEN ''GREEN'' + + WHEN (${isTopup} = false) AND (${loanProductId} = 5) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 5000 AND 10000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 5) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBAN'') AND (${requestedAmount} BETWEEN 5000 AND 20000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 5) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 5000 AND 10000) THEN ''GREEN'' + WHEN (${isTopup} = false) AND (${loanProductId} = 5) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${requestedAmount} BETWEEN 5000 AND 20000) THEN ''GREEN'' + + ELSE ''RED'' + END AS color') +WHERE report_name = 'Minimum and maximum amount Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/number_of_members.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/number_of_members.sql new file mode 100644 index 00000000000..5b9a2b220e2 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/number_of_members.sql @@ -0,0 +1,35 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat('SELECT + CASE + WHEN (${loanProductId} = 2) AND (${numberOfMembers} >= 7) THEN ''GREEN'' + + WHEN (${loanProductId} = ',@productId,') AND (${numberOfMembers} >= 7) THEN ''GREEN'' + + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (${recreditPercent} < 50) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (${recreditPercent} >= 50) THEN ''GREEN'' + + WHEN (${loanProductId} = 8) AND (${numberOfMembers} >= 7) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (${numberOfMembers} < 7) THEN ''ORANGE'' + + ELSE ''RED'' + END AS color') +WHERE report_name = 'Number of members according to policy Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/own_home_policy.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/own_home_policy.sql new file mode 100644 index 00000000000..b23627bdc8c --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/own_home_policy.sql @@ -0,0 +1,40 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat('SELECT + housing_type.owner_percent, + CASE + WHEN (${loanProductId} = 2) AND (housing_type.owner_percent >=50) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (housing_type.owner_percent <50) THEN ''YELLOW'' + + WHEN (${loanProductId} = ',@productId,') AND (housing_type.owner_percent >=50) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (housing_type.owner_percent <50) THEN ''YELLOW'' + + WHEN (${loanProductId} = 8) AND (housing_type.owner_percent >=50) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (housing_type.owner_percent <50) THEN ''YELLOW'' + + END AS color + FROM m_prequalification_group mpg + INNER JOIN ( select (((select count(*) from m_prequalification_group_members mpm INNER JOIN m_client mc on mc.dpi = mpm.dpi + INNER JOIN m_client_contact_info mcinf on mcinf.client_id = mc.id INNER JOIN m_code_value mcv on mcv.id = mcinf.housing_type where mcv.code_value = ''Propia'' and mpm.group_id = ${prequalificationId})/ + (select count(*) from m_prequalification_group_members mpg where mpg.group_id = ${prequalificationId}))*100) as owner_percent, ${prequalificationId} as grp_id ) + housing_type ON housing_type.grp_id = mpg.id + WHERE mpg.id = ${prequalificationId}') +WHERE report_name = 'Percentage of members with their own home Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/percentage_increase.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/percentage_increase.sql new file mode 100644 index 00000000000..2da8e5db11e --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/percentage_increase.sql @@ -0,0 +1,73 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat('SELECT + CASE + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) <= 200) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) <= 150) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) <= 100) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) <= 80) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) > 200) THEN ''RED'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) > 150) THEN ''RED'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) > 100) THEN ''RED'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) > 80) THEN ''RED'' + WHEN (${loanProductId} = 2) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''RED'' + + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) <= 200) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) <= 150) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) <= 100) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) <= 80) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) > 200) THEN ''RED'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) > 150) THEN ''RED'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) > 100) THEN ''RED'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) > 80) THEN ''RED'' + WHEN (${loanProductId} = ',@productId,') AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''RED'' + + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) <= 200) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) <= 150) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) <= 100) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) <= 80) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) > 200) THEN ''RED'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) > 150) THEN ''RED'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) > 100) THEN ''RED'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) > 80) THEN ''RED'' + WHEN (${loanProductId} = 9) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) <= 200) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) <= 150) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) <= 100) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) <= 80) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) <= 1500) AND (IFNULL(${percentageIncrease}, 0) > 200) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 1500) AND (IFNULL(${currentCreditValue}, 0) <= 3000) AND (IFNULL(${percentageIncrease}, 0) > 150) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 3000) AND (IFNULL(${currentCreditValue}, 0) <= 3500) AND (IFNULL(${percentageIncrease}, 0) > 100) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 3500) AND (IFNULL(${currentCreditValue}, 0) <= 4000) AND (IFNULL(${percentageIncrease}, 0) > 80) THEN ''RED'' + WHEN (${loanProductId} = 8) AND (IFNULL(${currentCreditValue}, 0) > 4000) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''RED'' + WHEN (${loanProductId} = 4) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = 4) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''ORANGE'' + WHEN (${loanProductId} = 5) AND (IFNULL(${percentageIncrease}, 0) <= 60) THEN ''GREEN'' + WHEN (${loanProductId} = 5) AND (IFNULL(${percentageIncrease}, 0) > 60) THEN ''ORANGE'' + END AS color + FROM m_client mc + WHERE mc.id = ${clientId} + GROUP BY mc.id') +WHERE report_name = 'Increase percentage Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/presidet_board_of_directors.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/presidet_board_of_directors.sql new file mode 100644 index 00000000000..f7ebdb2ea62 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/presidet_board_of_directors.sql @@ -0,0 +1,61 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat(' SELECT + prequalification_details.recreditCategorization, + CASE + WHEN (${loanProductId} = 2) AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = 2) AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + + WHEN (${loanProductId} = ',@productId,') AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = ',@productId,') AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + + WHEN (${loanProductId} = 9) AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = 9) AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + + WHEN (${loanProductId} = 8) AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = 8) AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + + WHEN (${loanProductId} = 4) AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = 4) AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = 4) AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = 4) AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + + WHEN (${loanProductId} = 5) AND (''${buroCheckClassification}'' = ''A'') THEN ''GREEN'' + WHEN (${loanProductId} = 5) AND (''${buroCheckClassification}'' = ''B'') THEN ''GREEN'' + WHEN (${loanProductId} = 5) AND (''${buroCheckClassification}'' = ''C'') THEN ''YELLOW'' + WHEN (${loanProductId} = 5) AND (''${buroCheckClassification}'' = ''D'') THEN ''ORANGE'' + END AS color + FROM m_prequalification_group mpg + INNER JOIN ( + SELECT p.id AS prequalification_id, + (CASE WHEN p.previous_prequalification IS NOT NULL THEN ''RECREDITO'' ELSE ''NUEVO'' END) AS recreditCategorization + FROM m_prequalification_group p + ) prequalification_details ON prequalification_details.prequalification_id = mpg.id + WHERE mpg.id = ${prequalificationId}') +WHERE report_name = 'President of the Board of Directors of the BC Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/value_disparity.sql b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/value_disparity.sql new file mode 100644 index 00000000000..550dbb5cd3f --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/commands/BACCOMMEDA/value_disparity.sql @@ -0,0 +1,76 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +SELECT @productId := (select id from m_product_loan where short_name='BCOMMEDA' limit 1); +UPDATE stretchy_report SET report_sql = concat(' SELECT + CASE + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 2) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = ',@productId,') AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 9) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''URBANA'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 3) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''NUEVO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 3) THEN ''YELLOW'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} BETWEEN 1 AND 4) THEN ''GREEN'' + WHEN (${loanProductId} = 8) AND (''${categorization}'' = ''RECREDITO'') AND (''${clientArea}'' = ''RURAL'') AND (${disparityRatio} > 4) THEN ''YELLOW'' + ELSE ''RED'' + + END AS color + FROM m_prequalification_group mpg + LEFT JOIN ( + SELECT p.id AS prequalification_id, + (select count(ml.id) FROM m_prequalification_group mp + LEFT JOIN m_prequalification_group_members mpgm ON mpgm.group_id = mp.id + LEFT JOIN m_client mc ON mc.dpi = mpgm.dpi + LEFT JOIN m_loan ml ON ml.client_id = mc.id + WHERE + ml.loan_status_id < 300 AND ml.product_id = ${loanProductId} AND ml.is_topup = 1 + AND mp.id = ${prequalificationId} + ) recredit_count + FROM m_prequalification_group p + ) recredit_loan ON recredit_loan.prequalification_id = mpg.id + WHERE mpg.id = ${prequalificationId}') +WHERE report_name = 'Value disparity Policy Check'; diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0135_FBR-714-BANCO_COMMUNAL_MEDA.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0135_FBR-714-BANCO_COMMUNAL_MEDA.xml new file mode 100644 index 00000000000..f751e3a99b2 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0135_FBR-714-BANCO_COMMUNAL_MEDA.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +