At the time of creating a product with a batch, you can associate the cost with that batch.
Not every lot has the same cost and you would need to know the margin of each one.