Skip to content
All guides

Cost of goods sold: what it includes, how to calculate it, and how Xero records it

Cost of goods sold is the cost of the stock you sold, not what you bought. The formula, what belongs in it, a shop worked example, and fixing it in Xero.

Updated 25 October 2026

ReportPilot reads your Xero and emails you what your numbers mean every Monday. Try it free (14 days, no card)

Short answer: cost of goods sold (COGS, called cost of sales in Xero and in most UK, Australian and New Zealand accounts) is what the goods you sold in a period cost you: the stock itself plus the costs of getting it ready to sell, such as freight in, import duty and, for a maker or a trade, materials and direct labour. It is not what you bought in the period. The formula is opening stock + purchases − closing stock. Sales minus cost of goods sold is your gross profit, so if COGS is wrong, your gross margin is wrong too.

What goes in cost of goods sold, and what does not

Usually in cost of goods soldUsually in operating expenses
Stock bought for resaleRent and outgoings
Raw materials and ingredientsOffice and admin wages
Freight and courier costs to bring stock inMarketing and advertising
Import duty and customs feesCard and payment fees
Packaging that is part of the productSoftware and subscriptions
Direct labour making the product or doing the jobInsurance, accounting, phone
Subcontractors on customer jobsDepreciation of shop fit-out and equipment

The test is whether the cost belongs to a specific item or job you sold. If you sold nothing this month, would you still pay it? If yes, it is an operating expense. Service businesses often have little or no cost of goods sold; where they do, it is usually subcontractors and the wages of people doing billable work.

The formula, and why “what I bought” is not the answer

Cost of goods sold = opening stock + purchases − closing stock.

Purchases tell you what came in the door. Stock left on the shelf at the end has not been sold yet, so it is still an asset on the Balance Sheet, not a cost. Stock you started the period with and then sold is a cost of this period, even though you paid for it last period.

A worked example: a homewares shop in Hobart

These figures are made up and exclude GST. Priya runs a homewares shop in Hobart. For the year to 30 June:

LineAmount
Sales300,000
Opening stock (1 July, from last year’s count)38,000
Add: stock purchases, freight in and duty142,000
Less: closing stock (30 June count)(45,000)
Cost of goods sold135,000
Gross profit165,000
Gross margin55.0%

What the formula shows:

  1. Bought is not sold. She bought $142,000 of stock but the goods she sold cost $135,000. The other $7,000 is the stock pile growing from $38,000 to $45,000.
  2. Skipping the stock count understates profit. If her accounts simply expensed every purchase, cost of goods sold would be $142,000, gross profit $158,000 and gross margin 52.7%. That is $7,000 of profit missing from the year, and a margin that looks worse than it is.
  3. The month you stock up looks like a loss. In November Priya buys $30,000 of Christmas stock and sells $25,000. Expensing the purchases, November’s gross profit is 25,000 − 30,000 = −$5,000. At her real cost ratio of 45% (100% − 55%), the goods sold in November cost $11,250, so gross profit was $13,750. The cash really did go out, but it went into stock, which shows up on the Balance Sheet and in profit but no cash, not as a bad month.
  4. The tax position follows the count. Her stock rose by $7,000, which is more than $5,000, so under the ATO’s simplified trading stock rules for small businesses she must account for the change rather than skip it. If the change in a year is $5,000 or less, a small business can choose not to do a formal stocktake. Ask your accountant how this applies to you; New Zealand and the UK have their own rules.

The margin and markup calculator turns a cost price into a selling price at a target margin, and the stock days guide uses the same cost of goods sold figure to show how long stock sits on the shelf. The stock turnover calculator divides it by your average stock to show how many times a year the stock sells through.

How Xero records cost of goods sold

Xero puts every account with the type Direct Costs under Cost of Sales on the Profit and Loss, above gross profit. What lands there depends on how you buy stock:

  1. Tracked inventory items. When an item is set up as tracked, a bill for it goes to the inventory asset account on the Balance Sheet, not to the Profit and Loss. When you invoice the item, Xero moves its cost into the cost of goods sold account at the item’s average cost. This gets the timing right, but only for sales made on Xero invoices with the item on the line.
  2. Untracked items or bills coded straight to Cost of Sales. Most small businesses do this. Every purchase hits the Profit and Loss in the month you buy it, which is the “bought, not sold” problem from the example. Fix it with a stock adjustment: after each stock count (at least at year end, ideally monthly or quarterly), post a manual journal for the change in stock. When stock went up, debit the inventory asset account and credit cost of goods sold; when it went down, the reverse. In Priya’s year that is a $7,000 journal.
  3. A connected inventory or e-commerce app (Shopify, a POS or a stock system). Many post cost of goods sold to Xero for you, often as a journal per day or per month. Check which side does it, so it is not posted twice.

To see the result, run Accounting › Reports › Profit and Loss by month and look at the gross margin line: a month where the margin jumps or collapses with no change in prices usually means stock purchases are being expensed or a journal is missing. The Xero gross profit margin guide explains how to read it. Menu names move between Xero releases and regions, so search Xero Central for the report name if your screen differs.

Common mistakes

  • Treating purchases as cost of goods sold. It works only if your stock level never changes. Count stock and adjust, or margins swing with your buying.
  • Moving shipping to customers and card fees between sections. Many online sellers put them in cost of sales to see a margin after delivery and fees, and that is fine if it is consistent. Coding them to cost of sales one month and to expenses the next is what breaks the comparison.
  • Leaving freight in and duty in expenses. They are part of what the stock cost you. Leaving them out flatters the gross margin and hides price rises from suppliers.
  • Forgetting stock written off. Damaged, stolen or expired stock is a cost too. A count that comes in below what the system expects should flow through to cost of goods sold, not sit as a phantom asset.
  • Using the wrong period’s count. The closing stock for one year is the opening stock for the next. If they do not match, the journal is wrong.

Common questions

What is cost of goods sold? Cost of goods sold is what the goods you sold in a period cost you, including the stock itself and costs like freight in, duty, materials and direct labour. Sales minus cost of goods sold is gross profit.

How do you calculate cost of goods sold? Add opening stock and purchases for the period, then subtract closing stock. With opening stock of $38,000, purchases of $142,000 and closing stock of $45,000, cost of goods sold is $135,000.

Is cost of goods sold the same as cost of sales? In practice yes. Cost of goods sold is the usual term for a business selling products, and cost of sales is the wider term Xero and most UK, Australian and New Zealand accounts use, which also covers direct costs of services such as subcontractors.

Are wages part of cost of goods sold? Only the wages of people who make the product or do the customer work, such as production staff or tradespeople on jobs. Office, admin, sales and management wages are operating expenses.

Why does my gross margin jump around every month in Xero? Usually because stock purchases are coded straight to cost of sales, so a month you stock up looks bad and the following months look good. Posting a stock adjustment journal after each count, or tracking inventory items in Xero, fixes the timing.

Does a service business have cost of goods sold? Often not much. A consultancy or agency may have none, while a service business that uses subcontractors or bills staff time can put those direct costs in cost of sales to see its gross margin per job.

See your margins every Monday

ReportPilot reads your Xero figures and sends a short plain-English email every Monday, with a 24-month dashboard behind it. It covers the cash in the bank against the end of last month, sales and profit against last month and the same month last year, money owed to you that is past due, and bills due in the next two weeks against your cash. It reads cost of sales as Xero reports it and does not count or value your stock. It asks Xero for read-only access, and there is a 14-day free trial with no card.