dbo.smart_alert_monitoreo

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

3
Name Data Type Length Description
@p_fecha date 3
@busqueda_personalizada bit 1
@cliente int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.smart_alert_monitoreo 
@p_fecha date = null,
@busqueda_personalizada bit = 0,
@cliente int = 110864291

AS
BEGIN
    SET NOCOUNT ON;

   if(@busqueda_personalizada = 0)
   begin
    if(@p_fecha is null)
    BEGIN
      set @p_fecha = convert(date,getdate()-1)
    end
      update monitoreos_resultados set smart_alert = 1 where id_monitoreo in 
      (
      select mr.id_monitoreo
          from monitoreos_resultados as mr

          inner join padrones p 
            on (p.identificacion = mr.cuit and p.habilitado = 1)

          inner join monitoreos m 
              on m.cliente = @cliente 
          and m.cuit =  mr.cuit
          and m.seccion_mantenimiento = mr.seccion_mantenimiento
          and m.visible = 1
          and (m.fecha_vigencia_mantenimiento is null or m.fecha_vigencia_mantenimiento > @p_fecha)
            
          where mr.fecha = @p_fecha
      /* agregado 21/05/2019 para que solo marque como smart_alert las novedades Fiscales(6), Legales(9), Bancos(10), Cheques(18) */
      and mr.seccion_mantenimiento in (6,9,10,18) 
      /**/
            and mr.novedad = 1  
   
      )
       update monitoreos_resultados set smart_alert = 0 where id_monitoreo in 
      (
      select  mr.id_monitoreo
          from monitoreos_resultados as mr

          inner join padrones p 
            on (p.identificacion = mr.cuit and p.habilitado = 1)

          inner join monitoreos m 
              on m.cliente = @cliente 

          inner join ChequesBCRA on id_cheque = id_tabla and fecha_levantamiento is not null 
          and m.cuit =  mr.cuit
          and m.seccion_mantenimiento = mr.seccion_mantenimiento
          and mr.seccion_mantenimiento = 18
          and m.visible = 1
          and (m.fecha_vigencia_mantenimiento is null or m.fecha_vigencia_mantenimiento > @p_fecha)
            
          where mr.fecha = @p_fecha
            and mr.novedad = 1  
      )
     
    end 
END

GO

Used By

No items found