Decision software for grocery chains

How to calculate cost of goods sold (COGS)

Last updated: 5 October 202610 min read

Who it is forGrocery chain finance and accounting teams, business owners

Cost of goods sold is the largest expense line in the income statement and the direct determinant of gross profit. The formula has three terms, but each carries its own argument: is closing inventory taken from a count or from the records, does freight go to purchases or to expense, do stolen and spoiled goods count as sold? This guide covers the formula, the calculation schedule, deriving it from a trial balance and where shrinkage belongs.

The COGS formula and what the three terms mean

The logic is simple: what did you have available during the period, and how much of it is left. What is not left has been sold.

Opening inventory is the previous period's closing stock at cost. Purchases are the cost of goods bought, including freight, customs, insurance and import charges, less purchase discounts. Closing inventory is the cost value of what a physical count says remains.

The weak point is the third term. If closing inventory is taken from the system rather than a count, every difference between the record and reality is written straight into cost of goods sold and gross profit comes out wrong. That is why a count is not an accounting formality but a condition for the income statement to be true.

Cost of goods sold
Opening inventory + Purchases − Closing inventory
Net purchases
Gross purchases + Freight and landed costs − Purchase discounts − Purchase returns
For in-store production (bakery, delicatessen)
Opening finished goods + Cost of goods manufactured − Closing finished goods

The calculation schedule, step by step

The COGS schedule is prepared as a supporting statement to the income statement and is among the first documents requested in an audit. The sequence below suits both statutory reporting and management reporting.

  1. Enter opening inventoryThe prior period's closing value. If you are preparing this for the first time, an opening count is required; an estimated opening stock corrupts the whole year.
  2. Total the period's purchasesGoods for resale only. Fixed assets, office supplies and service purchases do not belong here.
  3. Add landed costsFreight, customs, insurance, import charges. Expensing these makes margin look high and leaves inventory undervalued.
  4. Deduct discounts and returnsPurchase discounts, volume rebates and returns to suppliers. Volume rebates arrive at year end and are often missed, which makes cost look high.
  5. Establish closing inventory by countCount physically, then value on your costing method. Use the counted value, not the recorded value.
  6. Separate the varianceBefore the difference between record and count is absorbed into cost of goods sold, split it into shrinkage, write-offs, theft and counting error.

Skip step five and take closing inventory from the records, and the count variance hides inside cost of goods sold. Gross profit comes out wrong and the reason appears in no report.

Shrinkage, write-offs and theft: not sold, but gone

Goods that spoil, break, are stolen or pass their expiry date leave inventory. Looked at through the formula, that reduces closing inventory and increases cost of goods sold — unsold goods are costed as though they had sold.

Technically the result is not wrong; total expense comes out right. But it is a loss of information for management reporting: it becomes impossible to see whether a margin shortfall came from price or from shrinkage.

The correct approach is to record shrinkage as its own transaction type and show it on a separate line. Gross margin then reflects genuine sales only, shrinkage is tracked in its own right and becomes a line that can be reduced.

Types of stock outflow and where they belong
Outflow typeLeaves stockEnters COGSTracked in
SaleYesYesCost of goods sold
Shrinkage and spoilageYesNo (separate it)Separate expense account, shrinkage report
Write-off (expired)YesNo (separate it)Separate expense account, disposal record
Theft and lossYesNo (separate it)Stock variance account
Samples and promotionYesNoMarketing expense
Staff purchaseYesYesSales, as a separate channel
Inter-store transferNoNoStock movement, cost carried across

Deriving cost of goods sold from a trial balance

If you have the trial balance, COGS needs no separate working; the components are already there. The opening balance, period debits and closing balance of the merchandise inventory account give the three terms of the formula.

Two traps show up in practice. The first is landed costs having been posted to expense accounts rather than to inventory, which leaves stock understated and expenses overstated. The second is non-merchandise items sitting inside the inventory account.

The check is simple: compare the COGS you calculated with the balance on the cost of sales account. If the two do not agree, the difference lies in one of those two traps.

  • Inventory account, opening balance → Opening inventory
  • Inventory account, period debits → Purchases (landed costs must be included)
  • Inventory account, closing balance → Closing inventory (must be verified by count)
  • Cost of sales account balance → cross-check against the calculated figure

Frequently asked questions

How is cost of goods sold calculated?
Add purchases during the period to opening inventory and subtract closing inventory. With opening inventory of ₺140,000, purchases of ₺635,000 and closing inventory of ₺155,000, cost of goods sold is ₺620,000.
What is the cost of goods sold formula?
COGS = Opening Inventory + Purchases − Closing Inventory. Purchases include freight, customs and insurance; purchase discounts and returns are deducted.
Is freight included in cost of goods sold?
Inbound freight is. Every cost that brings the product into your warehouse is allocated into product cost. Outbound freight is not; it is a selling and distribution expense. Confusing the two makes gross margin look several points higher than it is.
Do shrinkage and spoiled goods enter cost of goods sold?
Through the formula they do automatically, because they reduce closing inventory. But correct practice is to separate shrinkage as its own transaction type. Without that separation it is impossible to see whether a margin shortfall came from price or from shrinkage.
Should closing inventory come from a count or from the system?
From a count. If closing inventory is taken from the records, every difference between the record and reality is absorbed into cost of goods sold and gross profit comes out wrong. The count is a condition for the income statement to be true.
How does COGS work for goods produced in the store?
For goods the store makes itself, such as bread from the in-store bakery, the cost of goods manufactured replaces purchases: opening finished goods plus cost of goods manufactured less closing finished goods. Cost of goods manufactured is built from raw materials, direct labour and manufacturing overhead, and is tracked in a separate schedule.

Let us build this calculation on your data

Knowing the formula is not enough; the data has to sit at the right grain. Our team does the installation. We will go through your current setup together in 30 minutes.