From 198a0fd064884e622237aa173eab1ccb255e12d6 Mon Sep 17 00:00:00 2001 From: Anthony Laz Arteaga Date: Mon, 25 Nov 2024 10:46:32 -0500 Subject: [PATCH] . --- .../001 VERIFICAR CONVENIO.sql | 133 ------------------ .../004 ACTUALIZAR ESTADOS CONVENIOS.sql | 96 ------------- 2 files changed, 229 deletions(-) delete mode 100644 CONVENIOS FINALIZADOS APROBADOS/001 VERIFICAR CONVENIO.sql delete mode 100644 CONVENIOS FINALIZADOS APROBADOS/004 ACTUALIZAR ESTADOS CONVENIOS.sql diff --git a/CONVENIOS FINALIZADOS APROBADOS/001 VERIFICAR CONVENIO.sql b/CONVENIOS FINALIZADOS APROBADOS/001 VERIFICAR CONVENIO.sql deleted file mode 100644 index eee1ec8..0000000 --- a/CONVENIOS FINALIZADOS APROBADOS/001 VERIFICAR CONVENIO.sql +++ /dev/null @@ -1,133 +0,0 @@ -use telus; - -/*verificar convenios antes del 2024*/ - -if OBJECT_ID('tempdb.dbo.#convenios_revisar') is not null - drop table #convenios_revisar - -select id -into #convenios_revisar -from db_olympo_web.dbo.convenios_cabecera where code in('002658'); - -declare - @cuotas_pagadas int, - @total_lotes int, - @clave_verificar VARCHAR(max) = '', - @lote_id INT - - -set @lote_id = (select lote_id from telus_procesos.dbo.agcm_datos_claves_avaluos where ClaveCatastral = @clave_verificar); - - -set @cuotas_pagadas = (select count(*) from db_olympo_web.dbo.convenios_detalle de where agreement_id in(select id from #convenios_revisar) and all_paid = 1); -print 'Cuotas pagadas: ' + CAST(@cuotas_pagadas as VARCHAR(MAX)); - -if OBJECT_ID('tempdb.dbo.#lotes_convenio_re') is not null - drop table #lotes_convenio_re - -select - DISTINCT - --top 10 - lote_id - into #lotes_convenio_re - from agcm_2022_tram_liquidaciones_convenio lc where lc.id_convenio in(select id from #convenios_revisar); - -set @total_lotes = (select COUNT(*) from #lotes_convenio_re); -print 'Claves catastrales: ' + CAST(@total_lotes as VARCHAR(MAX)); - -/* -/*INFORME DE PAGOS REALIZADOS EN OLYMPO*/ -select max(pd.agreement_id) as id_convenio, max(pc.date) as fecha_pago, max(pc.code) as code, pd.id, pd.vouchers_id, pd.value_paid,pd.penalty_fee,pd.penalty_agreement, pd.to_paid - from db_olympo_web.dbo.convenios_pagos_detalle pd - inner join db_olympo_web.dbo.convenios_pagos_cabecera as pc on pc.id = pd.vouchers_id - where pd.agreement_id in (select id from #convenios_revisar) and vouchers_id is not null - group by pd.vouchers_id, pd.to_paid, pd.value_paid,pd.penalty_fee,pd.penalty_agreement,pd.id - order by pd.vouchers_id; - - */ - -if OBJECT_ID('tempdb.dbo.#infome_pagadas') is not null - drop table #infome_pagadas - -select lm.titulo,MAX(cast(lm.observacion as Varchar(max))) AS obs, idpago as vouchers_id, MAX(c.fecha_pago) as fecha_pago, MAX(c.fecha_registro) as fecha_registro, MAX(c.lote_id) as lote_id, recaudacion_id_mg,sum(valor_pagar_unitario) as valor_pagado -into #infome_pagadas -from db_olympo_web.dbo.agcm_2023_recaudacion_cuotas c -left join telus.dbo.agcm_2022_tram_liquidaciones_convenio l on l.id = c.id_tranliqui -left join db_olympo_web.dbo.liquidaciones_main lm on l.id_liquidacion = lm.id -where c.id_convenio_olympo in (select id from #convenios_revisar) -group by l.id_liquidacion,lm.titulo, idpago, recaudacion_id_mg - - -if OBJECT_ID('tempdb.dbo.#infome_pagadas_detalle') is not null - drop table #infome_pagadas_detalle - -select -MAX(lm.titulo) as titulo,MAX(cast(lm.observacion as Varchar(max))) AS obs, -vouchers_id, c.id_convenio_olympo, MAX(c.fecha_pago) as fecha_pago, MAX(c.fecha_registro) as fecha_registro, MAX(c.lote_id) as lote_id, recaudacion_id_mg,valor_pagar_unitario as valor_pagado -into #infome_pagadas_detalle -from db_olympo_web.dbo.agcm_2023_recaudacion_cuotas_detalle c -inner join db_olympo_web.dbo.convenios_pagos_detalle pd on c.idpago = pd.id -left join telus.dbo.agcm_2022_tram_liquidaciones_convenio l on l.id = c.id_tranliqui -left join db_olympo_web.dbo.liquidaciones_main lm on l.id_liquidacion = lm.id -where c.id_convenio_olympo in (select id from #convenios_revisar) -group by --l.id_liquidacion,lm.titulo, -pd.vouchers_id, recaudacion_id_mg,valor_pagar_unitario, c.id_convenio_olympo - - - - -SELECT x.titulo, ---x.obs, -x.vouchers_id, x.fecha_pago, x.fecha_registro, x.lote_id,da.ClaveCatastral, x.recaudacion_id_mg, valor_pagado , -(select count(*) from agcm_2023_recaudacion_id_convenio where lote_id = x.lote_id) pagos_olympo -FROM #infome_pagadas x -inner join telus_procesos.dbo.agcm_datos_claves_avaluos da on x.lote_id = da.lote_id ---where da.ClaveCatastral like '%'+ @clave_verificar -order by x.recaudacion_id_mg; - -SELECT -x.titulo, ---x.obs, -x.vouchers_id,x.fecha_pago, x.fecha_registro, x.lote_id,da.ClaveCatastral, x.recaudacion_id_mg, valor_pagado, -(select count(*) from agcm_2023_recaudacion_id_convenio where lote_id = x.lote_id) pagos_olympo -FROM #infome_pagadas_detalle x -inner join telus_procesos.dbo.agcm_datos_claves_avaluos da on x.lote_id = da.lote_id ---where da.ClaveCatastral like '%'+ @clave_verificar -order by x.recaudacion_id_mg; - -/*INFORME DUPLICADAS*/ -SELECT -count(*) as duplicados -FROM #infome_pagadas_detalle x -inner join telus_procesos.dbo.agcm_datos_claves_avaluos da on x.lote_id = da.lote_id -where x.vouchers_id in (select vouchers_id from #infome_pagadas) - - -SELECT -x.titulo, ---x.obs, -x.vouchers_id,x.fecha_pago, x.fecha_registro, x.lote_id,da.ClaveCatastral, x.recaudacion_id_mg as recaudacion_id, valor_pagado -FROM #infome_pagadas_detalle x -inner join telus_procesos.dbo.agcm_datos_claves_avaluos da on x.lote_id = da.lote_id -where x.vouchers_id in (select vouchers_id from #infome_pagadas) ---and recaudacion_id_mg not in(select distinct recaudacion_id_mg from #infome_pagadas) -order by x.recaudacion_id_mg; - -goto salir - -/*verificar si hay pagos no procesados*/ -select * from db_olympo_web.dbo.agcm_2023_recaudacion_cuotas where lote_id = 7910 and recaudacion_id_mg = 0 -select * from db_olympo_web.dbo.agcm_2023_recaudacion_cuotas_detalle where lote_id = 7910 and recaudacion_id_mg = 0 - -select * from agcm_2023_recaudacion_id_convenio where lote_id = 7910 - ---delete db_olympo_web.dbo.agcm_2023_recaudacion_cuotas where lote_id = 2338 and recaudacion_id_mg = 0 - -/*Ver recaudaciones de usuario portal ciudadano, con el que se procesan las recaudaciones de convenios*/ -select sum(valor_pago) from recaudacion_registro_pago where lote_id = 36888 -and usuario_id = 430 ---order by recaudacion_id desc - - -SALIR: - diff --git a/CONVENIOS FINALIZADOS APROBADOS/004 ACTUALIZAR ESTADOS CONVENIOS.sql b/CONVENIOS FINALIZADOS APROBADOS/004 ACTUALIZAR ESTADOS CONVENIOS.sql deleted file mode 100644 index 451a396..0000000 --- a/CONVENIOS FINALIZADOS APROBADOS/004 ACTUALIZAR ESTADOS CONVENIOS.sql +++ /dev/null @@ -1,96 +0,0 @@ -use telus; - -/*verificar convenios antes del 2024*/ - -if OBJECT_ID('tempdb.dbo.#convenios_revisar') is not null - drop table #convenios_revisar - -select id -into #convenios_revisar -from db_olympo_web.dbo.convenios_cabecera where code in('002658'); - -select b.ClaveCatastral, a.* from agcm_2022_tram_liquidaciones_convenio a - inner join telus_procesos.dbo.agcm_datos_claves_avaluos b on a.lote_id = b.lote_id - where a.id_convenio = (select id from #convenios_revisar) order by lote_id - - -select * from rentas_estado b - inner join agcm_2022_tram_liquidaciones_convenio a on b.registro_lote_id = a.lote_id - where a.id_convenio = (select id from #convenios_revisar) - and b.estado = 1 and estado_registro= 'ACTIVO' - order by lote_id - -select b.* from avaluo_emision_anual_cabecera b - inner join agcm_2022_tram_liquidaciones_convenio a on b.lote_id = a.lote_id - where a.id_convenio = (select id from #convenios_revisar) - and b.esta_convenio = 1 - order by b.lote_id - - ---update avaluo_emision_anual_cabecera set esta_convenio = 0 where emision_id in(1947170,1947170)and esta_convenio = 1 - - - ---update rentas_estado set estado_registro = 'INACTIVO' where tipo_renta=0 and registro_lote_id = 56354 and estado_registro <> 'INACTIVO' - - ---update agcm_2022_tram_liquidaciones_convenio set estado = 'INACTIVO' where id = 5688 - - -GOTO SALIR - -DECLARE - @id_tram_liq INT, - @lote_id INT, - @desde INT, - @hasta INT - -DECLARE procesar_cursor CURSOR FOR - select --b.ClaveCatastral, a.estado, - a.id, a.lote_id, a.desde, a.hasta from agcm_2022_tram_liquidaciones_convenio a - inner join telus_procesos.dbo.agcm_datos_claves_avaluos b on a.lote_id = b.lote_id - where a.id_convenio = (select id from #convenios_revisar) order by lote_id - ---SELECT top 1 registro_id FROM rentas_estado where tipo_renta=0 and registro_lote_id = 67325 and estado = 0 order by registro_id desc - -print 'Fecha Hora Inicio' -print getdate() - -OPEN procesar_cursor - FETCH NEXT FROM procesar_cursor - INTO @id_tram_liq,@lote_id, @desde, @hasta - WHILE @@FETCH_STATUS = 0 - BEGIN - declare @estado_convenio int = 0 - - update agcm_2022_tram_liquidaciones_convenio set estado = 'INACTIVO', fecha_actualiza = GETDATE() where id = @id_tram_liq and estado <> 'INACTIVO' - - update avaluo_emision_anual_cabecera set esta_convenio = 0 where lote_id = @lote_id and ano_id between @desde and @hasta and esta_convenio = 1 and esta_pagado = 1 - - set @estado_convenio = isnull((select top 1 estado from rentas_estado where tipo_renta=0 and registro_lote_id = @lote_id and estado_registro = 'ACTIVO' and estado <> 0),0) - - print @estado_convenio - - if @estado_convenio = 1 - begin - update rentas_estado set estado_registro = 'INACTIVO' where tipo_renta=0 and registro_lote_id = @lote_id and estado_registro <> 'INACTIVO' - - insert into rentas_estado(registro_lote_id,tipo_renta,estado,usuario_id,ip,pcname,detalle,estado_registro,fecha) - select @lote_id,0,0,18,'127.0.0.1','localhost','Convenio rechazado por inclumplimiento de cuotas mensuales','ACTIVO',GETDATE() - end - /*ELSE - BEGIN - update rentas_estado set estado_registro = 'ACTIVO' - where registro_id in (SELECT top 1 registro_id FROM rentas_estado where tipo_renta=0 and registro_lote_id = @lote_id and estado = 0 order by registro_id desc) - END*/ - FETCH NEXT FROM procesar_cursor - INTO @id_tram_liq,@lote_id, @desde, @hasta - END - -CLOSE procesar_cursor -DEALLOCATE procesar_cursor; -print 'Fecha Hora Fin' -print getdate() - -SALIR: -