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 prensa_economica
CREATE OR ALTER PROCEDURE dbo.prensa_economica
AS
BEGIN
SET NOCOUNT ON;
declare @p_desde char(10)
declare @p_anio int
declare @dtStart date, @dtEnd date
set @dtEnd = getdate()
set @p_anio = year(@dtEnd)-1
set @p_desde = convert(char(4),@p_anio)+'-01-01'
set @dtStart = convert(date, @p_desde)
select
bc.cuit as 'Cuit',
p.nombre_persona as 'Razon Social',
'Actividad' = isnull((select top 1 clae.descripcion from clae where clae.cuit = bc.cuit order by clae.descripcion desc),''),
bc.fecha_balance as 'Fecha Balance',
monedas.nombre_moneda as 'Moneda',
bc.act_total as 'Total Activo',
bc.pas_total as 'Total Pasivo',
bc.patrimonio as 'Patrimonio',
bc.res_vtanet as 'Venta Neta',
Resultado = (
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)
),
'Cant Empleados' = isnull((select COUNT(*) from empleados where empleados.cuit = bc.cuit and periodo = (select MAX(periodo) from empleados em where em.cuit = bc.cuit)),''),
'Domicilio' = isnull((select top 1 domicilio + ' - ' + loc_nombre + ' - ' + prv_nombre from domicilios_todos where cuit = bc.cuit and tipo_domicilio = 'F'),''),
'Telefono' = isnull((select top 1 telefono from domicilios_todos where cuit = bc.cuit and telefono is not null and ltrim(rtrim(telefono)) != ''),''),
'Socio' = isnull((select top 1 padrones.nombre_persona from socios, cargos, padrones
where c01_cuit = bc.cuit
and c04_ultimo != 'N'
and socios.c01_cuit_soc is not null
and socios.car_codigo = CARGOS.car_codigo
and padrones.identificacion = socios.c01_cuit_soc
order by car_orden),'')
from balances_contables bc
left join monedas
on monedas.moneda = bc.moneda
inner join padrones p
on p.identificacion = cuit
and identificador = 'CUIT'
and p.habilitado = 1
and p.id_padron = (select min(id_padron) from padrones p2
where p2.identificacion = p.identificacion
and p2.habilitado = 1)
where bc.fecha_balance between @dtStart and @dtEnd
and bc.bal_manifestacion = 'B'
and bc.visible = 1
END
GO
GO
--exec prensa_economica
CREATE OR ALTER PROCEDURE dbo.prensa_economica
AS
BEGIN
SET NOCOUNT ON;
declare @p_desde char(10)
declare @p_anio int
declare @dtStart date, @dtEnd date
set @dtEnd = getdate()
set @p_anio = year(@dtEnd)-1
set @p_desde = convert(char(4),@p_anio)+'-01-01'
set @dtStart = convert(date, @p_desde)
select
bc.cuit as 'Cuit',
p.nombre_persona as 'Razon Social',
'Actividad' = isnull((select top 1 clae.descripcion from clae where clae.cuit = bc.cuit order by clae.descripcion desc),''),
bc.fecha_balance as 'Fecha Balance',
monedas.nombre_moneda as 'Moneda',
bc.act_total as 'Total Activo',
bc.pas_total as 'Total Pasivo',
bc.patrimonio as 'Patrimonio',
bc.res_vtanet as 'Venta Neta',
Resultado = (
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)
),
'Cant Empleados' = isnull((select COUNT(*) from empleados where empleados.cuit = bc.cuit and periodo = (select MAX(periodo) from empleados em where em.cuit = bc.cuit)),''),
'Domicilio' = isnull((select top 1 domicilio + ' - ' + loc_nombre + ' - ' + prv_nombre from domicilios_todos where cuit = bc.cuit and tipo_domicilio = 'F'),''),
'Telefono' = isnull((select top 1 telefono from domicilios_todos where cuit = bc.cuit and telefono is not null and ltrim(rtrim(telefono)) != ''),''),
'Socio' = isnull((select top 1 padrones.nombre_persona from socios, cargos, padrones
where c01_cuit = bc.cuit
and c04_ultimo != 'N'
and socios.c01_cuit_soc is not null
and socios.car_codigo = CARGOS.car_codigo
and padrones.identificacion = socios.c01_cuit_soc
order by car_orden),'')
from balances_contables bc
left join monedas
on monedas.moneda = bc.moneda
inner join padrones p
on p.identificacion = cuit
and identificador = 'CUIT'
and p.habilitado = 1
and p.id_padron = (select min(id_padron) from padrones p2
where p2.identificacion = p.identificacion
and p2.habilitado = 1)
where bc.fecha_balance between @dtStart and @dtEnd
and bc.bal_manifestacion = 'B'
and bc.visible = 1
END
GO
Depends On
8Used By
No items found