The cost of goods sold formula is beginning inventory plus purchases minus ending inventory. The result is the cost of the products you sold during the period. Freight, duties and prep are built into the inventory value, and products still sitting in a warehouse or at Amazon stay out of it until they sell.
For an Amazon or Shopify seller, cost of goods sold (COGS) is usually the largest expense on the profit and loss statement, and it is also the figure most likely to be wrong. Book a $30,000 inventory order as an expense the day you wire your supplier and your books can show a loss in March and a large profit in November, even with steady sales. That hides your real margin. It can also shift taxable income into the wrong year.
How to Use the Cost of Goods Sold Formula
You need three dollar figures for the same period: the value of inventory at the start, the cost of inventory you added and the value of inventory left at the end. Beginning inventory plus purchases gives you goods available for sale. Subtract ending inventory, and what remains is the cost of the goods that left your shelves.
Beginning Inventory, Net Purchases and Ending Inventory
Beginning inventory (also called opening inventory) is the value of unsold stock on the first day of the period. It should match last period’s ending inventory exactly. If it does not, something changed after the books closed, and you need to find out what.
Net purchases are the landed cost of inventory bought during the period: the supplier invoice plus freight-in and duties, minus supplier discounts and returns. Count only goods you plan to resell. Packing tape for the office or a new label printer goes elsewhere.
Ending inventory (also called closing inventory) is the value of everything you still own at period end. For ecommerce, that includes units at Amazon FBA, at a 3PL, in your garage and in transit to a warehouse when you already own them. Sellers often leave out goods on the water, which pushes COGS too high.
A Step-by-Step Example for an Online Store
Say you sell kitchen gadgets on Amazon and Shopify and want COGS for the year.
You start January with $40,000 of inventory across FBA and your 3PL. During the year, you buy $65,000 of product from your supplier. On December 31, your inventory records show $35,000 of stock still on hand.
First, add beginning inventory and purchases: $40,000 + $65,000 = $105,000. That is your goods available for sale. Next, subtract ending inventory: $105,000 − $35,000 = $70,000. Your COGS for the year is $70,000, and on $180,000 of sales, gross profit would be $110,000. That figure is not final yet, because purchases still need adjusting.
Adjust Purchases for Freight, Discounts and Supplier Returns
The extended version of the formula uses net purchases in place of raw supplier invoices. Net purchases equal purchases, plus freight-in and duties, minus purchase discounts, minus returns to suppliers.
Back to the example. Add $4,000 of ocean freight and $2,500 of import duties, then subtract a $1,500 early-payment discount and $2,000 of defective units sent back for credit. Net purchases become $65,000 + $4,000 + $2,500 − $1,500 − $2,000 = $68,000.
Assuming your $35,000 ending inventory already carries its share of freight and duties, COGS is now $40,000 + $68,000 − $35,000 = $73,000, and gross profit drops to $107,000. Duties and freight belong in the cost of each unit, so they reach COGS in the period that unit sells rather than the month the bill arrives.
Which Ecommerce Costs Belong in COGS
A cost belongs in COGS when it is needed to buy or make a product and get it ready to sell. Costs of selling it, marketing it or running the business go into operating expenses. For online sellers, the tricky cases are marketplace fees, fulfillment and outbound shipping.
Product Cost, Inbound Freight, Duties and Sale-Ready Prep
Your core COGS items are the supplier’s unit price and inbound freight to your warehouse, 3PL or FBA. Add customs duties, tariffs and broker fees on imports, plus prep work that makes a unit sellable: poly bagging, FNSKU labels, bundling and retail packaging that ships as part of the product. Moving a pallet from a 3PL into FBA is also inbound cost, since the unit is not ready to sell until it arrives.
These costs are capitalized. They become part of each unit’s value on the balance sheet and turn into COGS only when that unit sells.
Marketplace Fees, Advertising and Outbound Shipping
Amazon referral fees, FBA fulfillment fees, storage fees, Shopify Payments processing and PPC spend are most often booked as operating expenses, or as a separate selling-costs group below gross profit. Outbound shipping to customers and your Shopify subscription follow the same treatment, and indirect costs like rent and salaries stay out of COGS too.
Some brands place per-order fulfillment and payment fees in a broader cost of sales section so gross margin shows unit economics more clearly. Either layout can work for management reports. What matters is that you choose one, apply it every month and keep tax reporting in line with the inventory rules. Fees that sit in COGS some months and in operating expenses in others make your margin trend useless.
Materials, Labor and Overhead When You Make Products
If you manufacture, COGS comes from production cost: raw materials, direct labor for the people who make or assemble the goods, and manufacturing overhead such as production supplies, equipment depreciation and the share of workshop rent and utilities tied to production.
Manufacturers first work out the cost of goods manufactured, then use it in place of purchases in the formula. A candle brand, for example, adds wax, wicks, jars and the wages of the person pouring them, while its office manager’s salary stays in operating expenses. Write down how you allocate overhead so you apply it the same way each year.
Tracking COGS Across Amazon, Shopify and Your 3PL
COGS tracking works when one system ties every unit’s landed cost to the sale that moved it, across every channel and location. Under accrual accounting, the cost hits your income statement in the same month as the revenue, which is what makes monthly profit meaningful.
Reconcile Inventory Across Every Location
Your inventory lives in more than one place, and each place keeps its own count. At least monthly, compare your accounting records with FBA inventory reports, your 3PL’s on-hand report and any stock you hold yourself. Look for lost or damaged FBA units, removal orders and units stuck in inbound shipments.
Lost units should come out of inventory, and Amazon’s reimbursement for them should be recorded as income or a cost recovery rather than left inside the inventory value. Record gross sales rather than the net settlement deposit, so fees and refunds keep their own lines. This monthly check is a core part of good cloud bookkeeping for ecommerce brands.
Periodic or Perpetual Tracking, and Your Valuation Method
A periodic system updates inventory only when you count it, often at quarter or year end, so COGS for the months in between is an estimate. It is cheap and workable for a small single-channel seller.
A perpetual system records cost each time a unit sells, so COGS posts daily or with every settlement. A2X connected to QuickBooks Online, for example, can post COGS alongside each Amazon or Shopify settlement once your unit costs are loaded. Setup takes more work, and in return you get a real gross margin every month and earlier warning when a SKU stops making money.
Your inventory valuation method, usually FIFO or weighted average for ecommerce sellers, decides which purchase costs move into COGS when prices change between orders. Whichever you choose, apply it consistently, because switching methods generally requires filing Form 3115 with the IRS.
COGS Mistakes That Distort Profit and Tax
The most expensive COGS mistakes either move costs into the wrong year or leave the inventory figure on your balance sheet wrong. Each one changes gross profit, and on a tax return, wrong gross profit means wrong taxable income.
Expensing Inventory Purchases or Counting Freight Twice
Paying a supplier swaps cash for an asset. If a $25,000 purchase order is coded straight to COGS, that year’s profit drops by $25,000 even if half the units are still at FBA in January. The reverse error is common too: freight gets added into each unit’s cost and then booked again as a separate shipping expense, so the same cost lands on the P&L twice.
Overstating or Understating Unsold Inventory
Ending inventory is the input most likely to be wrong. Every dollar you overstate it lowers COGS by a dollar and raises taxable income by a dollar. Count $5,000 of stock that was lost at FBA and you pay tax on $5,000 of profit you never made. The error reverses the next year, but by then you have paid the tax and may have priced from false margins.
Dead and damaged stock needs its own process. The rules for an inventory write-off for FBA sellers explain when you can reduce inventory and what records you need.
Confusing Gross Profit, Gross Margin and COGS Percentage
Gross profit is a dollar amount: revenue minus COGS. Gross margin is gross profit divided by revenue. COGS percentage is COGS divided by revenue.
In the example, $107,000 of gross profit on $180,000 of sales gives a gross margin of about 59.4% and a COGS percentage of about 40.6%, and the two always add up to 100%. Mixing them up leads to pricing errors, such as marking up cost by 40% when you meant to keep a 40% margin. A 40% markup on a $10 unit gives a $14 price and only a 28.6% margin.
Reporting COGS on Schedule C or Form 1125-A
Sole proprietors and single-member LLCs taxed as disregarded entities report COGS in Part III of Schedule C. You enter beginning inventory, purchases (minus items withdrawn for personal use), labor, materials and supplies, other costs and ending inventory, and the result carries to line 4. Part III also asks for your inventory valuation method and whether you changed how you determine quantities, costs or valuations.
Partnerships, S corporations and C corporations file Form 1125-A with Form 1065, 1120-S or 1120. It follows the same structure and also asks about Section 263A costs and LIFO. Ending inventory on the return must match the balance sheet behind it, and a year-end ecommerce accounting checklist should include a full count and valuation review before you file. Smaller businesses that meet the IRS gross receipts test have simpler inventory options, and that threshold is adjusted for inflation each year. This is general information, so confirm how the rules apply to your own return with a CPA.
If the inventory on your balance sheet and the figure on last year’s return do not agree, that gap needs closing before you file again. Our CPAs can review your inventory and COGS records with you and help track down the difference.
Frequently Asked Questions
How do I calculate COGS from sales and gross profit?
Subtract gross profit from revenue. If your store had $200,000 in sales and $90,000 in gross profit, COGS was $110,000. This shortcut only works when gross profit was itself built from a correct COGS figure, so it is a check, not a substitute for the inventory formula.
How do I calculate cost of goods sold in Excel?
Put beginning inventory in B2, net purchases in B3 and ending inventory in B4, then enter =B2+B3-B4 in B5. Add revenue in B6, and use =B6-B5 for gross profit and =(B6-B5)/B6 for gross margin.
Is inventory deductible when I buy it?
Generally, no. Under the standard rules, inventory costs reach your return through COGS as units sell, so stock still on hand at year end is not deducted that year. Businesses under the gross receipts threshold can use simpler methods, which can change the timing, so check which option fits before year end.
Can I calculate COGS without a physical inventory count?
Yes. A perpetual system that records cost at every sale can supply ending inventory without a full count. You should still reconcile against FBA and 3PL reports regularly, because lost, damaged and miscounted units pull your records away from reality over time.
Are cost of sales and cost of revenue the same as COGS?
They overlap but are not identical. Cost of sales often means COGS, though some businesses include fulfillment or payment fees in it. Cost of revenue is broader still, and cost of services applies to service firms that hold no inventory.
Get Your COGS Right Before Your Next Filing
A wrong ending inventory figure or a freight bill in the wrong account can overstate your profit, understate it or push tax into the wrong year. AMZ Accountant’s licensed CPAs have more than 15 years of accounting and tax experience and specialize in ecommerce, so we can help you get inventory and COGS right in your books and on your return. Schedule a free 15-minute discovery call to talk it through; it is free, with no obligation.