Skip to content

Commit

Permalink
SU-488: Archivo de Cartera - Departamento
Browse files Browse the repository at this point in the history
  • Loading branch information
tabrez-fiter committed Dec 7, 2024
1 parent 3c8ae43 commit d1786c8
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public String schema() {
+ " CASE WHEN mc.legal_form_enum = 2 THEN 'NIT' ELSE 'Cédula' END AS tipo_documento,\n"
+ " COALESCE(ccp.\"Direccion\",cce.\"Direccion\") AS direction, \n"
+ " COALESCE(ccp.\"Ciudad_cd_Ciudad\",cce.\"Ciudad_cd_Ciudad\") as ciudad, \n"
+ " cce.\"Departamento_cd_Departamento\" as departamento,\n" + " mcbr.name_of_reason AS creaditBlock, \n"
+ " ccp.\"Referencia\"AS referencia,\n" + " ccp.\"Media de ingresos\" AS media_de_ingreso, \n"
+ " ccp.\"Nombre empresa\" AS nombre_empresa, \n" + " caps.client_ally_id,\n"
+ " ca.nit as nit_empresa_aliada,\n" + " caps.name as point_of_sale_name,\n"
+ " ccp.\"Parentesco_cd_Parentesco\" AS parentesco,\n"
+ " COALESCE(cce.\"Departamento_cd_Departamento\",(select id from m_code_value where code_id =40 and code_score = mcv.departement_id)) as departamento,\n"
+ " mcbr.name_of_reason AS creaditBlock, \n" + " ccp.\"Referencia\"AS referencia,\n"
+ " ccp.\"Media de ingresos\" AS media_de_ingreso, \n" + " ccp.\"Nombre empresa\" AS nombre_empresa, \n"
+ " caps.client_ally_id,\n" + " ca.nit as nit_empresa_aliada,\n"
+ " caps.name as point_of_sale_name,\n" + " ccp.\"Parentesco_cd_Parentesco\" AS parentesco,\n"
+ " mc.created_on_utc, ccp.\"Estado Civil_cd_Estado civil\" as estado_civil, \n"
+ " ml.disbursedon_date, \n" + " mc.date_of_birth,\n" + " (SELECT code_value \n"
+ " FROM m_code_value \n"
Expand All @@ -66,8 +66,13 @@ public String schema() {
+ "LEFT JOIN campos_cliente_persona ccp ON ccp.client_id = mc.id\n"
+ "LEFT JOIN campos_cliente_empresas cce ON cce.client_id = mc.id \n" + "LEFT JOIN (\n"
+ " SELECT loan_id, name_of_reason, priority\n" + " FROM RankedCreaditReasons\n" + " WHERE row_num = 1\n"
+ ") AS mcbr ON mcbr.loan_id = ml.id\n" + "WHERE total_outstanding_derived > 0 \n"
+ " and loan_status_id NOT IN (500, 601, 602, 600)\n" + "ORDER BY mc.id, ml.id DESC;\n";
+ ") AS mcbr ON mcbr.loan_id = ml.id\n" + " LEFT JOIN (\n" + "SELECT id,CASE \n"
+ " WHEN LEFT(LPAD(code_score::TEXT, 5, '0'), 2)::INTEGER < 10 THEN \n"
+ " LEFT(LPAD(code_score::TEXT, 5, '0'), 2)::INTEGER::VARCHAR\n" + " ELSE \n"
+ " LEFT(LPAD(code_score::TEXT, 5, '0'), 2)\n" + " END as departement_id\n"
+ "\tfrom m_code_value ciudad where ciudad.code_id =41\n" + " ) mcv on mcv.id= ccp.\"Ciudad_cd_Ciudad\" "
+ "WHERE total_outstanding_derived > 0 \n" + " and loan_status_id NOT IN (500, 601, 602, 600)\n"
+ "ORDER BY mc.id, ml.id DESC;\n";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,5 @@
<include file="parts/20243008011009148_SU_319_add_table_collection_house_history.xml" relativeToChangelogFile="true"/>
<include file="parts/20243008011009148_SU_432_update-job-run.xml" relativeToChangelogFile="true"/>
<include file="parts/20240507011009134_SU_477_update_reports_migration_aval_charge.xml" relativeToChangelogFile="true"/>
<include file="parts/20243008011009142_SU_488_update_report._archivo.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<update tableName="STRETCHY_REPORT">
<column name="REPORT_SQL">
<![CDATA[
SELECT
title AS "Titulo",
identificacion AS "Cedula del cliente",
primer_nombre AS "Primer Nombre",
segundo_nombre AS "Segundo Nombre",
primer_apellido AS "Primer Apellido",
segundo_apellido AS "Segundo Apellido",
estado_cliente AS "Estado Cliente",
numero_obligacion AS "Numero Cuenta Cuota",
nit_empresa AS "Nit Empresa",
telefono_sac_1 AS "Telefono",
celular_sac_1 AS "Mobile No",
telefono_sac_2 AS "Telefono Sac 2",
celular_sac_2 AS "Celular Sac 2",
email_sac AS "Email",
direccion_sac AS "Direccion",
barrio_sac AS "Barrio",
ciudad_sac AS "Ciudad",
COALESCE(departamento,(select code_value
from m_code_value mcv where code_id = 40 and code_score =(select CASE
WHEN LEFT(LPAD(code_score::TEXT, 5, '0'), 2)::INTEGER < 10 THEN
LEFT(LPAD(code_score::TEXT, 5, '0'), 2)::INTEGER::VARCHAR
ELSE
LEFT(LPAD(code_score::TEXT, 5, '0'), 2)
END as departement_id from m_code_value mcv where code_value =ciudad_sac) )) AS "Departamento",
tipo_credito AS "Categoria punto de venta de origen del credito",
COALESCE(fecha_vencimiento::text, '') AS "Vencimiento cuota",
dias_mora AS "Dias de mora de la cuenta",
valor_cuota AS "Cuota",
capital AS "Capital",
monto_inicial AS "Monto inicial",
aval AS "Aval",
intereses AS "Intereses",
intereses_de_mora AS "Intereses de mora",
iva_interes_de_mora AS "IVA de mora",
seguro AS "Seguro obligatorio cuota",
seguros_voluntarios AS "Seguros voluntarios cuota",
punto_de_venta AS "Punto de venta de origen del credito",
tipo_documento AS "Tipo de documento",
empresa AS "Empresa",
nit_empresa_aliada AS "Nit empresa aliada",
marca AS "Nombre Aliado",
razon_social AS "Nombre completo del cliente",
ciudad_punto_credito AS "Ciudad punto de venta",
estado_cuota AS "Estado de la cuenta",
nombre_familiar_1 AS "Referencia del cliente",
parentesco_familiar_1 AS "Parentesco referencia",
celular_familiar_1 AS "Celular referencia",
nombre_familiar_2 AS "Nombre familiar",
parentesco_familiar_2 AS "Parentesco familiar",
celular_familiar_2 AS "Celular familiar",
COALESCE(fecha_financiacion::text, '') AS "Fecha de desembolso",
COALESCE(fecha_nacimiento::text, '') AS "Fecha nacimiento cliente",
genero AS "Genero cliente",
empresa_labora AS "Nombre empresa donde labora",
ingresos AS "Media de ingresos",
periodicidad AS "Mensual",
COALESCE(antiguedad_cliente::text, '') AS "Fecha de creacion del cliente",
empresa_reporta AS "Intercredito",
abono AS "Abonos cuota",
condonaciones AS "Condonaciones cuota",
actividad_laboral AS "Actividad laboral del cliente",
cre_estado AS "Estado cliente",
cre_saldo AS "Saldo total del credito",
cuo_saldo AS "Saldo total cuota",
cuo_estado AS "Cuo Estado de la cuenta",
estado_civil AS "Estado civil del cliente",
numero_de_reprogramaciones AS "Numero de reprogramaciones"
FROM m_archive_loan_history
ORDER BY
identificacion DESC,
CAST(SPLIT_PART(numero_obligacion, '+', 1) AS INTEGER) DESC,
CAST(SPLIT_PART(numero_obligacion, '+', -1) AS INTEGER) ASC
]]>
</column>
<where>report_name = 'Archivo de cartera'</where>
</update>
</changeSet>
</databaseChangeLog>

0 comments on commit d1786c8

Please sign in to comment.