Skip to Content
author's profile photo Former Member
Former Member

Consulta

Buen día Amigos.

Estoy realizando una consulta formateada para el siguiente caso:

Se requiere que en la factura se cargue el almacén de los artículos que se colocan en la orden de venta, y el otro caso es si el usuario entra a la factura de deudor de un solo cargue el almacén por defecto de su usuario ( solo serian usuarios que tendría que tener esa validación)

yo lo he probado de la siguiente manera. me funciona la validación de la orden de venta pero no la del usuario.

Declare @docbase As int

Declare @almacen As char(4)

DECLARE @USUARIO as int

Set @docbase =(Select Count (T0.baseref) From dbo.inv1 T0 Inner Join dbo.oinv T1 on T0.docentry=T1.docentry

Where T1.docnum = $[OINV.DOCNUM.0] AND T0.BaseRef > 0 )

SET @USUARIO = (select INTERNAL_K from OUSR )

if @docbase > 0

begin

SET @almacen = (

SELECT T1.WhsCode FROM dbo.rdr1 T1 INNER JOIN dbo.ordr T2 ON T1.DocEntry = T2.DocEntry

WHERE T2.DocEntry =(select T0.BaseEntry from dbo.INV1 T0 join dbo.oinv T1 on T0.docentry=T1.docentry where T1.docnum = $[OINV.DOCNUM.0])

AND T1.ItemCode = $[RDR1.ITEMCODE.0])

end

if @USUARIO=1

begin

set @almacen =

(SELECT T0.Warehouse FROM OUDG T0 INNER JOIN OUSR T1 ON T0.Code = T1.DfltsGroup WHERE T1.INTERNAL_K = $[USER] )

END

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 10, 2015 at 04:15 PM

    El internal_key de la OUSR con valo 1 siempre es manager

    Entonces te recomiendo que pongas una validacion al campo usersign de la tabla oinv

    Es decir si tu tabla ousr tiene los siguientes usuarios por ejemplo

    Internal_Key usercode

    1 manager

    2 pedro

    3 juan

    usa if @usuario IN (2,3) para que Pedro y Juan sean validados

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.