Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
7| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 10 | |
| @cuit | varchar | 20 | |
| @denominacion | varchar | 160 | |
| @actividad | varchar | 6 | |
| @baja | bit | 1 | |
| @reemplazo | varchar | 11 | |
| @fallecimiento | tinyint | 1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.padron_afip_bcra_full
@accion varchar(10),
@cuit varchar(20),
@denominacion varchar(160),
@actividad varchar(6),
@baja bit,
@reemplazo varchar(11),
@fallecimiento tinyint
AS
/*
exec padron_afip_bcra 'CLAE','CUIT','','960201',0,'REEMPLAZO',0
SELECT * FROM cambios_cuit where fecha='2018-08-27' or fecha='2018-08-28' order by created desc
SELECT * FROM cambios_cuit where cuit='24047586522' or cuit_inactivo='27047586505'
select * from estado_servicios_externos
select * from DATOS_PERSONAS where defuncion=1
*/
declare @CantRows int=0
declare @CantRowsClaeCuit int=0
select @CantRows = (select count(*) from DATOS_PERSONAS where c01_cuit = @cuit)
BEGIN
SET NOCOUNT ON;
DECLARE @d varchar(10) = CONVERT(varchar, getdate(), 23);
if (@accion='CLAE') /* PROCESAMOS EL SUBSET DE CLAE DE PROVINCIA SEGUROS */
BEGIN
Select @CantRows = (SELECT COUNT(*)
from clae_provincia_seguros inner join actividades on clae_provincia_seguros.cod_clae = actividades.codigo_actividad
where clae_provincia_seguros.cod_clae = @actividad)
IF @CantRows > 0
BEGIN
select @CantRowsClaeCuit = (select count(id_clae) from clae where cuit = @cuit and formulario = '883' and visible = 1 and cod_clae=@actividad)
END
/*
DECLARE @p_descripcion_actividad VARCHAR(250) = NULL
IF @actividad = '464410'
BEGIN
SET @p_descripcion_actividad = 'VENTA AL POR MAYOR DE ARTICULOS DE OPTICA Y DE FOTOGRAFIA'
END
IF @actividad = '477410'
BEGIN
SET @p_descripcion_actividad = 'VENTA AL POR MENOR DE ARTICULOS DE OPTICA Y FOTOGRAFIA'
END
insert into clae
(cuit, cod_clae, descripcion, formulario, principal, created, visible)
values (@cuit, @actividad,@p_descripcion_actividad, '883', 1, GETDATE(), 1)
*/
IF @CantRowsClaeCuit = 0
BEGIN
insert into clae (cuit, cod_clae, descripcion, formulario, principal, created, visible,created_by)
select @cuit as cuit,clae_provincia_seguros.cod_clae as cod_clae,actividades.nombre_actividad as descripcion,'883' as formulario,
1 as principal,getdate() as created,1 as visible,15342812 as created_by
from clae_provincia_seguros inner join actividades on clae_provincia_seguros.cod_clae = actividades.codigo_actividad
where clae_provincia_seguros.cod_clae = @actividad
END
END
if (@accion='CAMBIOCUIT')
BEGIN
EXEC insertar_cuit_inactivo_afip @reemplazo,@cuit,@d;
update cambios_cuit set baja_afip = @baja where cuit=@reemplazo
END
if (@accion='DEFUNCION' and @fallecimiento = 1)
BEGIN
if (@CantRows > 0)
begin
update DATOS_PERSONAS set defuncion = 1 where c01_cuit=@cuit
end
if (@CantRows = 0)
begin
insert into DATOS_PERSONAS (c01_cuit,pai_codigo_nacionalidad,doc_codigo,pai_codigo_nacimiento,c02_fecha_act,created,defuncion)
values (@cuit,54,3,54,getdate(),getdate(),@fallecimiento)
end
END
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.padron_afip_bcra_full
@accion varchar(10),
@cuit varchar(20),
@denominacion varchar(160),
@actividad varchar(6),
@baja bit,
@reemplazo varchar(11),
@fallecimiento tinyint
AS
/*
exec padron_afip_bcra 'CLAE','CUIT','','960201',0,'REEMPLAZO',0
SELECT * FROM cambios_cuit where fecha='2018-08-27' or fecha='2018-08-28' order by created desc
SELECT * FROM cambios_cuit where cuit='24047586522' or cuit_inactivo='27047586505'
select * from estado_servicios_externos
select * from DATOS_PERSONAS where defuncion=1
*/
declare @CantRows int=0
declare @CantRowsClaeCuit int=0
select @CantRows = (select count(*) from DATOS_PERSONAS where c01_cuit = @cuit)
BEGIN
SET NOCOUNT ON;
DECLARE @d varchar(10) = CONVERT(varchar, getdate(), 23);
if (@accion='CLAE') /* PROCESAMOS EL SUBSET DE CLAE DE PROVINCIA SEGUROS */
BEGIN
Select @CantRows = (SELECT COUNT(*)
from clae_provincia_seguros inner join actividades on clae_provincia_seguros.cod_clae = actividades.codigo_actividad
where clae_provincia_seguros.cod_clae = @actividad)
IF @CantRows > 0
BEGIN
select @CantRowsClaeCuit = (select count(id_clae) from clae where cuit = @cuit and formulario = '883' and visible = 1 and cod_clae=@actividad)
END
/*
DECLARE @p_descripcion_actividad VARCHAR(250) = NULL
IF @actividad = '464410'
BEGIN
SET @p_descripcion_actividad = 'VENTA AL POR MAYOR DE ARTICULOS DE OPTICA Y DE FOTOGRAFIA'
END
IF @actividad = '477410'
BEGIN
SET @p_descripcion_actividad = 'VENTA AL POR MENOR DE ARTICULOS DE OPTICA Y FOTOGRAFIA'
END
insert into clae
(cuit, cod_clae, descripcion, formulario, principal, created, visible)
values (@cuit, @actividad,@p_descripcion_actividad, '883', 1, GETDATE(), 1)
*/
IF @CantRowsClaeCuit = 0
BEGIN
insert into clae (cuit, cod_clae, descripcion, formulario, principal, created, visible,created_by)
select @cuit as cuit,clae_provincia_seguros.cod_clae as cod_clae,actividades.nombre_actividad as descripcion,'883' as formulario,
1 as principal,getdate() as created,1 as visible,15342812 as created_by
from clae_provincia_seguros inner join actividades on clae_provincia_seguros.cod_clae = actividades.codigo_actividad
where clae_provincia_seguros.cod_clae = @actividad
END
END
if (@accion='CAMBIOCUIT')
BEGIN
EXEC insertar_cuit_inactivo_afip @reemplazo,@cuit,@d;
update cambios_cuit set baja_afip = @baja where cuit=@reemplazo
END
if (@accion='DEFUNCION' and @fallecimiento = 1)
BEGIN
if (@CantRows > 0)
begin
update DATOS_PERSONAS set defuncion = 1 where c01_cuit=@cuit
end
if (@CantRows = 0)
begin
insert into DATOS_PERSONAS (c01_cuit,pai_codigo_nacionalidad,doc_codigo,pai_codigo_nacimiento,c02_fecha_act,created,defuncion)
values (@cuit,54,3,54,getdate(),getdate(),@fallecimiento)
end
END
END
GO
Depends On
5Used By
No items found