on 05-27-2010 7:02 PM
Estimados todos, buen día
Tengo un caso que seguramente ustedes habrán experimentado antes:
Resulta ser que dentro de SN existe un cliente con varias localidades (direcciones y tiendas) y a cada uno se le ha creado su código de cliente para saber que se le vende por separado, sin embargo, tengo una validación para que el NIT (número de identificación tributaria) no se repita o bien el SN no se quede sin este dato.
Intento hacer que estos SN tengan un SN de consolidación (para pagos) pero al momento de actualizar la ficha me salta la validación diciendo que el NIT ya existe, ahora bien he pensado que esta validación incluya el campo FatherCard y que al etar vacio restringa y al estar con datos deje pasar. he intentado con el siguiente código pero no me ha funcionado y como tengo poca experiencia en el tema acudo a ustedes para solicitar verifiquen que es lo malo que tengo.
saludos
Declare @Nit2 as nvarchar(20)
, @CardType as nchar(1)
, @CountryDefault as nchar(3)
, @Country as nchar(3)
, @SNC varchar(10)
Select @CountryDefault = 'GT'
Select @Nit2 = T0.U_Nit
, @Country = Country, @SNC= FatherCard
From OCRD T0
Where CardCode = @list_of_cols_val_tab_del
If (@Nit2 Is Null or Len(Rtrim(@Nit2))=0) And @Country = @CountryDefault and (@SNC is null or Len(Rtrim(@SNC))=0)
Begin
set @error = 1
set @error_message = 'Falta NIT de Socio de Negocio.'
end
else
Begin
if @cont > 1 and (@SNC is null or Len(Rtrim(@SNC))=0) -- and @nit <> 'CF' BEGIN
Begin
set @error = 1
set @error_message = 'Ese NIT ya existe....'
End
End
end
A ver intenta con este codigo
IF @transaction_type in ('A') AND @object_type IN ('2')
begin
declare @rfcsn nvarchar(13)
declare @consolida nvarchar(15)
declare @cuenta int
set @rfc=(select lictradnum from ocrd where cardcode=@list_of_cols_val_tab_del)
set @consolida=(select isnull(fathercard,0) from ocrd where cardcode=@list_of_cols_val_tab_del)
set @cuenta= (select count(lictradnum) from ocrd where lictradnum=@rfc)
if @cuenta >1
begin --envia error
set @error=(99)
set @error_message='Este RFC ya existe'
end
if @cuenta=1 and @consolida=0
begin --envia error
set @error=(66)
set @error_message='Falta SN consolidacion'
end
end
Espero te sirva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.