hello to all!
i am interested for an FMS query for all marketing documents such as sales orders, sales invoices etc.
the requirements are the following
if the Customer is Excempt then the field Tax Code will be filled with a default value
if the customer is liable, then the Tax Code field will be filled as follows
the vat should be considered from Items(sales or purchasing it depends on the documents)
if the customer is wholesale, then the taxgroup will be 0 or 10 (depending on the itemcode) and if the cistomer is retail will be (20 or 30)
do you have any idea how to implement it?
till now i have made the following code
DECLARE @VATSTATUS NVARCHAR(10)
DECLARE @DEF_VATGOURPSA NVARCHAR(8)
DECLARE @ITEMCODE NVARCHAR(20)
SET @VATSTATUS=(SELECT VATSTATUS FROM OCRD WHERE CARDCODE=$[$4.0.0])
SET @ITEMCODE = (SELECT N$[$38.1.0])
SET @DEF_VATGOURPSA =(SELECT VATGOURPSA FROM OITM WHERE ITEMCODE = @ITEMCODE)
IF @VATSTATUS='N'
BEGIN
SELECT $[$38.18.0]
END
ELSE IF (@VATSTATUS = 'Y')
BEGIN
SELECT @DEF_VATGOURPSA
END