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
--exec [balances_res_iva]
CREATE OR ALTER PROCEDURE dbo.balances_res_iva
AS
BEGIN
SET NOCOUNT ON;
declare @id int
declare @cant int = 0
DECLARE bn CURSOR
FOR
select distinct idifx
from balances_contables
where res_iva != 0.00
and created_by is null and modified_by is null
OPEN bn
Fetch next from bn INTO @id
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @cant = @cant + 1
update balances_contables
set res_iva = res_iva * (-1),
modified_by = '0'
where idifx = @id
update balances_contables
set ganancia = (isnull(res_vtanet,0)
- isnull(res_cosmer,0)
- isnull(res_gascom,0)
- isnull(res_gasadm,0)
- isnull(res_gasfin,0)
+ isnull(res_otrosing,0)
- isnull(res_otrosegr,0)
+ isnull(res_resfin,0)
- isnull(res_iva,0))
where idifx = @id
update balances_contables
set ebitda = (isnull(ganancia,0) + isnull(amortiza,0) + isnull(res_gasfin,0) - isnull(res_iva,0))
where idifx = @id
update balances_contables
set ind_utilfin = ((isnull(ganancia,0) / isnull(res_vtanet,0)) * 100)
where isnull(res_vtanet,0) != 0
and idifx = @id
update balances_contables
set ind_retpat = (isnull(ganancia,0) / isnull(patrimonio,0))
where isnull(patrimonio,0) != 0
and idifx = @id
update balances_contables
set ind_rentabilidad = ((isnull(ganancia,0) / isnull(act_total,0)) * 100)
where isnull(act_total,0) != 0
and idifx = @id
Fetch next from bn INTO @id
END
CLOSE bn
DEALLOCATE bn
select @cant as 'CANTIDAD PROCESADA'
END
GO
GO
--exec [balances_res_iva]
CREATE OR ALTER PROCEDURE dbo.balances_res_iva
AS
BEGIN
SET NOCOUNT ON;
declare @id int
declare @cant int = 0
DECLARE bn CURSOR
FOR
select distinct idifx
from balances_contables
where res_iva != 0.00
and created_by is null and modified_by is null
OPEN bn
Fetch next from bn INTO @id
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @cant = @cant + 1
update balances_contables
set res_iva = res_iva * (-1),
modified_by = '0'
where idifx = @id
update balances_contables
set ganancia = (isnull(res_vtanet,0)
- isnull(res_cosmer,0)
- isnull(res_gascom,0)
- isnull(res_gasadm,0)
- isnull(res_gasfin,0)
+ isnull(res_otrosing,0)
- isnull(res_otrosegr,0)
+ isnull(res_resfin,0)
- isnull(res_iva,0))
where idifx = @id
update balances_contables
set ebitda = (isnull(ganancia,0) + isnull(amortiza,0) + isnull(res_gasfin,0) - isnull(res_iva,0))
where idifx = @id
update balances_contables
set ind_utilfin = ((isnull(ganancia,0) / isnull(res_vtanet,0)) * 100)
where isnull(res_vtanet,0) != 0
and idifx = @id
update balances_contables
set ind_retpat = (isnull(ganancia,0) / isnull(patrimonio,0))
where isnull(patrimonio,0) != 0
and idifx = @id
update balances_contables
set ind_rentabilidad = ((isnull(ganancia,0) / isnull(act_total,0)) * 100)
where isnull(act_total,0) != 0
and idifx = @id
Fetch next from bn INTO @id
END
CLOSE bn
DEALLOCATE bn
select @cant as 'CANTIDAD PROCESADA'
END
GO
Depends On
1Used By
No items found