Inventory and cost of goods sold
General educational material, not professional advice. See Not professional advice.
Inventory (stock held for sale)
Inventory is goods you hold to sell: finished products, parts you build them from, or items you resell. Until you sell them, they are an asset. Their cost becomes an expense, cost of goods sold (COGS), when you sell them.
This follows the matching principle. If you bought a year’s stock in January and expensed it all then, January would show a huge loss and every other month would look too profitable.
Businesses that sell services rather than goods usually have no inventory.
Cost of goods sold (COGS) when you sell
Buying stock moves money into the inventory asset. Selling records the revenue at the sale price and, separately, moves the items’ cost from inventory to COGS.
account expenses:cost of goods sold ; type: X
2026-02-01 Buy 100 mugs from the pottery
assets:inventory:mugs $800.00
assets:bank:checking $-800.00
2026-02-18 Sell 30 mugs at the market
assets:bank:checking $540.00
revenue:sales $-540.00
expenses:cost of goods sold $240.00
assets:inventory:mugs $-240.00
The 30 mugs cost $8 each, so $240 moves to COGS. Inventory keeps $560, the 70 mugs left.
If you sell through a register or a marketplace, it is often easier to post COGS once a month from a stock count (next section) than with every sale.
Gross profit and gross margin
Gross profit is revenue minus cost of goods sold. It is what you make on the products themselves, before rent, wages and other running costs. Gross margin is gross profit as a share of revenue.
For the mug sale: $540 − $240 = $300 gross profit, and $300 ÷ $540 ≈ 56 % gross margin.
You need COGS in its own account, separate from other expenses, to calculate this figure. Startup metrics can show gross margin when your accounts are tagged for it.
Periodic inventory counts and shrinkage
Tracking the cost of every item sold is the perpetual method. The alternative, the periodic method, is to count your stock at the end of each period and work COGS out from the difference:
COGS = Opening inventory + Purchases − Closing inventory
Then post one adjusting entry to bring the inventory account to the counted value.
2026-02-01 Buy 100 mugs from the pottery
assets:inventory:mugs $800.00
assets:bank:checking $-800.00
2026-02-28 February cost of goods sold, from stock count of 62 mugs
expenses:cost of goods sold $304.00
assets:inventory:mugs $-304.00 = $496.00
62 mugs at $8 is $496 on hand, so $304 of stock left during February. The balance assertion records the count. A count lower than your records expect, from breakage, theft or errors, is shrinkage. Some businesses post it to a separate expenses:inventory shrinkage account to track it.
Which cost when prices change (FIFO, average cost)
When you buy the same item at different prices, you need a rule for which cost leaves with each sale:
- FIFO (first in, first out): the oldest units are sold first.
- Average cost: every unit costs the running average.
- LIFO (last in, first out): the newest units are sold first. Allowed in some places, such as US tax, and not under IFRS.
Pick one and use it consistently. The rules on which methods you may use for tax vary by country.
hledger can also track inventory as a commodity, with quantities and per-unit cost (70 MUG @ $8), the same way it tracks shares. See Investments for that notation.