dbo.Imperium_cumplimiento_total

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@cliente int 4
@periodo int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_cumplimiento_total
@cliente int,
@periodo int

AS


BEGIN
declare @contratista int
declare @qtyC varchar(1)='V'
declare @qtyS varchar(1)='V'
declare @qtyE varchar(1)='V'
declare @qtyV varchar(1)='V'


TRUNCATE TABLE led_docs_cumplimiento_total

DECLARE cumplimiento CURSOR FOR

select DISTINCT CONTRATISTA from led_compliance where contratista in (select distinct contratista from led_contratista_periodo where periodo = @periodo 
and contratista in (select distinct contratista_1 from led_contratistas where cliente = @cliente and estado_contratista='A'))
and periodo = @periodo

OPEN cumplimiento

FETCH NEXT FROM cumplimiento INTO @contratista

WHILE @@fetch_status = 0

 
BEGIN

set @qtyC = 'V'
set @qtyE = 'V'
set @qtyV = 'V'
set @qtyS = 'V'

declare @CC int = 0
declare @EE int = 0
declare @VV int = 0
declare @SS int = 0
/*
select @qtyC =  (select isnull(estado_compliance,'V') from led_compliance where contratista = @contratista and periodo=@periodo and estado_compliance = 'V' and led_seccion='C')
select @qtyE =   (select isnull(estado_compliance,'V') from led_compliance where contratista = @contratista and periodo=@periodo and estado_compliance = 'V' and led_seccion='E')
select @qtyV =  (select isnull(estado_compliance,'V') from led_compliance where contratista = @contratista and periodo=@periodo and estado_compliance = 'V' and led_seccion='V')
select @qtyS =  (select isnull(estado_compliance,'V') from led_compliance where contratista = @contratista and periodo=@periodo and estado_compliance = 'V' and led_seccion='S')
*/




select @CC = count(*) from led_docs where contratista = @contratista and periodo=@periodo and estado_doc!='V' and led_seccion='C'
select @EE = count(*) from led_docs where contratista = @contratista and periodo=@periodo and estado_doc!='V' and led_seccion='E'
select @VV = count(*) from led_docs where contratista = @contratista and periodo=@periodo and estado_doc!='V' and led_seccion='V'
select @SS = count(*) from led_docs where contratista = @contratista and periodo=@periodo and estado_doc!='V' and led_seccion='S'





IF (@qtyC IS NULL)
 BEGIN
  set @qtyC = 'V'
 END

IF (@qtyE IS NULL)
 BEGIN
  set @qtyE = 'V'
 END
IF (@qtyV IS NULL)
 BEGIN
  set @qtyV = 'V'
 END

IF (@qtyS IS NULL)
 BEGIN
  set @qtyS = 'V'
 END

/*
(select count(*) from led_compliance where contratista = 1786 and periodo=202208 and estado_compliance = 'V' and led_seccion='C')
(select count(*) from led_compliance where contratista = 1786 and periodo=202208 and estado_compliance = 'V' and led_seccion='E')
(select count(*) from led_compliance where contratista = 1786 and periodo=202208 and estado_compliance = 'V' and led_seccion='V')
(select count(*) from led_compliance where contratista = 1786 and periodo=202208 and estado_compliance = 'V' and led_seccion='S')

*/



--SELECT @qtyC AS C,@qtyE AS E,@qtyV AS V,@qtyS AS S


--if (@qtyC = 'V' and @qtyE = 'V' and @qtyV = 'V' and @qtyS = 'V')
if (@CC = 0 and @EE = 0 and @VV = 0 and @SS = 0)

begin
insert into led_docs_cumplimiento_total (contraparte,periodo) values (@contratista,@periodo)
end


    FETCH NEXT FROM cumplimiento INTO @contratista

END

CLOSE cumplimiento

DEALLOCATE cumplimiento


select DISTINCT led_docs_cumplimiento_total.CONTRAPARTE, padrones.identificacion as CUIT,padrones.nombre_persona as DENOMINACION,UPPER(led_tipos_contratista.nombre_tipo_contratista) as [TIPO CONTRATISTA],'100%' as CUMPLIMIENTO,@periodo as PERIODO

 from led_docs_cumplimiento_total inner join led_contratistas on led_docs_cumplimiento_total.contraparte = led_contratistas.contratista_1
inner join led_tipos_contratista on led_contratistas.tipo_contratista = led_tipos_contratista.tipo_contratista
inner join padrones on led_contratistas.id_padron=padrones.id_padron
where padrones.habilitado=1 and led_contratistas.estado_contratista = 'A'
AND led_contratistas.contratista=led_contratistas.contratista_1
ORDER BY DENOMINACION

END 

/*
select DISTINCT led_docs_cumplimiento_total.CONTRAPARTE, padrones.identificacion as CUIT,padrones.nombre_persona as DENOMINACION,UPPER(led_tipos_contratista.nombre_tipo_contratista) as [TIPO CONTRATISTA],'100%' as CUMPLIMIENTO

 from led_docs_cumplimiento_total inner join led_contratistas on led_docs_cumplimiento_total.contraparte = led_contratistas.contratista_1
inner join led_tipos_contratista on led_contratistas.tipo_contratista = led_tipos_contratista.tipo_contratista
inner join padrones on led_contratistas.id_padron=padrones.id_padron
where padrones.habilitado=1 and led_contratistas.estado_contratista = 'A'
AND led_contratistas.contratista=led_contratistas.contratista_1
ORDER BY DENOMINACION

*/

GO

Used By

No items found