on 04-10-2012 4:35 PM
Estimados,
Tengo definido un TN que valida en el documento factura de ventas que la fecha de vencimiento sea igual a la asignada en la condicion de pago que trae por defecto del SN, en la condicion de pago tengo definido en el campo ExtraMonth el numero de meses y en otras condiciones en el campo ExtraDays el numero de dias, el SP se esta presentando en algunas ocaciones (no es constante) en algunos casos la fecha de vencimiento corresponde ej. 60 o 90 dias (igual a la definida en el SN), aun asi se presenta la validacion.
if @object_type in ('13') and @transaction_type in ('A', 'U')-----------------Factura - Nota Debito
begin
declare @FVCTO datetime
SELECT @FVCTO = T0.DocDate + ((T1.ExtraMonth * 30) + (T1.ExtraDays))
FROM OINV
T0 INNER JOIN OCTG T1 ON T0.GroupNum = T1.GroupNum
WHERE @list_of_cols_val_tab_del
= T0.DocEntry
declare @FVCTODOC datetime
SELECT @FVCTODOC = T0.DocDueDate
FROM OINV
T0 INNER JOIN OCTG T1 ON T0.GroupNum = T1.GroupNum
WHERE @list_of_cols_val_tab_del
= T0.DocEntry
if convert(varchar, @FVCTODOC, 103) <> (convert(varchar,@FVCTO, 103))
begin
set @error = 11
set @error_message
= '** SP VENTAS138: LA FECHA DE VENCIMIENTO DEBE SER EQUIVALENTE AL DE LA CONDICION DE PAGO DEL
CLIENTE'
end
end
Alguno experto en SQL me puede ayudar a organizar el TN para que solo se presente cuando la fecha de vencimiento de la factura NO sea igual a la condicion de pago, de antemano nuchas gracias.
JAMS
Porque no lo armas asi
if @object_type in ('13') and @transaction_type in ('A', 'U')-----------------Factura - Nota Debito
begin
declare @fecha1 as datetime
declare @extramonth as int
declare @extradays as int
SELECT @extramonth =T1.ExtraMonth,@extradays=T1.ExtraDays,@fecha1=t0.docdate
FROM OINV T0 INNER JOIN OCTG T1 ON T0.GroupNum = T1.GroupNum
WHERE @list_of_cols_val_tab_del= T0.DocEntry
if
(SELECT convert(varchar,T0.DocDueDate,103)
FROM OINV T0 WHERE @list_of_cols_val_tab_del= T0.DocEntry)
<>(select convert(varchar, (DATEADD(m,@extramonth,@fecha1)+@extradays), 103))
begin
set @error = 11
set @error_message
= '** SP VENTAS138: LA FECHA DE VENCIMIENTO DEBE SER EQUIVALENTE AL DE LA CONDICION DE PAGO DEL
CLIENTE'
End
end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias por la rutina, también la probé y funciona. Solamente me presenta un inconveniente a la hora de trabajar con facturas con plazos, por lo que la modifiqué de la siguiente forma:
-- ***** Proc: BloqFecVencFact *****
-- Bloquea Cambiar la Fecha de Vencimiento
-- Verifica que la misma sea igual a lo calculado por el tipo de plazo
-- Publicado por Mauricio Quntanilla en http://scn.sap.com/thread/3158813 - 11/04/2012
-- Modificado por: CRNS - 25/10/2012
if @object_type in ('13') and @transaction_type in ('A', 'U')-----------------Factura - Nota Debito
begin
declare @fecha1 as datetime
declare @extramonth as int
declare @extradays as int
declare @cuotas as int
SELECT @extramonth =T1.ExtraMonth,@extradays=T1.ExtraDays,@cuotas=T0.Installmnt, @fecha1=t0.docdate
FROM OINV T0 INNER JOIN OCTG T1 ON T0.GroupNum = T1.GroupNum
WHERE @list_of_cols_val_tab_del= T0.DocEntry
if (@cuotas = 1) AND
(SELECT convert(varchar,T0.DocDueDate,103)
FROM OINV T0 WHERE @list_of_cols_val_tab_del= T0.DocEntry) <>(select convert(varchar, (DATEADD(m,@extramonth,@fecha1)+@extradays), 103))
begin
set @error = 1380
set @error_message= 'LA FECHA DE VENCIMIENTO DEBE SER EQUIVALENTE A LA CONDICION DE PAGO DEL CLIENTE'
End
End
-- ***** Fin Proc: BloqFecVencFact *****
Si la factura es por plazos, SAP bloquea automáticamente la fecha de vencimiento, por lo que no hay problema en que no detenga las que tiene cuota distrintas de 1
Saludos y gracias
C.Navarro
User | Count |
---|---|
95 | |
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.