forked from FITER1/fineract-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from fiterlatam/fix/FBR-404
Policy Checks Implementations
- Loading branch information
Showing
5 changed files
with
234 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
fineract-provider/src/main/resources/db/changelog/tenant/commands/policy_run_10.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- | ||
-- 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. | ||
-- | ||
|
||
-- liquibase formatted sql | ||
-- changeset fineract:1 | ||
-- MySQL dump 10.13 Distrib 5.1.60, for Win32 (ia32) | ||
-- | ||
-- Host: localhost Database: fineract_default | ||
-- ------------------------------------------------------ | ||
-- Server version 5.1.60-community | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES UTF8MB4 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- Percentage of members with their own home -- | ||
INSERT INTO stretchy_report (report_name,report_type,report_category,report_sql,description,core_report,use_report,self_service_user_report) | ||
VALUES ("Percentage of members with their own home Policy Check", "Table", "Prequalification", | ||
"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} = 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}", "Percentage of members with their own home Policy Check", 0, 0, 0); |
56 changes: 56 additions & 0 deletions
56
fineract-provider/src/main/resources/db/changelog/tenant/commands/policy_run_14.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- | ||
-- 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. | ||
-- | ||
|
||
-- liquibase formatted sql | ||
-- changeset fineract:1 | ||
-- MySQL dump 10.13 Distrib 5.1.60, for Win32 (ia32) | ||
-- | ||
-- Host: localhost Database: fineract_default | ||
-- ------------------------------------------------------ | ||
-- Server version 5.1.60-community | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES UTF8MB4 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- Amount requested in relation to the current amount of main products -- | ||
INSERT INTO stretchy_report (report_name,report_type,report_category,report_sql,description,core_report,use_report,self_service_user_report) | ||
VALUES ("Amount requested in relation to the current amount of main products", "Table", "Prequalification", | ||
"SELECT | ||
client_details.number_of_principal_loans, | ||
CASE | ||
WHEN ('${loanProductId}' = 7) AND ((client_details.current_loan_amount)/${requestedAmount} <= 4) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 7) AND ((client_details.current_loan_amount)/${requestedAmount} = 5) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 7) AND ((client_details.current_loan_amount)/${requestedAmount} >= 6) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 3) AND (${requestedAmount} <= 3000) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 3) AND (${requestedAmount} > client_details.current_loan_amount) THEN 'RED' | ||
WHEN ('${loanProductId}' = 3) AND (${requestedAmount} > 3000) THEN 'RED' | ||
END AS color | ||
FROM m_client mc | ||
INNER JOIN ( | ||
SELECT mc.id AS client_id, (select COALESCE(ml.principal_amount,0) from m_loan ml where ml.client_id = mc.id and ml.product_id = ${loanProductId} and ml.loan_status_id = 300 ORDER BY id desc limit 1 ) as current_loan_amount FROM m_client mc | ||
)client_details ON client_details.client_id = mc.id | ||
WHERE mc.id = ${clientId}", "Amount requested in relation to the current amount of main products", 0, 0, 0); |
59 changes: 59 additions & 0 deletions
59
fineract-provider/src/main/resources/db/changelog/tenant/commands/policy_run_16.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
-- | ||
-- 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. | ||
-- | ||
|
||
-- liquibase formatted sql | ||
-- changeset fineract:1 | ||
-- MySQL dump 10.13 Distrib 5.1.60, for Win32 (ia32) | ||
-- | ||
-- Host: localhost Database: fineract_default | ||
-- ------------------------------------------------------ | ||
-- Server version 5.1.60-community | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES UTF8MB4 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- Payments outside the current term of the main product -- | ||
INSERT INTO stretchy_report (report_name,report_type,report_category,report_sql,description,core_report,use_report,self_service_user_report) | ||
VALUES ("Payments outside the current term of the main product Policy Check", "Table", "Prequalification", | ||
"SELECT | ||
client_details.number_of_principal_loans, | ||
CASE | ||
WHEN ('${loanProductId}' = 7) AND (client_details.number_of_pending_installments = 4) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 7) AND (client_details.number_of_pending_installments > 4) THEN 'ORANGE' | ||
WHEN ('${loanProductId}' = 3) AND (client_details.number_of_pending_installments = 4) THEN 'GREEN' | ||
WHEN ('${loanProductId}' = 3) AND (client_details.number_of_pending_installments > 4) THEN 'ORANGE' | ||
END AS color | ||
FROM m_client mc | ||
INNER JOIN ( | ||
SELECT mc.id AS client_id, COUNT(DISTINCT RS.id) AS number_of_pending_installments | ||
FROM m_client mc | ||
LEFT JOIN m_loan ml ON ml.client_id = mc.id | ||
LEFT JOIN m_loan_repayment_schedule RS ON RS.loan_id = ml.id | ||
WHERE ml.product_id IN (2, 4) AND (ml.loan_status_id = 300) AND RS.completed_derived =0 | ||
GROUP BY mc.id | ||
)client_details ON client_details.client_id = mc.id | ||
WHERE mc.id = ${clientId}", "Payments outside the current term of the main product Policy Check", 0, 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters