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

//Allocate sales prices to the rest of the Profit Centers
*WHEN S_PCENTER
	*IS DISTRIB
	*RUNALLOCATION
		*FACTOR = 
		*DIM S_PCENTER WHAT = DISTRIB ;WHERE<>DISTRIB;
		*DIM S_INVMETRIC WHAT = PRICE ;WHERE = PRICE;
	*ENDALLOCATION 
*ENDWHEN 


//Calculate the Sales Amount on change of QTY or PRICE

*WHEN S_INVMETRIC
	*IS QTY,PRICE
	*REC(EXPRESSION = [S_INVMETRIC].[QTY]*[S_INVMETRIC].[PRICE], S_INVMETRIC = SAMOUNT)
*ENDWHEN

 
//Filter only QTY records and send the data to the Inventory

*XDIM_MEMBERSET S_INVMETRIC = QTY
*XDIM_MEMBERSET S_PCENTER = <All>

*DESTINATION_APP = SF_INVENTORY
*SKIP_DIM = S_PCENTER
*ADD_DIM S_INVFLOW = SALES

*WHEN S_TIME
	*IS *
	*REC(EXPRESSION = %VALUE%*-1)
*ENDWHEN 
