Module 07 · Inventory Accounting and COGS in Practice

How to Calculate Cost of Goods Sold From a Trial Balance

How to calculate cost of goods sold from a trial balance: which accounts to use, where closing inventory comes from, plus a full March example and checks.

11 min readLesson 3 of 10 in this moduleUpdated 2026-11-09

To calculate cost of goods sold from a trial balance, take the opening inventory balance, add the purchases and freight-in accounts, subtract purchase returns and discounts, and then subtract closing inventory from your stock count. For example, $18,000 opening inventory plus $46,000 net cost of purchases less $21,000 closing inventory equals $43,000. In a perpetual system, COGS is already a ledger balance.

Key takeaways

  • Which formula you use depends on your inventory system. In a periodic system, the trial balance holds opening inventory plus separate purchase accounts, and you calculate COGS. In a perpetual system, the trial balance already shows a COGS balance.
  • On an unadjusted periodic trial balance, the Inventory account still shows the opening balance, not the closing one. Take closing inventory from your count.
  • Pick up every cost account: purchases, freight-in, purchase returns and purchase discounts. Missing one changes COGS by exactly its amount.
  • A balanced trial balance only proves debits equal credits. It does not prove closing inventory or COGS is right.
  • After you calculate COGS, post an adjusting entry so the ledger shows the new inventory balance and a single COGS balance.

What does a trial balance show, and why does COGS take extra work?

A trial balance is a list of every ledger account with its debit or credit balance at a date. Total debits must equal total credits, which is the first check that the books are internally consistent. If you need a refresher on how the debit and credit rules produce those balances, see the debit and credit rules.

COGS needs extra work because, in a periodic inventory system, no one posts a cost entry when you make a sale. During the month you debit Purchases when you buy and credit Sales when you sell. You only find out what the sales cost at the end, when you count the stock. So the trial balance taken before that step contains the ingredients of COGS but no COGS figure. In a perpetual system, every sale posts its cost at the time, so the trial balance already contains a COGS account. Our companion lesson on inventory accounting journal entries shows the difference entry by entry.

Step 1: Decide whether the books are periodic or perpetual

Look at the trial balance. These signs tell you which system you have:

What you seeWhat it means
Accounts called Purchases, Purchase returns, Purchase discounts, Freight-in; no COGS account; Inventory equals last month's closing figurePeriodic. You calculate COGS.
An account called Cost of goods sold with a balance; no Purchases account; Inventory moves during the monthPerpetual. Read COGS from the account, then check it.
Both Purchases and COGS accounts with balancesMixed or partly adjusted. Find out what was posted before you calculate.

The rest of this lesson works through the periodic case, because that is where you have to calculate. The perpetual case is covered near the end.

Step 2: Read the unadjusted trial balance

Here is the unadjusted trial balance of the fictional shop Lakeside Home Goods at 31 March, prepared under a periodic system. The figures in this example are fictional.

AccountDebit ($)Credit ($)
Cash12,000
Accounts receivable9,500
Inventory (opening balance)18,000
Equipment20,000
Accounts payable14,000
Owner's capital39,000
Sales72,000
Sales returns2,000
Purchases46,000
Purchase returns1,500
Purchase discounts500
Freight-in2,000
Rent5,000
Wages9,000
Utilities1,200
Other operating expenses2,300
Total127,000127,000

Debits and credits both total $127,000, so the trial balance balances. Note what is still missing: no one has recorded the closing stock yet, and the Inventory balance of $18,000 is the stock Lakeside had on 1 March.

The Inventory line is last month's number

In a periodic system the Inventory account is not touched during the month. The balance on an unadjusted trial balance is the opening figure. If you read $18,000 as the closing balance and use it in the formula, you are saying nothing changed all month, and COGS will be wrong by the full change in stock.

Step 3: Pick the right accounts for the COGS calculation

Go down the list and pull out only the accounts that belong in the cost of goods sold section. Everything else stays where it is.

Account on the trial balanceUsed in COGS?Effect
Inventory (opening) 18,000 DrYesAdd
Purchases 46,000 DrYesAdd
Freight-in 2,000 DrYesAdd
Purchase returns 1,500 CrYesSubtract
Purchase discounts 500 CrYesSubtract
Sales 72,000 Cr and Sales returns 2,000 DrNo (revenue side)Used later for gross profit
Rent, wages, utilities, other 17,500 DrNo (operating expenses)Below gross profit
Cash, receivables, equipment, payables, capitalNo (balance sheet)Not part of profit

If your trial balance uses different names, such as "Carriage inwards" or "Inward freight", map them to the same role. A debit-balance account that adds to the cost of getting stock into the shop belongs with purchases. A credit-balance account that reduces what you paid for stock belongs with returns and discounts. Items that you pay to deliver goods to customers (freight-out) normally stay in operating expenses.

Step 4: Get closing inventory from a count, not from the ledger

Closing inventory is the one number that is not on the unadjusted trial balance. Take it from the stock count at month-end, valued at cost (or at net realisable value if that is lower). For Lakeside, the count and valuation come to $21,000. If you need a method for the count, follow the step-by-step stock opname, and for the concept see what is stock opname.

The valuation method matters here. If you use FIFO or average cost, the closing figure is the unit cost times quantity under that method. The lesson on FIFO vs average costing shows how they differ.

Step 5: Calculate COGS

COGS = Opening inventory + Purchases + Freight-in − Purchase returns − Purchase discounts − Closing inventory

Opening inventory is the unadjusted trial-balance figure; closing inventory comes from the count.

StepCalculationResult ($)
Opening inventoryFrom trial balance18,000
Add: PurchasesFrom trial balance46,000
Less: Purchase returnsFrom trial balance1,500
Less: Purchase discountsFrom trial balance500
Net purchases46,000 − 1,500 − 50044,000
Add: Freight-inFrom trial balance2,000
Net cost of purchases44,000 + 2,00046,000
Cost of goods available for sale18,000 + 46,00064,000
Less: Closing inventoryFrom stock count21,000
Cost of goods sold64,000 − 21,00043,000

To confirm, net sales are $72,000 − $2,000 = $70,000, and gross profit is $70,000 − $43,000 = $27,000, a gross margin of 38.6%. That agrees with the income statement figure in the lesson on calculating COGS from an income statement.

Step 6: Post the adjusting entries so the ledger agrees

Calculating COGS on paper is not enough. The ledger still shows Inventory at $18,000 and has no COGS balance. Post two entries at month-end. The first moves opening inventory and all purchase-related accounts into COGS:

AccountDebit ($)Credit ($)
Cost of goods sold64,000
Purchase returns1,500
Purchase discounts500
Inventory (opening)18,000
Purchases46,000
Freight-in2,000
Total66,00066,000

The second records the stock still on hand:

AccountDebit ($)Credit ($)
Inventory (closing)21,000
Cost of goods sold21,000
Total21,00021,000

After both, COGS has a debit balance of $64,000 − $21,000 = $43,000, Inventory shows $21,000, and Purchases, Purchase returns, Purchase discounts and Freight-in are all zero. Many teams record this as one combined entry, or as part of closing entries; the end result is identical. The general idea of month-end adjustments is covered in adjusting journal entries, and the mechanics of writing entries by hand are in the general journal lesson.

Step 7: Check the adjusted trial balance

Prepare the adjusted trial balance and confirm it still balances. Only the inventory-related lines changed:

AccountDebit ($)Credit ($)
Cash12,000
Accounts receivable9,500
Inventory21,000
Equipment20,000
Accounts payable14,000
Owner's capital39,000
Sales72,000
Sales returns2,000
Cost of goods sold43,000
Rent5,000
Wages9,000
Utilities1,200
Other operating expenses2,300
Total125,000125,000

The totals are lower than before ($125,000 against $127,000) because four accounts that carried the cost of buying stock have been folded into COGS. The balance sheet now shows Inventory of $21,000, which matches the count. For a longer example of preparing and using a trial balance, see the trial balance worked example.

What if your books are perpetual?

If the system posts cost at each sale, the trial balance for the same month already contains the answer. The Purchases and related accounts do not exist because purchases were debited to Inventory when they happened, and the cost of each sale was moved out of Inventory into COGS. Lakeside's perpetual trial balance would look like the adjusted one above: Inventory $21,000 and COGS $43,000.

In that case you do not calculate COGS; you test it. Use the roll-forward:

CheckCalculationResult ($)
Opening inventoryLast month's ledger close18,000
Add: net cost of purchases posted to Inventory46,000 − 1,500 − 500 + 2,00046,000
Less: COGS balance on the trial balance43,000
Expected closing inventory18,000 + 46,000 − 43,00021,000
Counted inventoryStock count21,000
DifferenceCounted − expected0

A difference is not a COGS error to be hidden. In a perpetual system, a shortage is usually recorded as a separate adjustment (for example, to a shrinkage expense) once you find it, so you can see it. Under a periodic system the same shortage would have been absorbed into COGS without being visible. That visibility is a practical reason to prefer perpetual records. The retail lesson on calculating retail COGS goes deeper on that point.

Common mistakes when calculating COGS from a trial balance

  • Using the trial balance Inventory as closing stock. Covered above. It is the opening figure in a periodic system.
  • Leaving out freight-in. It is easy to miss because it often has a name like "carriage" or "delivery in".
  • Adding returns and discounts instead of subtracting them. They have credit balances, so they reduce cost.
  • Including freight-out or rent. These are operating expenses, not COGS.
  • Counting closing stock at selling price. Inventory belongs on the books at cost (or lower net realisable value).
  • Cut-off errors. Goods received before month-end but not yet entered, or invoiced but not yet received, shift COGS. Check the last few receipts and shipments around the count date.

More on typical errors appears in common mistakes in inventory and costing.

Local rules

How inventory is valued and presented, and whether a periodic method is acceptable for tax or statutory accounts, varies by country. Treat this lesson as general education and check your local rules or a qualified adviser.

Trial balance in Reyuko

Reyuko uses a perpetual system, so its trial balance already carries Inventory and COGS accounts and you do not assemble COGS from purchase accounts. A goods receipt debits Inventory and credits GRNI until the purchase bill arrives (the bill then clears GRNI), and each sales invoice posts Dr COGS / Cr Inventory at the cost set for the product: Average, FIFO, LIFO or FEFO. Because every entry balances, total debits equal total credits on the trial balance, and the stock count then checks Inventory against what is physically on hand.

Frequently asked questions

How do I calculate cost of goods sold from a trial balance?

Add the opening inventory balance and the purchases and freight-in accounts, subtract purchase returns and discounts, and then subtract closing inventory taken from your stock count. For example, $18,000 plus $46,000 net cost of purchases is $64,000 of goods available, and less $21,000 closing stock gives COGS of $43,000. This applies to periodic systems, where COGS is not yet a ledger balance.

Is cost of goods sold on the trial balance?

It depends on the inventory system. In a perpetual system, a COGS account is posted with every sale and appears on the trial balance with its balance. In a periodic system, the unadjusted trial balance has no COGS balance; it shows opening inventory and purchase accounts, and COGS is calculated at month-end and then posted by an adjusting entry.

Why is closing inventory not on the unadjusted trial balance?

In a periodic system, the Inventory account is only updated at the end of the period, after a physical count. Until that adjusting entry is posted, the Inventory line still shows the opening balance. That is why the closing figure has to come from the stock count and not from the ledger.

Does a balanced trial balance mean my COGS is correct?

No. A trial balance only proves total debits equal total credits. You can have a wrong closing inventory count, a missing freight-in invoice or a purchase posted in the wrong period and still balance. To check COGS, compare it with prior periods, test the gross margin for plausibility, and reconcile inventory to the count.

What accounts go into the cost of goods sold calculation?

Opening inventory, purchases, freight-in, purchase returns, purchase discounts and closing inventory. Sales, sales returns and operating expenses such as rent, wages and utilities are not part of COGS. If you also pay freight to deliver goods to customers, that is usually an operating expense. Some businesses add direct labor or manufacturing costs when they make what they sell.

Do I need adjusting entries for COGS?

In a periodic system, yes. The ledger will show the old inventory balance and no COGS until you post the entries that move opening inventory and purchase accounts into COGS and record closing inventory. Without them, the balance sheet shows stale stock and the income statement has no cost of sales line. In a perpetual system you only post adjustments for count differences.

Put this into practice in Reyuko

Reyuko posts inventory, cost of goods sold and gross profit from the same ledger, so the numbers in this lesson are the numbers on your reports.

Download Reyuko freeSee what's included