Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 7999

STORED PROCEDURE FOR ITEM COST

$
0
0

Dear Forum Members,

 

I would like to create a stored procedure to block sale of goods below the item cost (Moving Average). I have created the following SP but it still allows sale below cost. Kindly help me troubleshoot it.

 

---- Code for Item Cost Limit ---------------

 

IF @transaction_type IN ('A','U') AND @object_type = '17'and @error = 0

begin

IF EXISTS (select T0.DocNum FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode AND T1.[WhsCode] =  T2.[WhsCode] 

WHERE T0.DOCENTRY = @list_of_cols_val_tab_del AND T1.[PriceBefDi] < T2.[AvgPrice])

BEGIN

SET @error = 41

SET @error_message = 'Item cannot be sold below cost!'

END

END

 

 

I would also prefer to use the variable for price after discount instead of  T1.[PriceBefDi]. How can i do this?

 

Your assistance is greatly appreciated.

 

George Njuguna


Viewing all articles
Browse latest Browse all 7999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>