Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.sp_control_balances
AS
BEGIN
declare @errores table (id int, cuit varchar(20), nombre varchar(100), fecha_balance date, estado varchar(20), valor_campo decimal(20,2), valor_cuenta decimal(20,2), error varchar(200), usuario varchar(100))
declare
@nombre varchar(200),
@usuario varchar(200),
@id_balance int,
@cuit varchar(20),
@codigo int,
@fecha_balance date,
@bal_manifestacion char(1),
@ejercicio int,
@periodo smallint,
@monedaifx smallint,
@moneda varchar(3),
@ac_cajban decimal(20,2),
@ac_inver decimal(20,2),
@ac_crevta decimal(20,2),
@ac_otrcre decimal(20,2),
@ac_biecam decimal(20,2),
@ac_otract decimal(20,2),
@ac_bietan decimal(20,2),
@ac_total decimal(20,2),
@anc_crevta decimal(20,2),
@anc_otrcre decimal(20,2),
@anc_inver decimal(20,2),
@anc_actint decimal(20,2),
@anc_otract decimal(20,2),
@anc_bieuso decimal(20,2),
@anc_bieusovo decimal(20,2),
@anc_depacu decimal(20,2),
@anc_total decimal(20,2),
@act_total decimal(20,2),
@pc_ctapag decimal(20,2),
@pc_presta decimal(20,2),
@pc_remune decimal(20,2),
@pc_carfis decimal(20,2),
@pc_antcli decimal(20,2),
@pc_otrpas decimal(20,2),
@pc_total decimal(20,2),
@pnc_cuepag decimal(20,2),
@pnc_previ decimal(20,2),
@pnc_presta decimal(20,2),
@pnc_otrpas decimal(20,2),
@pnc_deufis decimal(20,2),
@pnc_total decimal(20,2),
@pas_total decimal(20,2),
@capsoc decimal(20,2),
@resacu decimal(20,2),
@res_noasig decimal(20,2),
@patrimonio decimal(20,2),
@res_vtanet decimal(20,2),
@res_compras decimal(20,2),
@res_cosmer decimal(20,2),
@amortiza decimal(20,2),
@res_gascom decimal(20,2),
@res_gasadm decimal(20,2),
@res_gasfin decimal(20,2),
@res_otrosing decimal(20,2),
@res_otrosegr decimal(20,2),
@res_resfin decimal(20,2),
@res_iva decimal(20,2),
@ganancia decimal(20,2),
@ebitda decimal(20,2),
@ajucap decimal(20,2),
@estado varchar(20)
SET NOCOUNT ON;
DECLARE C_BAL CURSOR FOR
select padrones.nombre_persona,
users.username,
bc.id_balance,
bc.cuit,
bc.codigo,
bc.fecha_balance,
bc.bal_manifestacion,
bc.ejercicio,
bc.periodo,
bc.monedaifx,
bc.moneda,
isnull(bc.ac_cajban,0),
isnull(bc.ac_inver,0),
isnull(bc.ac_crevta,0),
isnull(bc.ac_otrcre,0),
isnull(bc.ac_biecam,0),
isnull(bc.ac_otract,0),
isnull(bc.ac_bietan,0),
isnull(bc.ac_total,0),
isnull(bc.anc_crevta,0),
isnull(bc.anc_otrcre,0),
isnull(bc.anc_inver,0),
isnull(bc.anc_actint,0),
isnull(bc.anc_otract,0),
isnull(bc.anc_bieuso,0),
isnull(bc.anc_bieusovo,0),
isnull(bc.anc_depacu,0),
isnull(bc.anc_total,0),
isnull(bc.act_total,0),
isnull(bc.pc_ctapag,0),
isnull(bc.pc_presta,0),
isnull(bc.pc_remune,0),
isnull(bc.pc_carfis,0),
isnull(bc.pc_antcli,0),
isnull(bc.pc_otrpas,0),
isnull(bc.pc_total,0),
isnull(bc.pnc_cuepag,0),
isnull(bc.pnc_previ,0),
isnull(bc.pnc_presta,0),
isnull(bc.pnc_otrpas,0),
isnull(bc.pnc_deufis,0),
isnull(bc.pnc_total,0),
isnull(bc.pas_total,0),
isnull(bc.capsoc,0),
isnull(bc.resacu,0),
isnull(bc.res_noasig,0),
isnull(bc.patrimonio,0),
isnull(bc.res_vtanet,0),
isnull(bc.res_compras,0),
isnull(bc.res_cosmer,0),
isnull(bc.amortiza,0),
isnull(bc.res_gascom,0),
isnull(bc.res_gasadm,0),
isnull(bc.res_gasfin,0),
isnull(bc.res_otrosing,0),
isnull(bc.res_otrosegr,0),
isnull(bc.res_resfin,0),
isnull(bc.res_iva,0),
isnull(bc.ganancia,0),
isnull(bc.ebitda,0),
isnull(bc.ajucap,0),
bc.estado
from balances_contables bc
inner join padrones on identificacion = bc.cuit
and habilitado = 1
and identificador in (select identificador from identificadores where country_code = 'AR')
inner join users on users.user_id = bc.modified_by
where bc.bal_manifestacion = 'B'
and bc.created >= '2016-01-01'
and bc.estado != 'ELIMINADO'
OPEN C_Bal
FETCH NEXT FROM C_Bal INTO @nombre,
@usuario,
@id_balance,
@cuit,
@codigo,
@fecha_balance,
@bal_manifestacion,
@ejercicio,
@periodo ,
@monedaifx,
@moneda,
@ac_cajban,
@ac_inver,
@ac_crevta,
@ac_otrcre,
@ac_biecam,
@ac_otract,
@ac_bietan,
@ac_total,
@anc_crevta,
@anc_otrcre,
@anc_inver,
@anc_actint,
@anc_otract,
@anc_bieuso,
@anc_bieusovo,
@anc_depacu,
@anc_total,
@act_total,
@pc_ctapag,
@pc_presta,
@pc_remune,
@pc_carfis,
@pc_antcli,
@pc_otrpas,
@pc_total,
@pnc_cuepag,
@pnc_previ,
@pnc_presta,
@pnc_otrpas,
@pnc_deufis,
@pnc_total,
@pas_total,
@capsoc,
@resacu,
@res_noasig,
@patrimonio,
@res_vtanet,
@res_compras,
@res_cosmer,
@amortiza,
@res_gascom,
@res_gasadm,
@res_gasfin,
@res_otrosing,
@res_otrosegr,
@res_resfin,
@res_iva,
@ganancia,
@ebitda,
@ajucap,
@estado
WHILE @@fetch_status = 0
BEGIN
if (@anc_bieuso != @anc_bieusovo - @anc_depacu)
begin
if ((select COUNT(*) from balances_contables where cuit = @cuit and fecha_balance = DATEADD(year,(-1),@fecha_balance)) > 0 )
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado, @anc_bieuso, (@anc_bieusovo - @anc_depacu), 'BIENES DE USO', @usuario)
end
end
if (@patrimonio != @capsoc + @res_noasig)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@patrimonio,(@capsoc + @res_noasig),
'PATRIMONIO (CAPSOC+RESNOASIG)', @usuario)
end
if (@ac_total != @ac_cajban+
@ac_inver+
@ac_crevta+
@ac_otrcre+
@ac_biecam+
@ac_otract+
@ac_bietan)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@ac_total,
(@ac_cajban+
@ac_inver+
@ac_crevta+
@ac_otrcre+
@ac_biecam+
@ac_otract+
@ac_bietan),
'TOTAL ACTIVO CORRIENTE', @usuario)
end
if (@anc_total != @anc_crevta +
@anc_otrcre+
@anc_inver+
@anc_actint+
@anc_otract+
@anc_bieuso)
begin
insert into @errores values (@id_balance, @cuit, @nombre,@fecha_balance, @estado,
@anc_total,
(@anc_crevta +
@anc_otrcre+
@anc_inver+
@anc_actint+
@anc_otract+
@anc_bieuso),
'TOTAL ACTIVO NO CORRIENTE', @usuario)
end
if (@act_total != @ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@act_total,
(@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso),
'TOTAL ACTIVO', @usuario)
end
if (@pc_total != @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pc_total,
( @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas),
'TOTAL PASIVO CORRIENTE', @usuario)
end
if (@pnc_total != @pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pnc_total,
( @pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis),
'TOTAL PASIVO NO CORRIENTE', @usuario)
end
if (@pas_total != @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pas_total,
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis),
'TOTAL PASIVO', @usuario)
end
if (@patrimonio != (@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
-
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis))
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@patrimonio ,
((@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
-
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)),
'PATRIMONIO (ACTIVO-PASIVO)', @usuario)
end
if (@ganancia != (@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva))
begin
insert into @errores values (@id_balance, @cuit, @nombre,@fecha_balance, @estado,
@ganancia,
((@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)),
'RESULTADO', @usuario)
end
if ( @ebitda != (@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)
+
(@amortiza + @res_gasfin - @res_iva))
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@ebitda,
((@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)
+
(@amortiza + @res_gasfin - @res_iva)),
'EBITDA', @usuario)
end
FETCH NEXT FROM C_Bal INTO @nombre,
@usuario,
@id_balance,
@cuit,
@codigo,
@fecha_balance,
@bal_manifestacion,
@ejercicio,
@periodo ,
@monedaifx,
@moneda,
@ac_cajban,
@ac_inver,
@ac_crevta,
@ac_otrcre,
@ac_biecam,
@ac_otract,
@ac_bietan,
@ac_total,
@anc_crevta,
@anc_otrcre,
@anc_inver,
@anc_actint,
@anc_otract,
@anc_bieuso,
@anc_bieusovo,
@anc_depacu,
@anc_total,
@act_total,
@pc_ctapag,
@pc_presta,
@pc_remune,
@pc_carfis,
@pc_antcli,
@pc_otrpas,
@pc_total,
@pnc_cuepag,
@pnc_previ,
@pnc_presta,
@pnc_otrpas,
@pnc_deufis,
@pnc_total,
@pas_total,
@capsoc,
@resacu,
@res_noasig,
@patrimonio,
@res_vtanet,
@res_compras,
@res_cosmer,
@amortiza,
@res_gascom,
@res_gasadm,
@res_gasfin,
@res_otrosing,
@res_otrosegr,
@res_resfin,
@res_iva,
@ganancia,
@ebitda,
@ajucap,
@estado
END
CLOSE C_Bal
DEALLOCATE C_Bal
select * from @errores order by cuit, fecha_balance
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.sp_control_balances
AS
BEGIN
declare @errores table (id int, cuit varchar(20), nombre varchar(100), fecha_balance date, estado varchar(20), valor_campo decimal(20,2), valor_cuenta decimal(20,2), error varchar(200), usuario varchar(100))
declare
@nombre varchar(200),
@usuario varchar(200),
@id_balance int,
@cuit varchar(20),
@codigo int,
@fecha_balance date,
@bal_manifestacion char(1),
@ejercicio int,
@periodo smallint,
@monedaifx smallint,
@moneda varchar(3),
@ac_cajban decimal(20,2),
@ac_inver decimal(20,2),
@ac_crevta decimal(20,2),
@ac_otrcre decimal(20,2),
@ac_biecam decimal(20,2),
@ac_otract decimal(20,2),
@ac_bietan decimal(20,2),
@ac_total decimal(20,2),
@anc_crevta decimal(20,2),
@anc_otrcre decimal(20,2),
@anc_inver decimal(20,2),
@anc_actint decimal(20,2),
@anc_otract decimal(20,2),
@anc_bieuso decimal(20,2),
@anc_bieusovo decimal(20,2),
@anc_depacu decimal(20,2),
@anc_total decimal(20,2),
@act_total decimal(20,2),
@pc_ctapag decimal(20,2),
@pc_presta decimal(20,2),
@pc_remune decimal(20,2),
@pc_carfis decimal(20,2),
@pc_antcli decimal(20,2),
@pc_otrpas decimal(20,2),
@pc_total decimal(20,2),
@pnc_cuepag decimal(20,2),
@pnc_previ decimal(20,2),
@pnc_presta decimal(20,2),
@pnc_otrpas decimal(20,2),
@pnc_deufis decimal(20,2),
@pnc_total decimal(20,2),
@pas_total decimal(20,2),
@capsoc decimal(20,2),
@resacu decimal(20,2),
@res_noasig decimal(20,2),
@patrimonio decimal(20,2),
@res_vtanet decimal(20,2),
@res_compras decimal(20,2),
@res_cosmer decimal(20,2),
@amortiza decimal(20,2),
@res_gascom decimal(20,2),
@res_gasadm decimal(20,2),
@res_gasfin decimal(20,2),
@res_otrosing decimal(20,2),
@res_otrosegr decimal(20,2),
@res_resfin decimal(20,2),
@res_iva decimal(20,2),
@ganancia decimal(20,2),
@ebitda decimal(20,2),
@ajucap decimal(20,2),
@estado varchar(20)
SET NOCOUNT ON;
DECLARE C_BAL CURSOR FOR
select padrones.nombre_persona,
users.username,
bc.id_balance,
bc.cuit,
bc.codigo,
bc.fecha_balance,
bc.bal_manifestacion,
bc.ejercicio,
bc.periodo,
bc.monedaifx,
bc.moneda,
isnull(bc.ac_cajban,0),
isnull(bc.ac_inver,0),
isnull(bc.ac_crevta,0),
isnull(bc.ac_otrcre,0),
isnull(bc.ac_biecam,0),
isnull(bc.ac_otract,0),
isnull(bc.ac_bietan,0),
isnull(bc.ac_total,0),
isnull(bc.anc_crevta,0),
isnull(bc.anc_otrcre,0),
isnull(bc.anc_inver,0),
isnull(bc.anc_actint,0),
isnull(bc.anc_otract,0),
isnull(bc.anc_bieuso,0),
isnull(bc.anc_bieusovo,0),
isnull(bc.anc_depacu,0),
isnull(bc.anc_total,0),
isnull(bc.act_total,0),
isnull(bc.pc_ctapag,0),
isnull(bc.pc_presta,0),
isnull(bc.pc_remune,0),
isnull(bc.pc_carfis,0),
isnull(bc.pc_antcli,0),
isnull(bc.pc_otrpas,0),
isnull(bc.pc_total,0),
isnull(bc.pnc_cuepag,0),
isnull(bc.pnc_previ,0),
isnull(bc.pnc_presta,0),
isnull(bc.pnc_otrpas,0),
isnull(bc.pnc_deufis,0),
isnull(bc.pnc_total,0),
isnull(bc.pas_total,0),
isnull(bc.capsoc,0),
isnull(bc.resacu,0),
isnull(bc.res_noasig,0),
isnull(bc.patrimonio,0),
isnull(bc.res_vtanet,0),
isnull(bc.res_compras,0),
isnull(bc.res_cosmer,0),
isnull(bc.amortiza,0),
isnull(bc.res_gascom,0),
isnull(bc.res_gasadm,0),
isnull(bc.res_gasfin,0),
isnull(bc.res_otrosing,0),
isnull(bc.res_otrosegr,0),
isnull(bc.res_resfin,0),
isnull(bc.res_iva,0),
isnull(bc.ganancia,0),
isnull(bc.ebitda,0),
isnull(bc.ajucap,0),
bc.estado
from balances_contables bc
inner join padrones on identificacion = bc.cuit
and habilitado = 1
and identificador in (select identificador from identificadores where country_code = 'AR')
inner join users on users.user_id = bc.modified_by
where bc.bal_manifestacion = 'B'
and bc.created >= '2016-01-01'
and bc.estado != 'ELIMINADO'
OPEN C_Bal
FETCH NEXT FROM C_Bal INTO @nombre,
@usuario,
@id_balance,
@cuit,
@codigo,
@fecha_balance,
@bal_manifestacion,
@ejercicio,
@periodo ,
@monedaifx,
@moneda,
@ac_cajban,
@ac_inver,
@ac_crevta,
@ac_otrcre,
@ac_biecam,
@ac_otract,
@ac_bietan,
@ac_total,
@anc_crevta,
@anc_otrcre,
@anc_inver,
@anc_actint,
@anc_otract,
@anc_bieuso,
@anc_bieusovo,
@anc_depacu,
@anc_total,
@act_total,
@pc_ctapag,
@pc_presta,
@pc_remune,
@pc_carfis,
@pc_antcli,
@pc_otrpas,
@pc_total,
@pnc_cuepag,
@pnc_previ,
@pnc_presta,
@pnc_otrpas,
@pnc_deufis,
@pnc_total,
@pas_total,
@capsoc,
@resacu,
@res_noasig,
@patrimonio,
@res_vtanet,
@res_compras,
@res_cosmer,
@amortiza,
@res_gascom,
@res_gasadm,
@res_gasfin,
@res_otrosing,
@res_otrosegr,
@res_resfin,
@res_iva,
@ganancia,
@ebitda,
@ajucap,
@estado
WHILE @@fetch_status = 0
BEGIN
if (@anc_bieuso != @anc_bieusovo - @anc_depacu)
begin
if ((select COUNT(*) from balances_contables where cuit = @cuit and fecha_balance = DATEADD(year,(-1),@fecha_balance)) > 0 )
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado, @anc_bieuso, (@anc_bieusovo - @anc_depacu), 'BIENES DE USO', @usuario)
end
end
if (@patrimonio != @capsoc + @res_noasig)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@patrimonio,(@capsoc + @res_noasig),
'PATRIMONIO (CAPSOC+RESNOASIG)', @usuario)
end
if (@ac_total != @ac_cajban+
@ac_inver+
@ac_crevta+
@ac_otrcre+
@ac_biecam+
@ac_otract+
@ac_bietan)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@ac_total,
(@ac_cajban+
@ac_inver+
@ac_crevta+
@ac_otrcre+
@ac_biecam+
@ac_otract+
@ac_bietan),
'TOTAL ACTIVO CORRIENTE', @usuario)
end
if (@anc_total != @anc_crevta +
@anc_otrcre+
@anc_inver+
@anc_actint+
@anc_otract+
@anc_bieuso)
begin
insert into @errores values (@id_balance, @cuit, @nombre,@fecha_balance, @estado,
@anc_total,
(@anc_crevta +
@anc_otrcre+
@anc_inver+
@anc_actint+
@anc_otract+
@anc_bieuso),
'TOTAL ACTIVO NO CORRIENTE', @usuario)
end
if (@act_total != @ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@act_total,
(@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso),
'TOTAL ACTIVO', @usuario)
end
if (@pc_total != @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pc_total,
( @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas),
'TOTAL PASIVO CORRIENTE', @usuario)
end
if (@pnc_total != @pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pnc_total,
( @pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis),
'TOTAL PASIVO NO CORRIENTE', @usuario)
end
if (@pas_total != @pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@pas_total,
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis),
'TOTAL PASIVO', @usuario)
end
if (@patrimonio != (@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
-
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis))
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@patrimonio ,
((@ac_cajban +
@ac_inver +
@ac_crevta +
@ac_otrcre +
@ac_biecam +
@ac_otract +
@ac_bietan +
@anc_crevta +
@anc_otrcre+
@anc_inver +
@anc_actint+
@anc_otract+
@anc_bieuso)
-
(@pc_ctapag+
@pc_presta+
@pc_remune+
@pc_carfis+
@pc_antcli+
@pc_otrpas+
@pnc_cuepag +
@pnc_previ +
@pnc_presta +
@pnc_otrpas +
@pnc_deufis)),
'PATRIMONIO (ACTIVO-PASIVO)', @usuario)
end
if (@ganancia != (@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva))
begin
insert into @errores values (@id_balance, @cuit, @nombre,@fecha_balance, @estado,
@ganancia,
((@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)),
'RESULTADO', @usuario)
end
if ( @ebitda != (@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)
+
(@amortiza + @res_gasfin - @res_iva))
begin
insert into @errores values (@id_balance, @cuit, @nombre, @fecha_balance, @estado,
@ebitda,
((@res_vtanet
- @res_cosmer
- @res_gascom
- @res_gasadm
- @res_gasfin
+ @res_otrosing
- @res_otrosegr
+ @res_resfin
- @res_iva)
+
(@amortiza + @res_gasfin - @res_iva)),
'EBITDA', @usuario)
end
FETCH NEXT FROM C_Bal INTO @nombre,
@usuario,
@id_balance,
@cuit,
@codigo,
@fecha_balance,
@bal_manifestacion,
@ejercicio,
@periodo ,
@monedaifx,
@moneda,
@ac_cajban,
@ac_inver,
@ac_crevta,
@ac_otrcre,
@ac_biecam,
@ac_otract,
@ac_bietan,
@ac_total,
@anc_crevta,
@anc_otrcre,
@anc_inver,
@anc_actint,
@anc_otract,
@anc_bieuso,
@anc_bieusovo,
@anc_depacu,
@anc_total,
@act_total,
@pc_ctapag,
@pc_presta,
@pc_remune,
@pc_carfis,
@pc_antcli,
@pc_otrpas,
@pc_total,
@pnc_cuepag,
@pnc_previ,
@pnc_presta,
@pnc_otrpas,
@pnc_deufis,
@pnc_total,
@pas_total,
@capsoc,
@resacu,
@res_noasig,
@patrimonio,
@res_vtanet,
@res_compras,
@res_cosmer,
@amortiza,
@res_gascom,
@res_gasadm,
@res_gasfin,
@res_otrosing,
@res_otrosegr,
@res_resfin,
@res_iva,
@ganancia,
@ebitda,
@ajucap,
@estado
END
CLOSE C_Bal
DEALLOCATE C_Bal
select * from @errores order by cuit, fecha_balance
END
GO
Depends On
4Used By
No items found