Racklipedia
Racklify
​
Fulfillment

Cost of Goods Sold Formula for Ecommerce Inventory

By William Carlin
Updated November 30, 2026
Published November 13, 2026

COGS

Definition

Cost of goods sold (COGS) is the direct cost of producing the products a business sells, including materials, direct labor, and manufacturing overhead. It is deducted from revenue to calculate gross profit and supports inventory valuation and profitability analysis.

Overview

COGS for ecommerce inventory is calculated with the standard equation: Beginning Inventory + Purchases (including freight‑in) − Ending Inventory = Cost of Goods Sold. That is the cogs equation most accountants and ecommerce operators use to convert inventory movement into gross cost for a reporting period.


Use beginning inventory (what you had on the books at the start), add net purchases you made during the period (product cost plus freight‑in and any direct procurement charges), then subtract the ending inventory value (what remains on the books at period end). The result is the direct cost of the goods that were sold and should be deducted from revenue to compute gross profit.


How To Use The COGS Equation


Apply the equation at the close of each accounting period (monthly, quarterly, annually) after reconciling physical counts or cycle counts to your inventory ledger. Beginning Inventory equals last period's ending inventory. Purchases should be recorded net of purchase returns and allowances. Ending Inventory is the value assigned using your chosen inventory-costing method (FIFO, weighted average, or LIFO where allowed).


Including Freight‑In (Landed Cost)


Inbound freight (freight‑in) is normally added to the cost of purchases rather than treated as a selling or operating expense. That means freight charges you pay to receive product become part of inventory value and increase COGS when those items are sold.


  • Freight‑In Treatment: Add freight‑in to the purchase cost on the PO or supplier invoice so inventory carries the landed cost.
  • Other Landed Costs: Include customs duties, import fees, and non‑refundable brokerage when they are directly attributable to acquiring inventory.
  • Separate Freight‑Out: Outbound shipping to customers is normally an operating (fulfillment) expense, not freight‑in.


Accounting For Shrinkage


Shrinkage is the difference between book (expected) inventory and counted inventory caused by theft, damage, miscounts, or administrative errors. Shrinkage reduces the value of ending inventory and therefore increases COGS if not corrected.


Two common approaches to record shrinkage:


  • Inventory Adjustment: Debit COGS (or a shrinkage expense) and credit Inventory for the dollar amount of the loss, which immediately increases COGS for the period.
  • Revaluing Ending Inventory: Reduce ending inventory to the counted level before applying the COGS equation; the lower ending inventory produces a higher COGS number.


Treatment Of Fulfillment Expenses


Fulfillment costs (pick & pack labor, warehouse handling fees, outgoing parcel postage, and marketplace fulfillment charges) are often visible to ecommerce teams and must be classified consistently. Generally, fulfillment expenses are treated as operating (selling) expenses, not part of COGS, because they occur after the product is ready for sale.


However, some direct costs that are part of bringing a product to sellable condition (for example, custom packaging or kitting applied before sale) may be included in inventory and therefore in COGS. The deciding factor is whether the cost is directly tied to producing or acquiring the inventory item versus costs incurred to fulfill an individual customer order.


  • Direct Production/Acquisition Costs: Include in inventory (COGS) — examples: raw materials, manufacturing labor, import duties, freight‑in, kitting materials added before listing.
  • Fulfillment/Distribution Costs: Typically expense as SG&A — examples: outbound shipping, carrier postage, marketplace FBA/3PL pick & pack fees, returns processing, and customer service.
  • Consistency Rule: Choose a policy and apply it consistently period to period to comply with matching and disclosure requirements.


Practical Example


Example period figures for an ecommerce seller:


  • Beginning Inventory: $50,000
  • Purchases (product cost): $120,000
  • Freight‑In: $3,000 (added to purchases)
  • Expected Ending Inventory (book): $30,000
  • Physical Counted Ending Inventory: $28,500 (shrinkage of $1,500)


Step 1 — adjust for shrinkage: reduce ending inventory to counted amount ($28,500). Step 2 — apply the cogs equation using adjusted ending inventory:


COGS = $50,000 + ($120,000 + $3,000) − $28,500 = $144,500


The $1,500 shrinkage is reflected because ending inventory is lower, which increases COGS accordingly. Alternatively, you could post an inventory‑adjustment journal (Debit COGS $1,500; Credit Inventory $1,500) and then compute COGS with the book ending inventory.


Tips For Consistent Accounting


  • Document Policy: Define what counts as COGS versus fulfillment expense and document it in your accounting policy.
  • Track Landed Costs: Put freight‑in and import charges on purchase receipts or use “landed cost” functionality in your inventory system to avoid under‑stating inventory cost.
  • Reconcile Regularly: Run cycle counts and reconcile inventory accounts monthly to catch shrinkage and posting errors quickly.
  • Coordinate With Your Accountant: Confirm treatment of fulfillment fees and packaging with your CPA so tax reporting and financial statements agree.
  • Use Your WMS/WMS Integrations: Configure warehouse and 3PL feeds to tag costs as inbound (inventory) vs outbound (fulfillment) to preserve clean ledgers.


In short, the COGS equation for ecommerce inventory is Beginning Inventory + Purchases (plus freight‑in and other direct acquisition costs) − Ending Inventory; adjust ending inventory for shrinkage and apply a consistent policy for fulfillment costs so gross profit and inventory valuations are accurate and auditable.

Sources And Additional Reading (4)

More from this term
Looking for a 3PL?

Compare warehouses on Racklify and find the right logistics partner for your business.