If you add together the inventory at the start of the period and the purchases during the period, then that is the total that you are hoping to sell.
If they are not all sold and therefore there is inventory left at the end, then if you subtract this from the total you were hoping to see then you are left with the cost of what you actually did sell.