I have calculated a weighted average cost for a new goods of a specific product as following:
inQuantity [received quantity of that product] = 100
inCost [the cost of received goods of that product] = 10
currentQuantity [the quantity in stock of that product] = 50
currentCost [current cost for that product] = 5
totalQuantity [received quantity + current quantity in stock] = in quantity + current quantity
weightedAverage = $$\frac {\text ({inQuantity} \times \text{ inCost}) + \text ({currentQuantity}\times \text { currentCost})} {\text {totalQuantity}}$$
So; the new currentCost will be = 8.3 while I don't have a reference for the old currentCost which was (5).
Now I want to return those goods back, and I want to reverse this calculation, so; the currentCost should return back to (Whatever it was before calculation [ex: 5]).