// This script contains the logic which is executed whenever data is entered and sent



//Calculate Target Stock

*WHEN S_INVFLOW
	*IS <> TRGSTOCK
	*REC(EXPRESSION = -([S_INVFLOW].[SALES]+[S_INVFLOW].[PRODREQ])/12, S_INVFLOW = TRGSTOCK)
*ENDWHEN 
 
 //Caclculate what is for Production and Procurement

*WHEN S_PRODUCT.PROCTYPE
	*IS PROD
	*REC(EXPRESSION = -[S_INVFLOW].[STOCK] -[S_INVFLOW].[SALES]-[S_INVFLOW].[PRODREQ] +[S_INVFLOW].[TRGSTOCK], S_INVFLOW = PROD)
*ENDWHEN 

*WHEN S_PRODUCT.PROCTYPE
	*IS PROC
	*REC(EXPRESSION = -[S_INVFLOW].[STOCK] -[S_INVFLOW].[SALES]-[S_INVFLOW].[PRODREQ] +[S_INVFLOW].[TRGSTOCK], S_INVFLOW = PROC)
*ENDWHEN 


