Cost of Goods Sold (COGS): Formula, Examples, Journal Entry

Jul 20, 2026

Try it now, capture a real invoice

Your file is processed for the demo only and never stored.

Cost of goods sold (COGS) is the direct cost of producing or buying the goods a business actually sold during a period, including materials, direct labor, and freight in. It appears on the income statement right below revenue, and revenue minus COGS equals gross profit. COGS only counts inventory that was sold: unsold stock stays on the balance sheet as inventory until it moves.

Cost of goods sold formula

The standard formula ties the period's purchases to the change in inventory:

COGS = Beginning Inventory + Purchases During the Period - Ending Inventory

The logic is simple. You start with the inventory you had, add everything you bought or made, then subtract what is still on the shelf at the end. Whatever is left is what you sold. Purchases include the invoiced cost of the goods plus freight in and any direct costs to get the inventory ready to sell.

Cost of goods sold example

A retailer starts the quarter with $40,000 of inventory, buys $120,000 more during the quarter, and counts $35,000 of inventory on hand at quarter end.

LineAmount
Beginning inventory$40,000
Plus: purchases$120,000
Less: ending inventory($35,000)
Cost of goods sold$125,000

If the retailer's sales for the quarter were $210,000, gross profit is $85,000 and the gross margin is about 40 percent ($85,000 / $210,000).

Cost of goods sold journal entry

Under a perpetual inventory system, each sale triggers two entries: one to record the sale and one to move the cost out of inventory and into COGS. The cost entry is a debit to Cost of Goods Sold and a credit to Inventory for the cost of the items sold. Under a periodic system, you calculate COGS once at period end using the formula above and record a single adjusting entry. Either way, the accuracy of the number depends entirely on the recorded cost of purchases, which flows in from supplier invoices.

Cost of goods sold vs cost of sales

The two terms are often used interchangeably, and for a product business they usually mean the same thing. The nuance: cost of goods sold typically refers to physical products, while cost of sales is the broader label service and mixed businesses use for the direct cost of delivering whatever they sell. A software company reports cost of sales (hosting, support, third-party licenses) rather than COGS because it holds no inventory. On the income statement they sit in the same place, directly under revenue.

What is and is not included in COGS

COGS captures only direct costs: raw materials, the parts and finished goods you buy for resale, direct production labor, and freight in. It excludes indirect and period costs such as sales commissions, marketing, office rent, administrative salaries, and distribution to customers. Those live in operating expenses. Getting the line between direct and indirect right is what separates a clean gross margin from a distorted one, and it depends on coding each purchase invoice to the correct account. This is where disciplined GL coding in accounts payable pays off, because a freight bill miscoded to overhead understates COGS and overstates margin.

Why COGS matters beyond the income statement

COGS drives more than gross profit. It feeds inventory turnover, and it is the numerator behind days payable outstanding, the metric that tells you how long you take to pay suppliers relative to what you buy. A rising COGS with flat revenue signals margin erosion from higher supplier prices or freight. Because most COGS enters the books through vendor invoices, the timeliness and accuracy of your accounts payable process directly affects how reliable the number is at month end. Every purchase that lands after the cutoff misstates both COGS and inventory. Keeping a clean record of what you ordered and received, from the purchase order through the matched invoice, is what keeps COGS honest.

How inventory costing methods change COGS

The same physical sales can produce different COGS depending on the costing method. FIFO (first in, first out) assigns the oldest costs to COGS, which in a rising-price environment lowers COGS and raises reported profit. LIFO (last in, first out) does the opposite, though it is far less common and not permitted under IFRS. Weighted average smooths costs across all units. The method you choose is a policy decision that must stay consistent, and it flows straight from the recorded cost of purchases in accounts payable.

Frequently asked questions

Is cost of goods sold an expense? Yes. COGS is an expense on the income statement, but it is reported separately from operating expenses so readers can see gross profit before overhead.

Where does COGS appear on the income statement? Directly below revenue. Revenue minus COGS equals gross profit, and operating expenses are subtracted after that to reach operating income.

Does COGS include unsold inventory? No. Only the cost of inventory actually sold during the period hits COGS. Unsold inventory stays on the balance sheet as a current asset.

How do you lower cost of goods sold? Negotiate better supplier pricing, cut freight and waste, reduce spoilage and obsolescence, and improve production efficiency. Accurate invoice capture and coding make sure the reported number reflects real costs, not errors.

Stop keying invoices by hand

AutoPayables captures vendor, amounts and dates from any invoice with AI, routes approvals, and syncs to QuickBooks, Xero, NetSuite or Sage Intacct.

See the product

From the same family of tools