COGS formula for inventory businesses: worked examples and where the number goes wrong
Your gross margin looks healthy, but cash tells a different story, and nobody can say which COGS input is off. This post gives you the formula, three worked examples, and the checks that keep the number honest in Cin7, QuickBooks Online (QBO), or Xero.

On this page
- What is the COGS formula?
- How do you calculate COGS step by step?
- Which costs belong in the purchases line?
- How does your costing method change COGS?
- What changes for manufacturers?
- Why does COGS look wrong in Cin7 when the formula is right?
- How to check your COGS formula inputs this week
- When should you bring in a specialist?
- Frequently asked questions
TL;DR
- The COGS formula is beginning inventory plus purchases minus ending inventory, and the result is the cost of what you sold, not what you bought.
- Purchases only tell the truth when freight, duties, and brokerage sit inside inventory cost. A freight bill coded to expenses lifts gross margin and leaves the balance sheet understated by the same amount.
- Your costing method changes the answer from identical stock. Cin7 Core costs each sale from FIFO or FEFO layers, while QuickBooks uses weighted average cost, so the two systems can disagree without anyone making a mistake.
- Manufacturers add materials, direct labor, and production overhead, so the formula needs a work-in-progress step before finished goods reach COGS.
- Run the formula monthly against a physical count and your ledger, and write down who owns each input, because that habit catches drift before it reaches your P&L.
Gross margin looks fine in the report. The bank balance disagrees. Someone adjusts COGS with a manual journal at month-end, the numbers line up for a few weeks, and then the gap comes back. A manual journal can align the numbers briefly, but the underlying gap returns until the source is fixed. Your physical process and system process are no longer in sync, and the formula is where that becomes visible.
This post covers the COGS formula, three worked examples with round numbers, the inputs that break it for inventory businesses between $1m and $100m, and a short routine your bookkeeper can run this week. The examples are illustrations built for this post, not client data.
What is the COGS formula?
COGS equals beginning inventory plus purchases minus ending inventory. Beginning inventory is the value of stock at the start of the period, purchases are what you added during it, and ending inventory is what remains at the close. Xero's guide uses the same standard formula, and the same logic sits behind every inventory ledger.
The first two lines give you the cost of goods available for sale. Subtracting what is still on the shelf leaves the cost of the goods that left it. Inventory is an asset until it sells, and QuickBooks debits COGS only when you sell inventory items on an invoice or sales receipt, crediting the Inventory Asset account at the same moment.
Think of a shop till. The cash drawer at close only makes sense if you know what was in it at open and what went in during the day. COGS works the same way, and a wrong opening or closing figure moves the whole result.
How do you calculate COGS step by step?
Work from the opening balance, add the period's purchases at full cost, and subtract a valued closing count. Then test the answer against gross margin. Here is a retail-style example with round numbers.
| Line | Amount | Where it comes from |
|---|---|---|
| Beginning inventory | $200,000 | Prior period closing balance |
| Purchases, including freight and duties | $600,000 | Supplier bills plus landed costs |
| Goods available for sale | $800,000 | Sum of the two lines above |
| Ending inventory | $250,000 | Counted and valued stock |
| COGS | $550,000 | $800,000 minus $250,000 |
With $900,000 of net sales, gross profit is $350,000 and gross margin is about 39%. Every step depends on the one before it. If the $250,000 count is $20,000 too high, COGS is $20,000 too low and margin looks about 2 points better than it is.
Worked example: a missing freight bill
Say $30,000 of inbound freight and duties was paid but coded to a general expense account. Purchases read $570,000 instead of $600,000, so COGS shows $520,000 and gross margin looks like 42%. The stock on the shelf is also valued $30,000 too low, so the balance sheet and the P&L both carry an error. A margin that looks off is rarely a pricing issue. More often, landed cost is sitting in expenses instead of inventory.
Which costs belong in the purchases line?
Anything you pay to get a unit into sellable condition belongs in purchases or in inventory cost: purchase price, freight in, customs duties, insurance, handling, and brokerage. Costs of selling, such as rent, marketing, and administrative salaries, stay out. Xero's guide lists rent, marketing, administrative overhead, and most salaries as outside COGS.
Cin7 Core applies this at the purchase order. It allocates additional costs by invoice line cost by default, with other bases such as quantity, weight, or volume available through a manual journal. Pick the wrong basis, or leave a broker invoice outside the purchasing workflow, and unit cost is wrong from the first sale. The landed cost configuration guide walks through the setup.
| Symptom | Likely root cause | Fix |
|---|---|---|
| Margin higher than cash suggests | Freight or duties coded to expenses | Attach to the purchase order as additional cost |
| Margin jumps, then falls back | Invoice and shipment land in different periods | Align the authorization workflow and the lock date |
| COGS differs between Cin7 and QBO | Different costing methods or mapping | Document the method and review the account mapping |
| Zero-dollar COGS on some lines | Sale shipped before the purchase invoice was authorized | Fix receiving and invoicing sequence upstream |
How does your costing method change COGS?
Costing method decides which unit costs leave inventory first, so the same stock produces different COGS under different methods. FIFO assigns the cost of your oldest purchases to COGS first, and when prices rise it reports lower COGS and higher profit than newer-cost methods.
Worked example: one stock, two answers
You buy 100 units at $10 in January, 100 at $12 in February, and sell 150 units. The table shows what each method assigns.
| Method | COGS for 150 units | Ending inventory (50 units) |
|---|---|---|
| FIFO | $1,600 | $600 |
| Weighted average ($11 per unit) | $1,650 | $550 |
FIFO takes 100 units at $10 and 50 at $12. Weighted average blends both buys into $11 a unit. Neither is wrong. They answer different questions, and the gap grows as supplier prices move.
This matters when two systems share one ledger. QuickBooks uses weighted average cost to value inventory and the amount debited to COGS on sale. In Cin7 Core, COGS calculations use accounting costing methods such as FIFO or FEFO and are based on the actual purchase cost of the picked item, taken from the authorized purchase invoice. When Cin7 feeds journals into QBO, the ledger carries Cin7's number. Your reconciliation has to start from that fact.
What changes for manufacturers?
A manufacturer replaces purchases with the cost of goods manufactured: raw materials, direct labor, and production overhead for what was completed. COGS then equals beginning finished goods plus cost of goods manufactured minus ending finished goods. Work in progress sits on the balance sheet until output is complete.
Worked example: a light manufacturer
Beginning finished goods are $80,000. Production completed in the period carries $140,000 of materials, $40,000 of direct labor, and $20,000 of production overhead, so cost of goods manufactured is $200,000. Ending finished goods are $100,000. COGS is $80,000 plus $200,000 minus $100,000, which is $180,000.
In Cin7, this depends on bill of materials accuracy and on when production output is put away. A stale BOM or an unposted production run means COGS reflects old recipes. That is one reason margins on manufactured items drift without anyone touching them.
Why does COGS look wrong in Cin7 when the formula is right?
The formula runs on inputs, and in Cin7 each input comes from a transaction event. Revenue and cost relief run on separate triggers, so timing gaps show up as margin spikes. Sales invoice authorization recognizes revenue, while shipment authorization triggers inventory relief and the matching COGS. If the two fall in different reporting windows, margin looks better than it is until the shipment catches up. We cover that pattern in detail in why Cin7 COGS goes wrong and margins spike at month-end.
Receiving matters just as much. Receiving, supplier invoicing, and cost allocation establish inventory value, so a correct stock count alone won't give you a correct valuation. Quantity can match the shelf while the dollars underneath are incomplete.
Patching the report or posting a journal closes the visible gap but leaves the cause in place, so trace the difference to its source and fix that layer. Editing a display field does not help either, because the Average Cost field on the Cin7 product card has no effect on any posted journal entry, the P&L, or the General Ledger.
How to check your COGS formula inputs this week
Run the checks below in order. Each step is small enough for an operator or a bookkeeper to finish in a working session, and the last one is what stops the problem coming back.
- Lock the beginning balance. Confirm opening inventory in your accounting system equals last period's closing balance. If it moved, a prior reconciled transaction was changed or deleted, and that needs tracing before anything else.
- List every cost that touches a unit. Write down freight, duties, brokerage, insurance, and handling bills from the period, and check each one is attached to a purchase order or an inventory account.
- Compare the count to the ledger. Value a physical or cycle count at the same costing method your system uses, then compare it with the Inventory Asset balance in QBO or Xero.
- Check authorization order. Pull sales shipped before the matching purchase invoice was authorized. Those lines carry estimated cost until the invoice lands.
- Sample four SKUs end to end. Follow purchase, receipt, landed cost, sale, and return for each SKU and confirm the journal lands in the right account. Pull one of the four from your highest-volume channel.
- Write a retroactive change policy. Decide who may edit a closed period, which lock date applies, and when a manual journal is allowed. Put an owner's name next to each rule, because system adoption holds only when someone owns the discipline.
The Cin7 Core and QuickBooks Online reconciliation guide gives the monthly sequence for sales, purchases, COGS, and inventory on hand. If the checks surface more than one cause, the Fiskal Score shows which part of your setup to patch and which to rebuild.
When should you bring in a specialist?
A specialist is worth bringing in when the same COGS gap keeps returning or operations and finance disagree on the same period. At that point the formula is fine and the system underneath needs a diagnostic pass. Fiskal's inventory accounting service covers purchasing, receiving, landing, and shipping, and connects each of those to the ledger. Behaviour change is part of that work, because a correct setup only holds if the team uses it as designed.
Frequently asked questions
What is the COGS formula?
COGS equals beginning inventory plus purchases minus ending inventory. It gives the cost of goods sold in a period, and you subtract it from revenue to reach gross profit. For inventory businesses, include freight, duties, and brokerage in purchases so unit cost is complete.
Does COGS include shipping costs?
Inbound freight, duties, and brokerage belong in COGS because they are part of getting stock ready to sell. Outbound shipping to customers is usually treated as a selling cost, though some businesses classify it differently. Pick a policy, document it, and apply it every period.
How do you calculate COGS in QuickBooks Online?
QuickBooks debits COGS when an inventory item sells on an invoice or sales receipt, using weighted average cost, and credits Inventory Asset at the same moment. If Cin7 feeds the journals, QBO carries Cin7's COGS figure. Reconcile the two by checking mapping, timing, and lock dates.
Why is my COGS different in Cin7 and my accounting system?
The usual causes are timing, costing method, and account mapping. Cin7 Core costs sales from FIFO or FEFO layers, and COGS posts when the shipment is authorized, while the accounting system may value inventory differently or receive journals in another period. Trace the difference to the transaction that created it before posting any manual journal.
How often should you calculate COGS?
Monthly, at close, against a counted or cycle-counted ending inventory. Quarterly or annual calculation lets small errors compound into large ones. A fixed rhythm with named owners for each input is what keeps the number trustworthy as volume grows.


