Cost of goods sold (COGS): the formula, and what goes in it
COGS = opening inventory + purchases − closing inventory. How to work it out, what goes in it for an importer — landed cost included — and what stays out.
Cost of goods sold (COGS) is the direct cost of the goods a business sold during a period. It is worked out as opening inventory + purchases − closing inventory. For an importer, "purchases" means the landed cost of the goods: the supplier's price plus the freight, insurance, duties and clearance it took to get them into stock.
In short:
- COGS = opening inventory + purchases − closing inventory.
- Revenue − COGS = gross profit.
- Landed costs belong in the stock value; avoidable charges such as demurrage usually do not.

The COGS formula, with an example
| Amount | |
|---|---|
| Opening inventory (start of the period) | 50,000 |
| + Purchases in the period, with landed costs | 200,000 |
| − Closing inventory (end of the period) | 70,000 |
| = Cost of goods sold | 180,000 |
If sales in the period were 300,000, gross profit is 300,000 − 180,000 = 120,000, a gross margin of 40%.

What goes into COGS
For a manufacturer, COGS includes:
- Direct materials — often the biggest share.
- Direct labour — the people who make the product.
- Manufacturing overheads — the factory's power, maintenance and depreciation, allocated to products.
- Inbound freight — the cost of bringing materials in.
The split varies widely by industry; in a typical example, direct materials might be 60% of COGS, overheads 20%, labour 10% and inbound freight 5%.
For importers: landed cost belongs in the stock value
Under IAS 2, the international accounting standard for inventories, the cost of purchased goods includes the purchase price, import duties and other non-recoverable taxes, transport, handling and other costs directly needed to bring the goods to their present location and condition. For an importer, that usually means:
- Purchase price — what the supplier invoices.
- Freight and insurance — when your Incoterm leaves them to you (FOB or FCA, for example).
- Duties and clearance — customs duty, non-recoverable taxes, port and clearing charges.

What stays out of COGS
- Administration — office salaries, rent, IT.
- Selling and distribution — marketing, sales teams, delivery to customers.
- Research and development — new products and processes.
- Abnormal costs — spoilt stock, waste and avoidable charges beyond normal operations.
Demurrage and detention are usually treated as expenses as they happen, not added to the stock value. Either way they come straight off your margin, for nothing in return. Check how your own accounting policy treats them. Our guide to demurrage and detention explains how they start.
Why logistics teams should care about COGS
Freight rates, port charges and clearance fees all land in COGS, so logistics decisions show up directly in gross margin. A lower freight rate that comes with fewer free days can cost more in the end.
Questions
What is the formula for COGS?
COGS = opening inventory + purchases during the period − closing inventory.
Is freight included in COGS?
Inbound freight — bringing goods into your stock — is normally part of inventory cost and so of COGS. Outbound freight to customers is usually a selling or distribution cost.
Is demurrage part of COGS?
Usually not. Demurrage and detention are generally treated as expenses when incurred, because they are avoidable rather than part of the normal cost of the goods.
In SailPing: add a container's last free day — or it comes from the shipping line, when the line sends one — and it is counted down on your dashboard, so you see demurrage coming.