Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
12| Name | Data Type | Length | Description |
|---|---|---|---|
| @id_balance | varchar | 20 | |
| @cuit | varchar | 20 | |
| @id_padron | int | 4 | |
| @p_bal_manifestacion | char | 1 | |
| @p_fecha_balance | varchar | 10 | |
| @p_ejercicio | int | 4 | |
| @p_periodo | int | 4 | |
| @p_moneda | varchar | 3 | |
| @visible | bit | 1 | |
| @estado | varchar | 50 | |
| @user_id | int | 4 | |
| @doc_id | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.insert_update_balance_led
@id_balance varchar(20),
@cuit varchar(20),
@id_padron int,
@p_bal_manifestacion char(1),
@p_fecha_balance varchar(10),
@p_ejercicio int,
@p_periodo int,
@p_moneda varchar(3),
@visible bit,
@estado varchar(50),
@user_id int,
@doc_id int = null
AS
BEGIN
declare @p_id int
declare @ruta_archivo varchar(200)
if (@p_fecha_balance = '' ) set @p_fecha_balance = null
if (@id_balance = '')
begin set @p_id = null end
else
begin set @p_id = @id_balance end
if (@p_id is null)
begin
IF EXISTS (select * from balances_contables where cuit = @cuit and fecha_balance = convert(date,@p_fecha_balance) and estado = 'CARGA LED')
update balances_contables set estado = 'ELIMINADO', visible = 0
where cuit = @cuit and fecha_balance = convert(date,@p_fecha_balance) and estado = 'CARGA LED'
insert into balances_contables(cuit, id_padron, bal_manifestacion, fecha_balance, ejercicio, periodo, moneda, estado, visible, created, created_by)
values(@cuit, @id_padron, @p_bal_manifestacion, convert(date,@p_fecha_balance), @p_ejercicio, @p_periodo, @p_moneda, @estado, @visible, getdate(), @user_id )
set @p_id = (SELECT @@IDENTITY)
set @ruta_archivo = '/balances/' + ltrim(rtrim(@cuit)) + '/' + convert(varchar,@p_id) + '.pdf'
update balances_contables set ruta_archivo = @ruta_archivo where id_balance = @p_id
end
else
begin
update balances_contables
set cuit = @cuit,
id_padron = @id_padron,
bal_manifestacion = @p_bal_manifestacion,
fecha_balance = convert(date,@p_fecha_balance),
ejercicio = @p_ejercicio,
periodo = @p_periodo,
moneda = @p_moneda,
estado = @estado,
visible = @visible,
modified = getdate(),
modified_by = @user_id
where id_balance = @p_id
set @ruta_archivo = (select ruta_archivo from balances_contables where id_balance = @p_id)
end
if (@doc_id is not null)
begin
declare @periodo int = (select periodo from balances_contables where id_balance = @p_id)
declare @fin date = convert(date,@p_fecha_balance)
declare @inicio date = DATEADD(day,1,DATEADD(month, (-1)*@periodo,@fin))
UPDATE LN_docs SET
doc_log = convert(varchar(max),doc_log)+char(13)+char(10)+left(convert(varchar,getdate(),121),16)+': ingreso de documento',
modified = getdate(),
/*estado_doc = 'N',*/
doc_attach = 1,
ingresado = getdate(),
/*inicio_ejercicio = @inicio,
fin_ejercicio = @fin,*/
id_externo = @p_id,
es_balance = 1
where doc_id = @doc_id
end
select '0' as error, 'El registro se grabó satisfactoriamente' as mensaje, @p_id as id, @ruta_archivo as ruta_archivo
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.insert_update_balance_led
@id_balance varchar(20),
@cuit varchar(20),
@id_padron int,
@p_bal_manifestacion char(1),
@p_fecha_balance varchar(10),
@p_ejercicio int,
@p_periodo int,
@p_moneda varchar(3),
@visible bit,
@estado varchar(50),
@user_id int,
@doc_id int = null
AS
BEGIN
declare @p_id int
declare @ruta_archivo varchar(200)
if (@p_fecha_balance = '' ) set @p_fecha_balance = null
if (@id_balance = '')
begin set @p_id = null end
else
begin set @p_id = @id_balance end
if (@p_id is null)
begin
IF EXISTS (select * from balances_contables where cuit = @cuit and fecha_balance = convert(date,@p_fecha_balance) and estado = 'CARGA LED')
update balances_contables set estado = 'ELIMINADO', visible = 0
where cuit = @cuit and fecha_balance = convert(date,@p_fecha_balance) and estado = 'CARGA LED'
insert into balances_contables(cuit, id_padron, bal_manifestacion, fecha_balance, ejercicio, periodo, moneda, estado, visible, created, created_by)
values(@cuit, @id_padron, @p_bal_manifestacion, convert(date,@p_fecha_balance), @p_ejercicio, @p_periodo, @p_moneda, @estado, @visible, getdate(), @user_id )
set @p_id = (SELECT @@IDENTITY)
set @ruta_archivo = '/balances/' + ltrim(rtrim(@cuit)) + '/' + convert(varchar,@p_id) + '.pdf'
update balances_contables set ruta_archivo = @ruta_archivo where id_balance = @p_id
end
else
begin
update balances_contables
set cuit = @cuit,
id_padron = @id_padron,
bal_manifestacion = @p_bal_manifestacion,
fecha_balance = convert(date,@p_fecha_balance),
ejercicio = @p_ejercicio,
periodo = @p_periodo,
moneda = @p_moneda,
estado = @estado,
visible = @visible,
modified = getdate(),
modified_by = @user_id
where id_balance = @p_id
set @ruta_archivo = (select ruta_archivo from balances_contables where id_balance = @p_id)
end
if (@doc_id is not null)
begin
declare @periodo int = (select periodo from balances_contables where id_balance = @p_id)
declare @fin date = convert(date,@p_fecha_balance)
declare @inicio date = DATEADD(day,1,DATEADD(month, (-1)*@periodo,@fin))
UPDATE LN_docs SET
doc_log = convert(varchar(max),doc_log)+char(13)+char(10)+left(convert(varchar,getdate(),121),16)+': ingreso de documento',
modified = getdate(),
/*estado_doc = 'N',*/
doc_attach = 1,
ingresado = getdate(),
/*inicio_ejercicio = @inicio,
fin_ejercicio = @fin,*/
id_externo = @p_id,
es_balance = 1
where doc_id = @doc_id
end
select '0' as error, 'El registro se grabó satisfactoriamente' as mensaje, @p_id as id, @ruta_archivo as ruta_archivo
END
GO
Depends On
2Used By
No items found