top of page

What Is Cost of Goods Sold? Formula, Methods and Examples

2 days ago
12 min read
What is cost of goods sold? Learn the formula, FIFO vs average cost, worked examples for retail and services, and how to record COGS in QuickBooks and Xero.

Cost of goods sold is the direct cost of the products sold or the services delivered in a period, and the formula is beginning inventory plus purchases minus ending inventory. A shop that starts with $80,000 of stock, buys $420,000, and still holds $100,000 at year end has $400,000 of cost of goods sold.


You are probably looking at a delivery of flour, butter, and pastry boxes and wondering which of those dollars belong in this month's profit. The sack still on the shelf is not an expense yet. The butter that went into the 300 pastries you sold this week is. That split is what cost of goods sold is for, and it is the line that turns an inventory decision into gross profit and, later, tax.


Table of Contents



What Cost of Goods Sold Means and How to Calculate It


A bakery sells 300 pastries this week. The flour and butter used in those pastries belong in cost of goods sold (COGS), while the unused flour sack stays in inventory. That distinction determines how much of the bakery's spending reduces this period's profit.


COGS is the direct cost of products sold, or services delivered, during a period. It usually includes raw materials, direct labor, and the purchase cost of goods resold. On the income statement, subtract COGS from net revenue to find gross profit. For example, net sales of $500,000 minus COGS of $300,000 leaves $200,000 in gross profit, a 40% gross margin.


The calculation connects inventory records to that profit figure:


Beginning inventory + purchases and other inventory costs − ending inventory = COGS.


A diagram explaining how to calculate cost of goods sold using a baker example for ingredients.

Suppose the bakery begins with $5,000 of ingredients, buys $12,000 more during the period, and has $4,000 of unused ingredients at the end. Its COGS is $13,000: $5,000 + $12,000 − $4,000. The remaining $4,000 is still an asset, not a cost charged to this period. It carries forward as the next period's opening inventory.


That distinction matters in your books. Purchases increase the inventory available, but they do not automatically become COGS when you buy them. The ending count shows how much remains on hand, so the formula assigns the cost of what was sold to the current period and leaves unsold stock for later.


Businesses apply the same logic to different records. An online seller may include the supplier invoice, inbound freight, customs, and other costs of acquiring items. A manufacturer may track raw materials, work in process, finished goods, direct labor, and a share of factory overhead. Keeping inventory and operating expenses separate helps explain why inventory accounting matters, especially when comparing products across months.


Costs that cannot be tied to the goods sold, such as administrative salaries, marketing, corporate office rent, and research, sit below gross profit as operating expenses. Recording purchases or direct production costs incorrectly changes both taxable income and the margin used to price products.


Before closing a period, gather three figures from your records: opening stock value, purchases during the period, and counted closing stock value. Use consistent inventory records to connect those figures to the products that sold.


Which Costs Belong in COGS and Which Do Not


A cost belongs in COGS when you can tie it directly to making or acquiring what was sold. It stays out when it keeps the business running whether or not anything sells.


Cost

Typical business

In COGS?

Reason

Purchase price of resold goods

Retail, e-commerce

Yes

Direct cost of the item sold

Inbound freight and customs duties

E-commerce, importers

Yes

Needed to get the item to a sellable state

Raw materials and components

Manufacturing

Yes

Become part of the finished product

Direct production labor

Manufacturing

Yes

Labor that makes the product

Allocated factory overhead (utilities, plant rent share)

Manufacturing

Yes, allocated

Production cost spread across units

Staff or contractors delivering client work

Services

Yes, as cost of revenue

Directly delivers the service sold

Inventory write-downs and shrinkage

Retail, e-commerce

Yes

Reduces the value of stock sold or lost

Marketing and advertising

All types

No

Operating expense that continues without sales

Office rent and administrative salaries

All types

No

Indirect overhead

Sales commissions

All types

No

Selling expense

Payment processing fees

E-commerce

Usually no

Selling expense in most small business books; confirm with an accountant


Retail and ecommerce owners often stumble over freight. The truck that brings goods to your warehouse is part of getting the item ready to sell, so it rides with inventory and then into COGS. The label you buy to ship a parcel to a customer is a selling cost and stays below gross profit. Duties work the same way as inbound freight. For a closer look at how landed cost and product cost diverge for online brands, the inventory cost distinctions for DTC brands walk through the pieces importers typically pay.


Gray areas that show up in real books


Payment processing fees from Shopify, Stripe, or Amazon are the question owners ask most. Most small business books record them as selling expenses, not COGS. Confirm the treatment with your accountant before you move a large fee total, because the choice changes gross margin even when net profit stays the same.


Factory overhead is the other fuzzy one. Plant rent and production utilities can be spread across units. The same dollar of rent on a front office cannot. Service firms have no shelf of goods, so the test shifts to people: staff or contractors who deliver the client work are a cost of revenue, while the office manager is not.


If the cost disappears when nothing sells, it is probably COGS. If it keeps running when sales stop, it is probably an operating expense.

Map those choices onto account numbers before the first bill hits. A clean chart of accounts setup keeps purchase price, freight-in, and selling fees from landing in the same bucket.


Which Inventory Method Changes Your COGS and Which to Choose


Picture a grocery cooler. Staff either pull older milk forward or mix old cartons with new ones. That habit decides which cost hits the register, even when the number of cartons sold doesn't change.


Use one purchase history for every method. You buy 100 units at $10, then 100 units at $12, and you sell 150. 150 units leave. 50 stay.


A comparison chart showing how FIFO, LIFO, and weighted average methods affect cost of goods sold.

Method

How it picks cost

COGS for 150 units

Ending inventory (50 units)

FIFO

Oldest costs leave first

$1,600

$600

Weighted average

One blended cost of $11 per unit

$1,650

$550

LIFO (US tax reporting only)

Newest costs leave first

$1,700

$500

Specific identification

Actual cost of each unit sold

Depends on units sold

Actual cost of units left


What each method does to profit


FIFO sends the first-in costs out first: 100 units at $10 plus 50 at $12, so COGS is $1,600 and the 50 unsold units are worth $600. When purchase prices rise, FIFO reports the lower COGS and the higher gross profit.


Weighted average blends the two buys into $11 a unit. COGS is $1,650 and ending stock is $550. The margin doesn't jump every time a supplier raises a price.


LIFO sends the newest costs out first: 100 at $12 plus 50 at $10, so COGS is $1,700 and ending stock is $500. In the United States it is a tax method that generally requires a Form 970 election, and it isn't available under IFRS. Gross profit moves dollar for dollar the other way from COGS, so the same 150 units produce a different profit and a different tax bill under each method.


Specific identification fits serialized goods, a piece of jewelry, a vehicle, a custom machine, where you can point at the invoice for that exact unit.


When prices are steady, pick the simplest method your software already supports. When prices rise, FIFO shows higher profit and tax, while weighted average smooths both.

A routine you can keep


  1. Write a one-page costing policy that names the method, the cutoff date, and which costs (invoice, freight, duty) enter the unit cost.

  2. Apply that method every year. Changing it for tax purposes usually needs IRS approval, so don't switch because one quarter looks better.

  3. Count stock at least at year end, and quarterly if you can.

  4. Each quarter, write down aged stock you can no longer sell at cost. The lower of cost or market test is the rule that forces that step.

  5. Track gross margin monthly. If it drops more than a few points and sales volume didn't change, look at price increases, shrinkage, or discounting before you blame overhead.


COGS Worked Examples for Four Business Types


The same formula changes shape once the business changes. Start with a retail boutique, then see what an online seller, a small plant, and a consultancy put in the blank.


A boutique opens with $40,000 of stock, buys $150,000, and counts $35,000 still on the racks. COGS is $155,000. On net sales of $250,000, gross profit is $95,000, a 38% margin.


  1. Value opening stock from last year's closing count, not from a guess.

  2. Add every purchase invoice, net of supplier discounts, plus freight in.

  3. Count and value closing stock at cost, using the method you already chose.

  4. Subtract closing stock from the sum. That result is COGS.

  5. Divide gross profit by sales to get the margin you will compare next month.


Three more shapes of the same math


An ecommerce seller buys 2,000 units at $12, which is $24,000, then pays $2,400 of freight and $1,200 of duties. Landed cost is $27,600, or $13.80 a unit. Selling 1,500 units puts $20,700 in COGS. The other 500 units stay in inventory at $13.80. There is no sales price in this example, so gross profit isn't computed yet.


A small manufacturer uses $60,000 of raw materials, $40,000 of direct labor, and $20,000 of allocated overhead. Finished goods rise from $10,000 to $15,000, so $5,000 of production is still unsold. COGS is $115,000. If you also build to stock, the cost of goods manufactured is the bridge between the factory floor and that finished-goods change.


A consultancy has no shelf. $60,000 of staff cost spent delivering client work, against $150,000 of revenue, leaves $90,000 of gross profit, a 60% margin. Call the line cost of revenue if "goods" feels wrong. The test is the same: only the cost of delivering the work.


Business type

Gross profit and margin

Retail boutique

Gross profit $95,000, margin 38% on $250,000 sales

E-commerce seller

COGS $20,700; no sales price given, so gross profit isn't computed

Small manufacturer

COGS $115,000; no sales figure given, so margin isn't computed

Service consultancy

Gross profit $90,000, margin 60% on $150,000 revenue


The IRS Publication 334 requires a business that produces, purchases, or sells merchandise as an income-producing factor to value inventory at the start and end of each tax year. On Schedule C, beginning inventory goes on line 35, purchases and related costs are added through line 40, ending inventory goes on line 41, and COGS lands on line 42. A business that begins with $80,000, purchases $420,000, and ends with $100,000 reports $400,000 of COGS. That ending $100,000 is not this year's expense. It remains an asset and normally becomes next year's beginning inventory. Invoice price net of discounts, transportation, and, where production rules apply, direct and indirect costs can all sit inside inventory cost.


How COGS Affects Your Profit and Tax Bill


COGS is the inventory cost assigned to products sold in the period, not the cash you handed a supplier. The IRS small-business guide puts the merchandiser's math as beginning inventory plus purchases and other inventory costs, minus ending inventory. Beginning inventory is merchandise available for sale at the start of the year. Ending inventory is the unsold portion, and it remains an asset. You recognize COGS when inventory is sold, not when you buy it.


Walk a shop's profit and loss in that order. Net sales of $500,000 minus COGS of $300,000 leave gross profit of $200,000, a 40% margin. Operating expenses of $120,000 then leave operating income of $80,000. Higher COGS reduces gross profit and taxable business income in the same period. Purchases that stay unsold increase ending inventory and wait for a later period. A restaurant owner can see the same stack on a sample income statement for a restaurant, with food cost sitting where product cost sits for a retailer.


When the count is wrong, profit moves twice


Say closing stock is undercounted by $8,000. COGS rises by $8,000 and profit falls by $8,000 this year. Next year that missing stock isn't there to open with, so beginning inventory is low, COGS falls, and profit bounces back. The two years together can look fine while each year is wrong. For a manufacturer, inventory cost can include raw materials, work in process, finished goods, direct labor, and allocable overhead, so a bad count in any of those piles moves the same way.


Where it lands on the return


Sole proprietors report COGS on Schedule C. Corporations generally use Form 1125-A, and the inventory figures still have to be valued at the beginning and end of the year. Gross margin is the number to watch between periods. A falling margin with steady sales usually points to higher purchase prices, shrinkage, or discounting, not to a change in office overhead. Building that stack cleanly is covered in how to create a P&L statement.


A business with little or no inventory may have little or no COGS. Check with a tax adviser before you assume the merchandise rules apply to a pure service or a software firm.


Recording COGS in QuickBooks Online and Xero


In both QuickBooks Online and Xero, COGS posts when you sell a tracked item. Setup matters more than a manual journal at month end. If the item isn't tracked, the software has nothing to move from the asset account into cost.


A woman working on a laptop with inventory boxes being automatically processed into cost of goods sold.

QuickBooks Online


  1. Turn on inventory tracking under Settings, then Account and settings, then Sales. Without that switch, products won't carry a quantity or a cost layer.

  2. Create each product under Products and services as an inventory item, and set the income account, the Cost of Goods Sold expense account, and the Inventory Asset account. Those three accounts are the whole posting.

  3. Enter purchases through bills or purchase orders so the cost lands on the item, not in a generic expense.

  4. Invoice the inventory item when you sell it. QuickBooks posts COGS and reduces the asset for you.

  5. Run the Inventory Valuation Summary each month and match its total to the Inventory Asset balance on the balance sheet. A gap means a bill, a journal, or a count is off.


Ecommerce sellers often need sales channels feeding those same items. The notes on QuickBooks for ecommerce cover how channel sales should hit tracked products instead of a single sales receipt with no cost.


Xero


  1. Create tracked inventory items, with purchase and sales prices and a Cost of Sales account. Untracked items will not post COGS on their own.

  2. Record supplier bills against those items so quantity and cost both move.

  3. Invoice the item to sell it. Xero posts Cost of Sales automatically and reduces inventory.

  4. Check the Inventory Summary against the balance sheet inventory account every month.


Menu names shift when either platform updates a plan, so confirm the clicks against the current help centre before you rebuild a file. If you outsource the monthly close, ask whoever posts the bills to use the tracked item, not a generic "purchases" account. A virtual bookkeeping partner such as Book Tech LLC can keep that item-level posting consistent in QuickBooks Online or Xero, alongside the owner's own review of the valuation report.


Common COGS Mistakes That Overstate Profit


The mistake that does the most damage is treating every purchase as COGS in the month it was paid. Unsold goods are still an asset. Expensing the whole bill makes this month look worse and next month look better than the sales deserve.


  • Leave inbound freight and duties out of inventory, and unit cost is too low, so COGS is understated and gross profit is too high. Add freight-in on the bill that receives the goods.

  • Skip the year-end count and estimate closing stock, and the COGS formula rests on a guess. Count, then value.

  • Ignore shrinkage, damaged goods, and customer returns, and the shelf in the software doesn't match the shelf in the room. Adjust quantity when you find the gap.

  • Switch costing methods between years without a written reason, and margins stop being comparable even when unit counts don't change. Stick to the policy.

  • Keep obsolete SKUs at full cost, and ending inventory, and profit, stay inflated. Review aging every quarter.


COGS is also a valuation control, not only a subtraction from sales. Inventory starts at cost, and under the lower-of-cost-and-net-realizable-value principle described in an SEC filing's inventory note, you write it down when the amount you expect to recover falls below recorded cost. Net realizable value is the estimated selling price in the ordinary course of business, less reasonably predictable completion, disposal, transportation, or selling costs. The write-down reduces the asset and increases expense, usually COGS or an inventory-loss line, in the period you identify the loss.


Say stock cost $10,000 and the expected selling price less the cost to sell it is $7,000. You write the stock down by $3,000, and COGS rises by that amount now, not when you finally discount the item. Cost-flow choices such as FIFO or weighted-average cost change ending inventory and COGS even when the physical units don't move. An ecommerce or retail business can show a very different gross margin because of purchase-price moves, obsolete SKUs, freight-in, returns, shrinkage, or the costing method itself.


A quarterly aging review, a reconciliation of each sales channel to the general ledger, and a one-page policy that names the method and the cutoff date are what keep inventory from propping up profit that isn't there.



If your COGS, inventory asset, and gross margin don't tie out each month, Book Tech LLC can take on the bookkeeping that keeps them aligned, from item setup in QuickBooks Online or Xero through a tax-ready close. The firm handles monthly books, catch-up work, and inventory-heavy retail and ecommerce files for small businesses across the US. Visit Book Tech LLC to set up a no-pressure look at your current cost of goods sold.


Subscribe To Our Newsletter • Never Miss an Update

bottom of page