I am working on a stock management application Here is the scenario:
-the user enters the items purchased with the following information (Id of the item, quantity purchased, purchase price, minimum price for wind, date of purchase)
each operation, the user enter the items sold with the following information (Id of the item, quantity sold, the final price of wind, date of the transaction) and each operation I have alerted the user if the the final price wind is less than the minimum price of wind
each operation, a wind I have recorded the benefit of the transaction (the final price wind - purchase price)
The problem is: you can buy the same product in a different time with a different price then we can calculate the common benefit,
for example if I have the following case
items purchased (t-shirt), 10, £ 20, £ 23, 10/08/2012 items purchased (t-shirt), 10, £ 22, £ 25, 19/08/2012
In this case, the operation of wind what I have to do to recover the Article with the correct purchase price and calculate profit and recorded the good information in the sales table?