Cost of Goods Sold (COGS) is calculated by adding the value of inventory at the start of the period (Opening stock) to the inventory purchased during the period, and then subtracting the inventory left over at the end (Closing stock). The other options represent unrelated accounting relationships.