Cost of goods sold include the costs incurred to buy the materials and bring them in a condition where a company can sell them.
So in practice, cost of goods sold include the material costs, the cost to bring the materials to the factories and other costs which are directly related to the production of a product or to the delivery of a service.
In order to find the cost of goods sold, you take the opening inventory value, you add the purchases made for this year and you then deduct the closing inventory value.