Cost per sale transaction

Hi,

I would like to add a Cost of Sales transaction with every sales transaction. My request is if it is possible to calculate the total cost of a ticket. e.g. Method to calculate the total cost of all the products based on their recipes one the current ticket?

Thanks