How to calculate cost of goods sold, with a worked example
Updated
Cost of goods sold is what the stock you sold cost you. Subtract it from revenue and you have gross profit — the number that tells you whether your prices work. The formula is short; the mistakes are in what goes into it and in the stock count it depends on.
The formula
COGS = beginning inventory + purchases − ending inventory.
Read it as: what you had, plus what you bought, minus what is left. Whatever is no longer on the shelf was sold — or lost, which is the catch covered below. All three figures are at cost, never at selling price.
A worked example
| Line | Amount (฿) |
|---|---|
| Beginning inventory, 1 October | 40,000 |
| + Purchases during October | 120,000 |
| + Inbound freight on those purchases | 5,000 |
| = Goods available for sale | 165,000 |
| − Ending inventory, 31 October | 50,000 |
| = Cost of goods sold | 115,000 |
With October revenue of ฿180,000, gross profit is 180,000 − 115,000 = ฿65,000, a gross margin of 36.1%.
Get COGS your accountant can reconcile
Import your products, do one opening count, and Proterate Stock costs every sale at moving average with freight included. COGS and valuation reports export to XLSX.
Get startedWhat belongs in cost, and what does not
| Include in inventory cost | Leave out — these are selling expenses |
|---|---|
| Purchase price from the supplier | Shipping to your customer |
| Inbound freight to your warehouse | Marketplace commission and payment fees |
| Import duty on the goods | Advertising |
| Discounts received reduce cost | Packing staff wages and rent |
The most common mistake is leaving inbound freight out. It makes every unit look cheaper than it was and your margin look better than it is.
Why the stock count decides your profit
Ending inventory comes from a count, and everything the count misses lands in COGS. Count ฿5,000 more stock than is really there and COGS in the example drops to ฿110,000 — gross profit jumps to ฿70,000 (38.9%) on paper. The error surfaces next period, when that stock is not there to sell.
This also means the periodic formula quietly puts theft, damage, and miscounts inside COGS. You cannot tell from the result whether you sold the stock or lost it.
Periodic vs perpetual: two ways to get the same number
The formula above is the periodic method: work COGS out once, at period end, from a count. The perpetual method records the cost of each sale as it happens, so COGS is always current and the count becomes a check rather than the source. When the two disagree, the difference is shrinkage you can see and investigate rather than absorb.
Perpetual records need a cost for each unit sold. When you bought the same item at different prices, that cost comes from your costing method — FIFO or moving average.
COGS in Proterate Stock
Proterate Stock keeps a perpetual ledger at moving-average cost, recalculated on every receipt, with freight allocated across the receipt so cost per unit is the real one. Its COGS and stock-valuation reports reconcile to that ledger and export to XLSX for your accountant. It is not accounting software and does not give tax advice; it produces the stock and cost side cleanly so it can be handed over.
Frequently asked
Is COGS the same as total purchases?
No. Purchases are what you bought; COGS is what you sold. Stock bought this month and still on the shelf is inventory, not COGS.
Do shipping costs count in COGS?
Freight to bring goods into your warehouse does. Shipping orders out to customers is a selling expense and does not.
Do marketplace fees count in COGS?
No. Commissions and payment fees are costs of selling, not of the goods. They reduce net profit, not gross profit.
What if I have never done a stock count?
Then you do not know ending inventory, so you do not know COGS. One full count sets a reliable starting balance; after that, a perpetual record keeps it current.