2024-11-21 11:39:26 -05:00
|
|
|
use telus;
|
|
|
|
|
|
|
|
|
|
/*verificar convenios antes del 2024*/
|
|
|
|
|
|
2024-12-17 09:35:45 -05:00
|
|
|
--exec telus_avaluo_emision_consulta 17848
|
|
|
|
|
|
|
|
|
|
--select * from agcm_2022_tram_liquidaciones_convenio where lote_id = 34950
|
|
|
|
|
--select * from avaluo_emision_anual_cabecera where lote_id = 34950
|
|
|
|
|
select * from rentas_estado WHERE registro_lote_id = 17848;
|
|
|
|
|
select * from rentas_estado WHERE registro_lote_id = 34950;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
exec agcm_2022_tram_liquidaciones_convenio_ingreso 470535,'desactivar',634,56987,268.72,'sdfsdfsdf','ACTIVO','127','',2016,2022
|
|
|
|
|
ALTER PROCEDURE [dbo].[agcm_2022_tram_liquidaciones_convenio_ingreso]
|
|
|
|
|
@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,
|
|
|
|
|
@tipo varchar(100)='AUTO'
|
|
|
|
|
*/
|
|
|
|
|
--exec agcm_2022_tram_liquidaciones_convenio_ingreso 630568, "IP-1305719963", id_convenio, lote_id, valor, "observacion", "ACTIVO", ip, host, desde, hasta
|
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-17 09:35:45 -05:00
|
|
|
from db_olympo_web.dbo.convenios_cabecera where code in('002191');
|
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-17 09:35:45 -05:00
|
|
|
--update avaluo_emision_anual_cabecera set esta_convenio = 0 where emision_id in(2011279)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
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|