Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
5| Name | Data Type | Length | Description |
|---|---|---|---|
| @cuit | varchar | 20 | |
| @dias | int | 4 | |
| @contraparte | int | 4 | |
| @gestion | int | 4 | |
| @accion | varchar | 5 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
select * from LN_Fidecheck_ws where tipofuente = 'Sancionados'
exec LN_Fidecheck_ws_select '232726'
exec LN_Fidecheck_API '23045417999',45
,191063,189325,'debug'
exec LN_Fidecheck_API '20165050348',45,191693,null,'debug'
-- '232726'
select distinct tipofuente from LN_Fidecheck_ws
*/
-- select * from LN_demo_fidecheck where nombre like 'burgol%'
CREATE OR ALTER PROCEDURE dbo.LN_Fidecheck_API
@cuit varchar(20),
@dias int = 30,
@contraparte int = null,
@gestion int = null,
@accion varchar(5)= null
AS
BEGIN
SET NOCOUNT ON;
set @dias=@dias*-1
--set @dias=0
-- exec LN_Fidecheck_API '20177260909',45,191063,189325,'debug'
if(@accion='debug')
begin
select * from LN_demo_fidecheck where contraparte = @contraparte and gestion = @gestion and tax_id=@cuit and (created > dateadd(day,@dias,GETDATE()) or modified > dateadd(day,@dias,GETDATE()))
select /*top 100 b.id_resultado, */ distinct top 1 @accion as accion,
b.cuit,
b.nombre_persona,
b.id_padron,
b.webservice,
b.StatusCode,
b.Status,
b.Reason,
b.Id,
b.Fuente,
b.NombreModificado,
b.DocumentoBuscado,
b.NombreBuscado,
b.Documento,
--b.TipoFuente,
b.Residencia,
b.DescripcionPais,
b.PaisNoColaborativo,
b.Hallazgos,
b.ExisteDocumentacion,
b.PorcentajeSimilitud,
b.fidecheck,
a.Codigo,
/*case
when b.TipoFuente like 'Noticia%' then convert(date,'2000-01-01') -- (para que las noticias las deje ultimas)
else isnull(a.FechaNovedad,convert(date,'2000-01-01'))
end as FechaNovedad,
convert(varchar(10),convert(date,isnull(a.FechaNovedad,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
*/
/* 27/10/2022: Se toma la fecha created como FechaNovedad */
convert(date,b.created) as FechaNovedad,
convert(varchar(10),convert(date,isnull(b.created,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
a.Cargo,
a.Institucion,
a.Domicilio,
a.NumeroDocumento,
a.NumeroIdTributaria,
a.Url,
isnull(a.Relacion,'') as Relacion,
case
when b.TipoFuente like 'Terrorista%' or b.TipoFuente = 'TER' then 1 -- Positive
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then 2 -- Positive
when b.TipoFuente in ('Sujeto Obligado','Sujetos Obligados','SO') then 9 -- Sujeto Obligado
when isnull(a.relacion,'') != '' then 4 -- Relacionado
when b.TipoFuente like 'Noticia%' then 10 -- (para que las noticias las deje ultimas)
else 3 -- PEP
end as orden,
case
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then
case b.fuente
when 'INHABIL_CAMBIOS' then b.tipoFuente + ' (Inhabilitados para operaciones de cambio B.C.R.A.)'
when 'BCRA_SO' then b.tipoFuente + ' (B.C.R.A.)'
when 'AFIP_EMP_APOC' then b.tipoFuente + ' (Empresas con Facturación Apocrifas)'
else b.tipoFuente
end
else b.TipoFuente
end as TipoFuente,
iif((isnull(a.Cargo,'') != '' or isnull(a.Institucion,'') != ''),'si','no') as con_datos,
iif(B.modified is not null, convert(varchar,B.modified, 103), convert(varchar,B.created,103)) as fecha ,b.visible,b.created,A.PrincipalLista
from LN_Fidecheck_ws B left join LN_Fidecheck_ws_mas_datos A on A.id_resultado = B.id_resultado
--INNER JOIN dbo.DelimitedSplit8K(@p_lista, ',') lista ON lista.item = B.id_resultado
where B.visible = 1 AND (B.cuit = @cuit /*or B.DocumentoBuscado=@cuit*/) and B.created > dateadd(day,@dias,GETDATE())
-- where B.visible = 1 AND B.cuit = '30715233599' and B.created > dateadd(day,-900,GETDATE())
order by B.created desc
-- order by con_datos desc, orden asc, isnull(a.FechaNovedad,convert(date,'2000-01-01')) desc
end
select /*top 100 b.id_resultado, */ distinct --top 1
b.cuit,
b.nombre_persona,
b.id_padron,
b.webservice,
b.StatusCode,
b.Status,
b.Reason,
b.Id,
b.Fuente,
b.NombreModificado,
b.DocumentoBuscado,
b.NombreBuscado,
b.Documento,
--b.TipoFuente,
b.Residencia,
b.DescripcionPais,
b.PaisNoColaborativo,
b.Hallazgos,
b.ExisteDocumentacion,
b.PorcentajeSimilitud,
b.fidecheck,
a.Codigo,
/*
case
when b.TipoFuente like 'Noticia%' then convert(date,'2000-01-01') -- (para que las noticias las deje ultimas)
else isnull(a.FechaNovedad,convert(date,'2000-01-01'))
end as FechaNovedad,
convert(varchar(10),convert(date,isnull(a.FechaNovedad,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
*/
/* 27/10/2022: Se toma la fecha created como FechaNovedad */
convert(date,b.created) as FechaNovedad,
convert(varchar(10),convert(date,isnull(b.created,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
a.Cargo,
a.Institucion,
a.Domicilio,
a.NumeroDocumento,
a.NumeroIdTributaria,
a.Url,
isnull(a.Relacion,'') as Relacion,
case
when b.TipoFuente like 'Terrorista%' or b.TipoFuente = 'TER' then 1 -- Positive
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then 2 -- Positive
when b.TipoFuente in ('Sujeto Obligado','Sujetos Obligados','SO') then 9 -- Sujeto Obligado
when isnull(a.relacion,'') != '' then 4 -- Relacionado
when b.TipoFuente like 'Noticia%' then 10 -- (para que las noticias las deje ultimas)
else 3 -- PEP
end as orden,
case
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then
case b.fuente
when 'INHABIL_CAMBIOS' then b.tipoFuente + ' (Inhabilitados para operaciones de cambio B.C.R.A.)'
when 'BCRA_SO' then b.tipoFuente + ' (B.C.R.A.)'
when 'AFIP_EMP_APOC' then b.tipoFuente + ' (Empresas con Facturación Apocrifas)'
else b.tipoFuente
end
else b.TipoFuente
end as TipoFuente,
iif((isnull(a.Cargo,'') != '' or isnull(a.Institucion,'') != ''),'si','no') as con_datos,
iif(B.modified is not null, convert(varchar,B.modified, 103), convert(varchar,B.created,103)) as fecha ,b.visible,b.created,A.PrincipalLista
from LN_Fidecheck_ws B left join LN_Fidecheck_ws_mas_datos A on A.id_resultado = B.id_resultado
--INNER JOIN dbo.DelimitedSplit8K(@p_lista, ',') lista ON lista.item = B.id_resultado
-- where B.visible = 1 AND (B.cuit = @cuit /*or B.DocumentoBuscado=@cuit*/) and B.created > dateadd(day,@dias,GETDATE())
where B.visible = 1 AND (B.cuit = @cuit or B.DocumentoBuscado=@cuit) and B.created > dateadd(day,@dias,GETDATE())
-- where B.visible = 1 AND B.cuit = '30715233599' and B.created > dateadd(day,-900,GETDATE())
-- order by B.created desc
-- order by con_datos desc, orden asc, isnull(a.FechaNovedad,convert(date,'2000-01-01')) desc
order by orden asc
END
/*
select a.TipoFuente, * from LN_Fidecheck_ws a
inner join LN_Fidecheck_ws_mas_datos b on b.id_resultado = a.id_resultado
where (cuit = '20106615854' or DocumentoBuscado = '20106615854') and a.visible = 1
*/
GO
GO
/*
select * from LN_Fidecheck_ws where tipofuente = 'Sancionados'
exec LN_Fidecheck_ws_select '232726'
exec LN_Fidecheck_API '23045417999',45
,191063,189325,'debug'
exec LN_Fidecheck_API '20165050348',45,191693,null,'debug'
-- '232726'
select distinct tipofuente from LN_Fidecheck_ws
*/
-- select * from LN_demo_fidecheck where nombre like 'burgol%'
CREATE OR ALTER PROCEDURE dbo.LN_Fidecheck_API
@cuit varchar(20),
@dias int = 30,
@contraparte int = null,
@gestion int = null,
@accion varchar(5)= null
AS
BEGIN
SET NOCOUNT ON;
set @dias=@dias*-1
--set @dias=0
-- exec LN_Fidecheck_API '20177260909',45,191063,189325,'debug'
if(@accion='debug')
begin
select * from LN_demo_fidecheck where contraparte = @contraparte and gestion = @gestion and tax_id=@cuit and (created > dateadd(day,@dias,GETDATE()) or modified > dateadd(day,@dias,GETDATE()))
select /*top 100 b.id_resultado, */ distinct top 1 @accion as accion,
b.cuit,
b.nombre_persona,
b.id_padron,
b.webservice,
b.StatusCode,
b.Status,
b.Reason,
b.Id,
b.Fuente,
b.NombreModificado,
b.DocumentoBuscado,
b.NombreBuscado,
b.Documento,
--b.TipoFuente,
b.Residencia,
b.DescripcionPais,
b.PaisNoColaborativo,
b.Hallazgos,
b.ExisteDocumentacion,
b.PorcentajeSimilitud,
b.fidecheck,
a.Codigo,
/*case
when b.TipoFuente like 'Noticia%' then convert(date,'2000-01-01') -- (para que las noticias las deje ultimas)
else isnull(a.FechaNovedad,convert(date,'2000-01-01'))
end as FechaNovedad,
convert(varchar(10),convert(date,isnull(a.FechaNovedad,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
*/
/* 27/10/2022: Se toma la fecha created como FechaNovedad */
convert(date,b.created) as FechaNovedad,
convert(varchar(10),convert(date,isnull(b.created,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
a.Cargo,
a.Institucion,
a.Domicilio,
a.NumeroDocumento,
a.NumeroIdTributaria,
a.Url,
isnull(a.Relacion,'') as Relacion,
case
when b.TipoFuente like 'Terrorista%' or b.TipoFuente = 'TER' then 1 -- Positive
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then 2 -- Positive
when b.TipoFuente in ('Sujeto Obligado','Sujetos Obligados','SO') then 9 -- Sujeto Obligado
when isnull(a.relacion,'') != '' then 4 -- Relacionado
when b.TipoFuente like 'Noticia%' then 10 -- (para que las noticias las deje ultimas)
else 3 -- PEP
end as orden,
case
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then
case b.fuente
when 'INHABIL_CAMBIOS' then b.tipoFuente + ' (Inhabilitados para operaciones de cambio B.C.R.A.)'
when 'BCRA_SO' then b.tipoFuente + ' (B.C.R.A.)'
when 'AFIP_EMP_APOC' then b.tipoFuente + ' (Empresas con Facturación Apocrifas)'
else b.tipoFuente
end
else b.TipoFuente
end as TipoFuente,
iif((isnull(a.Cargo,'') != '' or isnull(a.Institucion,'') != ''),'si','no') as con_datos,
iif(B.modified is not null, convert(varchar,B.modified, 103), convert(varchar,B.created,103)) as fecha ,b.visible,b.created,A.PrincipalLista
from LN_Fidecheck_ws B left join LN_Fidecheck_ws_mas_datos A on A.id_resultado = B.id_resultado
--INNER JOIN dbo.DelimitedSplit8K(@p_lista, ',') lista ON lista.item = B.id_resultado
where B.visible = 1 AND (B.cuit = @cuit /*or B.DocumentoBuscado=@cuit*/) and B.created > dateadd(day,@dias,GETDATE())
-- where B.visible = 1 AND B.cuit = '30715233599' and B.created > dateadd(day,-900,GETDATE())
order by B.created desc
-- order by con_datos desc, orden asc, isnull(a.FechaNovedad,convert(date,'2000-01-01')) desc
end
select /*top 100 b.id_resultado, */ distinct --top 1
b.cuit,
b.nombre_persona,
b.id_padron,
b.webservice,
b.StatusCode,
b.Status,
b.Reason,
b.Id,
b.Fuente,
b.NombreModificado,
b.DocumentoBuscado,
b.NombreBuscado,
b.Documento,
--b.TipoFuente,
b.Residencia,
b.DescripcionPais,
b.PaisNoColaborativo,
b.Hallazgos,
b.ExisteDocumentacion,
b.PorcentajeSimilitud,
b.fidecheck,
a.Codigo,
/*
case
when b.TipoFuente like 'Noticia%' then convert(date,'2000-01-01') -- (para que las noticias las deje ultimas)
else isnull(a.FechaNovedad,convert(date,'2000-01-01'))
end as FechaNovedad,
convert(varchar(10),convert(date,isnull(a.FechaNovedad,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
*/
/* 27/10/2022: Se toma la fecha created como FechaNovedad */
convert(date,b.created) as FechaNovedad,
convert(varchar(10),convert(date,isnull(b.created,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
a.Cargo,
a.Institucion,
a.Domicilio,
a.NumeroDocumento,
a.NumeroIdTributaria,
a.Url,
isnull(a.Relacion,'') as Relacion,
case
when b.TipoFuente like 'Terrorista%' or b.TipoFuente = 'TER' then 1 -- Positive
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then 2 -- Positive
when b.TipoFuente in ('Sujeto Obligado','Sujetos Obligados','SO') then 9 -- Sujeto Obligado
when isnull(a.relacion,'') != '' then 4 -- Relacionado
when b.TipoFuente like 'Noticia%' then 10 -- (para que las noticias las deje ultimas)
else 3 -- PEP
end as orden,
case
when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then
case b.fuente
when 'INHABIL_CAMBIOS' then b.tipoFuente + ' (Inhabilitados para operaciones de cambio B.C.R.A.)'
when 'BCRA_SO' then b.tipoFuente + ' (B.C.R.A.)'
when 'AFIP_EMP_APOC' then b.tipoFuente + ' (Empresas con Facturación Apocrifas)'
else b.tipoFuente
end
else b.TipoFuente
end as TipoFuente,
iif((isnull(a.Cargo,'') != '' or isnull(a.Institucion,'') != ''),'si','no') as con_datos,
iif(B.modified is not null, convert(varchar,B.modified, 103), convert(varchar,B.created,103)) as fecha ,b.visible,b.created,A.PrincipalLista
from LN_Fidecheck_ws B left join LN_Fidecheck_ws_mas_datos A on A.id_resultado = B.id_resultado
--INNER JOIN dbo.DelimitedSplit8K(@p_lista, ',') lista ON lista.item = B.id_resultado
-- where B.visible = 1 AND (B.cuit = @cuit /*or B.DocumentoBuscado=@cuit*/) and B.created > dateadd(day,@dias,GETDATE())
where B.visible = 1 AND (B.cuit = @cuit or B.DocumentoBuscado=@cuit) and B.created > dateadd(day,@dias,GETDATE())
-- where B.visible = 1 AND B.cuit = '30715233599' and B.created > dateadd(day,-900,GETDATE())
-- order by B.created desc
-- order by con_datos desc, orden asc, isnull(a.FechaNovedad,convert(date,'2000-01-01')) desc
order by orden asc
END
/*
select a.TipoFuente, * from LN_Fidecheck_ws a
inner join LN_Fidecheck_ws_mas_datos b on b.id_resultado = a.id_resultado
where (cuit = '20106615854' or DocumentoBuscado = '20106615854') and a.visible = 1
*/
GO
Used By
No items found