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

Release/1.0.48/prepare #899

Merged
merged 12 commits into from
Jul 8, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ public String schema() {
SELECT mc.id AS clientId,mc.loan_cycle as loanCycle, mpgm.id AS prequalificationMemberId, IFNULL(mc.display_name,mpgm.name) AS name, mpg.id AS prequalificationId,\s
mpgm.requested_amount AS requestedAmount, IFNULL(mc.date_of_birth, mpgm.dob) AS dateOfBirth, IFNULL(mc.dpi, mpgm.dpi) AS dpi,
mpgm.work_with_puente AS workWithPuente, mcv.code_value As gender, mpgm.is_president AS president, mpgm.buro_check_status as buroCheckStatus, mpgm.agency_bureau_status as agencyBuroStatus,
ml.is_topup AS isTopup, ml.id AS loanId,
ml.is_topup AS isTopup, ml.id AS loanId, mcvl.code_value as loanCycleCompleted,
ml.is_topup AS isTopup, ml.id AS loanId, mcvl.code_value as loanCycleCompleted,
CASE WHEN (? NOT IN (3,7,4,5)) AND (COALESCE(mc.loan_cycle, 0) >= 3) THEN 'RECURRING'
WHEN (? IN (4,5)) AND (COALESCE(mc.loan_cycle, 0) >= 1) THEN 'RECURRING'
ELSE 'NEW' END as clientCategorization,
Expand All @@ -276,6 +277,8 @@ CASE WHEN (? NOT IN (3,7,4,5)) AND (COALESCE(mc.loan_cycle, 0) >= 3) THEN 'RECUR
LEFT JOIN m_code_value areacv ON areacv.id = cinf.area
LEFT JOIN m_prequalification_group mpg ON mpg.id = mpgm.group_id
LEFT JOIN m_loan ml ON ml.client_id = mc.id AND ml.loan_status_id = 100 AND ml.prequalification_id = mpg.id
LEFT JOIN m_loan_additionals_group mlad ON mlad.loan_id = ml.id
LEFT JOIN m_code_value mcvl ON mcv.id = mlad.loan_cycle_completed
WHERE mpg.id = ? GROUP BY mc.id
""";
}
Expand All @@ -298,7 +301,12 @@ public ClientData mapRow(@NotNull ResultSet rs, int rowNum) throws SQLException
final String gender = rs.getString("gender");
final String clientArea = rs.getString("clientArea");
final String clientCategorization = rs.getString("clientCategorization");
final String recreditCategorization = isTopup?"RECREDITO" : "NUEVO";
String recreditCategorization = isTopup?"RECREDITO" : "NUEVO";
final String loanCycleCompleted = rs.getString("loanCycleCompleted");
if (!StringUtils.isBlank(loanCycleCompleted)){
recreditCategorization = StringUtils.equalsIgnoreCase(loanCycleCompleted, "fromAnotherGroup") ? "RECREDITO" : "NUEVO";
}

return ClientData.builder().clientId(clientId).prequalificationId(prequalificationId).clientArea(clientArea)
.clientCategorization(clientCategorization).recreditCategorization(recreditCategorization).prequalificationMemberId(prequalificationMemberId).name(name)
.dateOfBirth(dateOfBirth).dpi(dpi).requestedAmount(requestedAmount).gender(gender).workWithPuente(workWithPuente)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@
<include file="parts/0131_FBR_644_hard_policy_checks_updates_sql_updates.xml" relativeToChangelogFile="true"/>
<include file="parts/0132_AddConfigurationForAmountFormats.xml" relativeToChangelogFile="true"/>
<include file="parts/0133_UpdateNewHardPolicyQueries.xml" relativeToChangelogFile="true"/>
<include file="parts/0134_HardPolicyFixes.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">


<changeSet id="1" author="fineract">
<sql>
<![CDATA[
UPDATE stretchy_report SET report_sql = "SELECT
client_details.housing_type,
CASE
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'NUEVO') AND (client_details.housing_type = 'OWN') THEN 'GREEN'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'NUEVO') AND (client_details.housing_type = 'RENTED') THEN 'YELLOW'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'RECREDITO') AND (client_details.housing_type = 'OWN') THEN 'GREEN'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'RECREDITO') AND (client_details.housing_type = 'RENTED') THEN 'ORANGE'
ELSE 'RED'
END AS color
FROM m_client mc
INNER JOIN (
SELECT
mct.id AS client_id,
(CASE WHEN housing_type.code_value = 'Propia' THEN 'OWN' ELSE 'RENTED' END) AS housing_type
FROM m_client mct
LEFT JOIN m_client_contact_info mcci ON mcci.client_id = mct.id
LEFT JOIN m_code_value housing_type ON housing_type.id = mcci.housing_type
) client_details ON client_details.client_id = mc.id
WHERE mc.id = ${clientId}"
WHERE report_name = "Housing Typed Policy Check";
]]>
</sql>
</changeSet>
<changeSet id="2" author="fineract">
<sql>
<![CDATA[
UPDATE stretchy_report SET report_sql = "SELECT
client_details.years_of_residence,
CASE
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'NUEVO') AND (client_details.years_of_residence >= 3) THEN 'GREEN'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'NUEVO') AND (client_details.years_of_residence < 3) THEN 'YELLOW'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'RECREDITO') AND (client_details.years_of_residence >= 3) THEN 'GREEN'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'RECREDITO') AND (client_details.years_of_residence < 3) THEN 'YELLOW'
ELSE 'RED'
END AS color
FROM m_client mc
INNER JOIN (
SELECT
mct.id AS client_id,
COALESCE(mcci.years_of_residence, 0) AS years_of_residence
FROM m_client mct
LEFT JOIN m_client_contact_info mcci ON mcci.client_id = mct.id
LEFT JOIN m_code_value housing_type ON housing_type.id = mcci.housing_type
) client_details ON client_details.client_id = mc.id
WHERE mc.id = ${clientId}"
WHERE report_name = "Rental Age Policy Check";
]]>
</sql>
</changeSet>

<changeSet id="3" author="fineract">
<sql>
<![CDATA[
UPDATE stretchy_report SET report_sql = "SELECT
CASE
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'NUEVO') AND (${requestedAmount} BETWEEN 10000 AND 250000) THEN 'GREEN'
WHEN (${loanProductId} = 6) AND ('${recreditCategorization}' = 'RECREDITO') AND (${requestedAmount} BETWEEN 10000 AND 250000) THEN 'GREEN'
ELSE 'RED'
END AS color
FROM m_client mc
WHERE mc.id = ${clientId}"
WHERE report_name = "Amount Policy Check";
]]>
</sql>
</changeSet>



</databaseChangeLog>
Loading