dbo.Facturacion_enc_

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

21
Name Data Type Length Description
@accion varchar 20
@fac_nro_pedido int 4
@fac_comprobante char 3
@fac_tipo_pedido char 1
@cliente int 4
@cli_codigo int 4
@fac_masiva_libre char 1
@fac_periodo varchar 7
@fac_tipo_factura char 1
@fac_nro_factura_1 smallint 2
@fac_nro_factura int 4
@fac_fecha_fact date 3
@fac_fecha_vto date 3
@fac_neto decimal 9
@fac_iva_1 decimal 9
@fac_iva_2 decimal 9
@fac_total decimal 9
@fac_no_catego decimal 9
@fac_texto varchar 1000
@fac_marca_pago varchar 2
@created_by int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
/*
select * from Facturacion_enc where fac_nro_pedido = 19244
select * from Facturacion_det where fac_nro_pedido = 19244
[Facturacion_enc_] 'pedidos'
[Facturacion_enc_] 'select',19244
exec Facturacion_enc_
'update','19356','FAC','P','2254875','8907','L','2023-08',NULL, NULL, NULL,
'2023-09-04','2023-09-11',
'460','96.6','0','556.6','0', '8907|FIDELITAS SA|30641368977|1|Cabildo 924||CABA||Argentina|54|ARS|1.00','SP','0'

*/

CREATE OR ALTER PROCEDURE dbo.Facturacion_enc_
@accion varchar(20),
@fac_nro_pedido int = NULL,

@fac_comprobante char(3) = NULL,
@fac_tipo_pedido char(1) = NULL,
@cliente    int = NULL,
@cli_codigo    int = NULL,
@fac_masiva_libre  char(1) = NULL,
@fac_periodo      varchar(7) = NULL,
@fac_tipo_factura  char (1) = NULL,
@fac_nro_factura_1  smallint = NULL,
@fac_nro_factura  int     = NULL,
@fac_fecha_fact  date        = NULL,
@fac_fecha_vto  date        = NULL,
@fac_neto      decimal(16, 2) = NULL,
@fac_iva_1      decimal(16, 2) = NULL,
@fac_iva_2      decimal(16, 2) = NULL,
@fac_total      decimal(16, 2) = NULL,
@fac_no_catego  decimal(16, 2) = NULL,
@fac_texto      varchar(1000) = NULL,
@fac_marca_pago  varchar(2) = NULL,
@created_by      int = NULL
AS

BEGIN
    SET NOCOUNT ON;
 if @accion = 'update'
 begin
  update facturacion_enc  
  set 
   cliente = @cliente,   
   cli_codigo = @cli_codigo,
   fac_comprobante = @fac_comprobante,
   fac_masiva_libre = @fac_masiva_libre,
   fac_periodo = @fac_periodo,
   fac_tipo_pedido = @fac_tipo_pedido,
   fac_tipo_factura = @fac_tipo_factura,
   fac_nro_factura_1 = @fac_nro_factura_1,
   fac_nro_factura = @fac_nro_factura,
   fac_fecha_fact = @fac_fecha_fact,
   fac_fecha_vto = @fac_fecha_vto,
   fac_neto = @fac_neto,
   fac_iva_1 = @fac_iva_1,
   fac_iva_2 = @fac_iva_2,
   fac_total = @fac_total,
   fac_no_catego = @fac_no_catego,
   fac_texto = @fac_texto,
   fac_marca_pago = @fac_marca_pago,
   created = getdate(),
   created_by = @created_by
  where fac_nro_pedido = @fac_nro_pedido
   

 end 

 if @accion = 'pedidos'
 begin
  select c.nombre_cliente, f.cli_codigo, f.cliente, f.fac_nro_pedido, f.fac_neto, f.fac_total/*, dd.detalle*/
  from facturacion_enc f
  inner join clientes c on c.cliente = f.cliente
  /*left join (SELECT T.fac_nro_pedido,  detalle=STUFF(
     (SELECT distinct '; ' + (prod_texto + ': $ ' + convert(varchar(20),det_importe)) AS [text()]
   FROM facturacion_det XT
   WHERE XT.fac_nro_pedido = T.fac_nro_pedido
   FOR XML PATH('')), 1, 2, '') 
   FROM facturacion_det T where T.fac_tipo_pedido = 'I' 
   GROUP BY T.fac_nro_pedido) dd on (dd.fac_nro_pedido = f.fac_nro_pedido)*/

  where f.fac_tipo_pedido = 'I' 
  order by f.fac_nro_pedido

 end

 
 if @accion = 'cancelados'
 begin
  select top 50 c.nombre_cliente, f.cli_codigo, f.cliente, f.fac_nro_pedido, f.fac_neto, f.fac_total 
  from facturacion_enc f
  inner join clientes c on c.cliente = f.cliente
  where f.fac_tipo_pedido = 'C' 
  order by f.fac_nro_pedido desc
 end


end 
/*
select * from facturacion_enc where cli_codigo is not null order by fac_nro_pedido desc
select * from clientes where cli_codigo = 8907
exec backend_datos_clientes 2254875
exec cliente_condiciones_ 'select', 2254875
*/


GO

Used By

No items found