dbo.cliente_condiciones_

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

9
Name Data Type Length Description
@accion varchar 10
@cliente int 4
@cli_codigo int 4
@iva int 4
@moneda char 3
@forma_cobro char 1
@dias_vto_factura int 4
@tolerancia_mora int 4
@user_id int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================

CREATE OR ALTER PROCEDURE dbo.cliente_condiciones_
@accion varchar(10),
@cliente int, 
@cli_codigo int = null,
@iva int = null,
@moneda char(3) = null,
@forma_cobro char(1) = null,
@dias_vto_factura int = null,
@tolerancia_mora int = null,
@user_id int = null 
AS

BEGIN
    SET NOCOUNT ON;
 if @accion = 'select'
 begin
  select  c.cli_resiva, 
     cc.moneda, cc.forma_cobro,
    cc.tolerancia_mora     ,
    cc.bloquea_mes         ,
    cc.cant_mes            ,
    cc.dias_vto_factura,
    cc.e_mail_factura       
  from clientes c
  left join cliente_condiciones cc on cc.cliente = c.cliente 
  where c.cliente = @cliente 
 end 
 if @accion = 'update'
 begin
  if exists (select * from cliente_condiciones where cliente = @cliente) 
   update cliente_condiciones
   set moneda = @moneda,
    forma_cobro = @forma_cobro,
    dias_vto_factura = @dias_vto_factura,
    tolerancia_mora = @tolerancia_mora,
    modified_by = @user_id, 
    modified = GETDATE()
   where cliente = @cliente
  else 
  begin
   insert cliente_condiciones (cliente, cli_codigo, moneda, forma_cobro, dias_vto_factura, tolerancia_mora, created, created_by) 
   values (@cliente, @cli_codigo, @moneda, @forma_cobro, @dias_vto_factura, @tolerancia_mora, GETDATE(), @user_id) 
  end

  update clientes set cli_resiva = @iva where cliente = @cliente

  select 'ok' as respuesta
 end 
end 

/*
[cliente_condiciones_] 'select',2254875
select cli_resiva, * from clientes where cliente = 2254875
*/


GO

Used By

No items found