2024-11-21 11:39:26 -05:00
use telus ;
/* verificar convenios antes del 2024 */
2024-12-30 14:48:56 -05:00
- - exec telus_avaluo_emision_consulta 10634
- - select * from agcm_2022_tram_liquidaciones_convenio where lote_id = 53642
- - select * from avaluo_emision_anual_cabecera where lote_id = 53642
- - select * from rentas_estado WHERE registro_lote_id = 53642 ;
- - update rentas_estado set estado = 1 where registro_id = 17868 and registro_lote_id = 53642 ;
- - update avaluo_emision_anual_cabecera set esta_convenio = 1 where emision_id IN ( 1993121 , 2081207 ) and lote_id = 53642
- - @ id_liquidacion int , @ codigo_liquidacion varchar ( 200 ) , @ id_convenio int , @ lote_id int , @ valor numeric ( 18 , 2 ) , @ observacion text , @ estado varchar ( 100 ) , @ ip text , @ host text , @ desde int , @ hasta int
- - exec agcm_2022_tram_liquidaciones_convenio_ingreso 861638 , " IP-1390000991001-29169-2023 " , 3344 , 29169 , 0 . 51 , " Facilidad de Pago, Impuesto Predial, CEM y otras tasas, clave catastral 2-09-10-12-000 año(s) 2023 " , " ACTIVO " , " 201.234.204.18 " , " portalciudadano.manta.gob.ec " , 2023 , 2023
2024-11-26 11:40:08 -05:00
2024-11-21 11:39:26 -05:00
if OBJECT_ID ( ' tempdb.dbo.#convenios_revisar ' ) is not null
drop table #convenios_revisar
select id
into #convenios_revisar
2024-12-30 14:48:56 -05:00
from db_olympo_web . dbo . convenios_cabecera where code in ( ' 003011 ' ) ;
2024-11-21 11:39:26 -05:00
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
2024-12-30 14:48:56 -05:00
- - update avaluo_emision_anual_cabecera set esta_convenio = 0 where emision_id in ( 1583631 , 1481495 , 1587582 , 1529789 ) and esta_convenio = 1
2024-11-21 11:39:26 -05:00
- - update rentas_estado set estado_registro = ' INACTIVO ' where tipo_renta = 0 and registro_lote_id = 56354 and estado_registro < > ' INACTIVO '
2024-11-26 11:40:08 -05:00
- - update agcm_2022_tram_liquidaciones_convenio set estado = ' INACTIVO ' where id = 967
2024-11-21 11:39:26 -05:00
2024-12-30 14:48:56 -05:00
- - GOTO SALIR
2024-11-21 11:39:26 -05:00
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 :