Cost of Goods Sold & Inventory Ledger
Turn opening stock, purchase receipts and sales into a traceable inventory cost ledger for one interchangeable product. Compare FIFO with perpetual moving weighted-average costing on the same transaction sequence. See the cost assigned to each sale, the acquisition layers left in stock, and how the methods change gross profit while preserving total available cost. Open the period-end comparison to compare periodic weighted average with both ledger methods from the same inputs. Stock and value charts, transaction inspection and downloadable CSVs let you reconcile the calculations. This is a costing comparison, not an accounting-method election, tax return or compliance determination.
Trace each sale back to its inventory cost
Compare FIFO and moving weighted-average costs, follow remaining stock, and reconcile every purchase to cost of goods sold or ending inventory.
One product. Two ways to assign its cost.
Use the same ordered receipts and sales to see how costing methods affect COGS, ending inventory and gross profit. The examples are illustrative. This comparison does not establish which method your business may use.
Receipts and sales in transaction order
Enter events in the order they occurred. A receipt must precede any sale that needs its stock. Move rows with the buttons below; the calculator does not sort labels or use future purchases to cover an earlier stockout.
4 of 120 transactions. Copying a row creates another real transaction; check the resulting stock and costs.
1. Receipt · deliveryA
1–100 characters, such as an invoice or order reference. Labels do not determine transaction order.
Greater than zero, up to 1,000,000,000; at most six decimal places. A sale cannot exceed stock available before this row.
0–1,000,000,000 with up to six decimals. Use the acquisition price for this receipt.
0–1,000,000,000,000 with up to two decimals, assigned to this receipt only. Enter eligible costs such as freight-in; the tool does not classify costs for accounting or tax purposes.
Current draft stock: 100 → 150 units. Receipt cost USD 650.
2. Sale · orderA
1–100 characters, such as an invoice or order reference. Labels do not determine transaction order.
Greater than zero, up to 1,000,000,000; at most six decimal places. A sale cannot exceed stock available before this row.
0–1,000,000,000 with up to six decimals. Zero is allowed. Gross profit excludes selling costs and other operating expenses.
Current draft stock: 150 → 30 units. Sale revenue USD 2,400; FIFO cost 1,260; moving-average cost 1,320.
3. Receipt · deliveryB
1–100 characters, such as an invoice or order reference. Labels do not determine transaction order.
Greater than zero, up to 1,000,000,000; at most six decimal places. A sale cannot exceed stock available before this row.
0–1,000,000,000 with up to six decimals. Use the acquisition price for this receipt.
0–1,000,000,000,000 with up to two decimals, assigned to this receipt only. Enter eligible costs such as freight-in; the tool does not classify costs for accounting or tax purposes.
Current draft stock: 30 → 70 units. Receipt cost USD 600.
4. Sale · orderB
1–100 characters, such as an invoice or order reference. Labels do not determine transaction order.
Greater than zero, up to 1,000,000,000; at most six decimal places. A sale cannot exceed stock available before this row.
0–1,000,000,000 with up to six decimals. Zero is allowed. Gross profit excludes selling costs and other operating expenses.
Current draft stock: 70 → 40 units. Sale revenue USD 660; FIFO cost 390; moving-average cost 398.571429.
Example product: where the inventory stands
Opening value USD 1,000 + receipt costs USD 1,250 = cost available USD 2,250. Each method assigns that same total between COGS and ending inventory.
Compare the cost assignment
FIFO
Cost of goods sold
USD 1,650
Green: cost released to sales. Bordered slate: cost remaining in stock.
- Ending inventory
- USD 600
- Gross profit
- USD 1,410
- Gross margin
- 46.0784%
Moving weighted average
Cost of goods sold
USD 1,718.57
Green: cost released to sales. Bordered slate: cost remaining in stock.
- Ending inventory
- USD 531.43
- Gross profit
- USD 1,341.43
- Gross margin
- 43.8375%
FIFO minus moving-average COGS: USD −68.57. The same sales revenue applies to both methods. Gross profit excludes selling costs, overhead and taxes; a larger modeled profit is not a recommendation to change accounting methods.
Display rounding can make visible subtotals differ slightly. Exact fractions are retained in the calculations and CSV; tiny nonzero values remain fractions.
Compare period-end weighted average
The period runs from opening inventory through the last transaction. The period average includes every receipt in that window. The moving average uses only the pool on hand when each sale happens.
Period average unit cost
USD 11.842105 / units
USD 2,250 ÷ 190 units available
Periodic minus moving-average COGS
USD 57.74
A positive amount raises period COGS and lowers ending inventory and gross profit by the same amount.
Solid green is cost assigned to sales. Bordered slate is cost left in stock.
FIFO
USD 1,650 COGS · USD 600 in stock
Moving weighted average
USD 1,718.57 COGS · USD 531.43 in stock
Periodic weighted average
USD 1,776.32 COGS · USD 473.68 in stock
| Costing method | COGS | Ending inventory | Gross profit | Gross margin |
|---|---|---|---|---|
| FIFO | USD 1,650 | USD 600 | USD 1,410 | 46.0784% |
| Moving weighted average | USD 1,718.57 | USD 531.43 | USD 1,341.43 | 43.8375% |
| Periodic weighted average | USD 1,776.32 | USD 473.68 | USD 1,283.68 | 41.9505% |
190 units available = 150 units sold + 40 units in stock. For every method, COGS plus ending value equals available cost at exact precision. FIFO assigns the same oldest layers as the transaction ledger.
Selectable period close CSV copy
Follow stock and value through the ledger
Each step shows the position after an event. Horizontal spacing means transaction order, not elapsed time. Quantity and inventory value use separate scales.
Upper scale USD 1,650
Lower scale USD 0
Upper scale 150 units
Lower scale 0 units
Trace a transaction’s cost
Stock 150 → 30 units.
Moving-average basis before this sale: USD 1,650 ÷ 150 units. The sale uses that average for 120 units.
| Acquisition layer | Quantity (units) | Unit cost | Released cost |
|---|---|---|---|
| Opening inventory | 100 | 10 | 1,000 |
| deliveryA | 20 | 13 | 260 |
What remains in inventory?
Moving-average unit cost: USD 13.285714 per units.
| Layer | Quantity (units) | Unit cost | Remaining value |
|---|---|---|---|
| deliveryB | 40 | 15 | 600 |
Complete transaction ledger
| Event | Type | Stock after | Receipt cost | Revenue | FIFO COGS | Moving COGS | FIFO ending value | Moving ending value |
|---|---|---|---|---|---|---|---|---|
| 1. deliveryA | receipt | 150 | 650 | 0 | 0 | 0 | 1,650 | 1,650 |
| 2. orderA | sale | 30 | 0 | 2,400 | 1,260 | 1,320 | 390 | 330 |
| 3. deliveryB | receipt | 70 | 600 | 0 | 0 | 0 | 990 | 930 |
| 4. orderB | sale | 40 | 0 | 660 | 390 | 398.571429 | 600 | 531.428571 |
Export a ledger you can reconcile
Assumptions and limits
- One interchangeable product and one quantity unit; no automatic unit or currency conversion.
- Transactions follow the entered order. Later receipts cannot supply earlier sales.
- Receipt value equals quantity times unit cost plus the acquisition cost assigned to that receipt.
- FIFO releases the oldest available acquisition layers. Moving weighted-average cost uses remaining value divided by quantity immediately before each sale.
- Exact rational costs are retained without internal cent rounding; displayed values may be rounded and tiny nonzero values may remain fractions.
- Gross profit excludes selling costs and operating expenses. Zero revenue makes gross margin unavailable.
- No returns, write-downs, shrinkage, manufacturing allocations, taxes, method elections or compliance determination.
- CSV preserves exact fractions and formula-like values are prefixed with an apostrophe for spreadsheet safety.
CSV includes inputs, both costing methods, every sale’s FIFO allocations and the remaining layers. Exact fractions remain fractions. Formula-like values, including negatives, receive a protective apostrophe.
How to use this calculator
- Load Rising costs and freight or Falling purchase costs. Open Edit stock and transactions, name one product, and choose the same currency and quantity unit for every row.
- Enter opening quantity and its unit cost. For each receipt, enter received quantity, purchase unit cost and the additional acquisition cost assigned to that receipt. For each sale, enter sold quantity and selling price.
- Arrange receipts and sales in their actual sequence with Move up and Move down. Add, copy or remove rows as needed; a copy adds another transaction. Resolve stockouts at the affected sale before applying the ledger.
- Apply inventory ledger. Compare COGS, ending inventory and gross profit. Inspect the separate stock/value charts, select a transaction to trace FIFO allocations or its receipt cost, and review remaining acquisition layers.
- Open Compare period-end weighted average to see how all receipts affect closing COGS and inventory. Download the period close CSV or the complete inventory ledger CSV for reconciliation.
The Formula
The mathematical logic powering this calculation is:
Opening inventory value = opening quantity × opening unit cost. One opening cost layer is used; zero opening quantity contributes zero value even when a unit cost is entered. All transactions must concern one interchangeable product and use one quantity unit and currency. Labels do not convert units or currencies.
Receipt cost = received quantity × purchase unit cost + additional acquisition cost assigned to that receipt. FIFO creates a new acquisition layer with unit cost = receipt cost / received quantity. The moving-average pool adds the receipt’s complete quantity and cost to the remaining pool. You choose which costs belong in the acquisition charge; the calculator does not classify freight, taxes or other expenses for your accounting situation.
Transactions are processed in the order entered. Every sale must have enough stock immediately before that row. Later receipts cannot cover an earlier stockout. A stockout invalidates the ledger with an error at that sale’s quantity; no partial result is presented as a completed ledger. Copying creates a real additional transaction, and moving rows can change costs or stock availability.
For each sale, FIFO releases units from the oldest available layer until the sold quantity is covered. Each allocation records its source layer, quantity, unit cost and released cost. FIFO COGS is the sum of those released costs. The remaining quantity in each layer retains that layer’s unit cost.
Moving weighted-average unit cost before a sale = remaining pool value / remaining pool quantity. Sale COGS = sold quantity × that unit cost. Subtract the sold quantity and that exact cost from the pool. The average changes when a receipt enters the pool; a sale alone does not change it. This is a perpetual moving average, not a periodic average that includes later purchases. After complete stock depletion, both quantity and value are exactly zero; unit cost is unavailable until another receipt arrives.
Periodic weighted-average unit cost = (opening value + all receipt costs) ÷ (opening quantity + all received quantity). The period runs from opening stock through the last entered transaction. Ending inventory = remaining quantity × period average unit cost. Period COGS = available cost − ending inventory. With no available units, the average is unavailable and both assigned costs are zero. The period calculation yields aggregate costs. Earlier sales still require stock. FIFO shows the same final allocation because the same oldest units are sold in this ledger.
Sale revenue = quantity sold × entered selling price. Gross profit = revenue − COGS. Gross margin = gross profit / revenue × 100, unavailable when revenue is zero. Zero-price sales and negative gross profit or margins are retained. Selling expenses, general overhead and taxes are excluded; gross profit is not net profit or cash flow.
For each method, opening value + receipt costs = COGS + ending value. Opening quantity + receipts = sold quantity + closing quantity. All methods use identical quantities and revenue. The transaction comparison is FIFO COGS − moving-average COGS. A positive transaction difference means FIFO assigns more cost to sales. In the period comparison, the signed difference is periodic COGS − moving-average COGS.
Exact rational arithmetic preserves all quantities, unit costs, allocations and totals without internal cent rounding. Display values round half away from zero for readability; tiny nonzero values remain exact fractions when rounding would hide them. The charts and tables use the same model results. Transaction spacing on charts represents event order, not elapsed time. The inventory ledger CSV retains canonical fractions, inputs, both transaction methods, every allocation and remaining layers. The separate period close CSV records the exact cost and quantity reconciliation for all three methods. Formula-like values, including negative amounts, have an apostrophe prefix for spreadsheet safety.
Input limits: 0–120 receipt or sale rows. Opening quantity is 0–1,000,000,000 and each transaction quantity is greater than zero through 1,000,000,000, with at most six decimals. Opening and purchase unit costs and sale prices are 0–1,000,000,000 with at most six decimals. Additional acquisition cost is 0–1,000,000,000,000 per receipt with at most two decimals. Required blanks, malformed decimals, commas, exponents, negative values and overprecision are rejected. IDs are unique, letter-led ASCII strings of 1–40 characters; labels and product names have 1–100 characters, the quantity-unit label 1–24, and the currency label 1–12. Text labels cannot contain control codes or surrounding spaces.
This model excludes LIFO, specific identification, returns, shrinkage, write-downs, manufacturing cost allocations, multiple-product pools, rebates and currency conversion. It does not determine tax treatment, reporting requirements or whether changing a costing method is permitted. Inventory standards include requirements beyond these cost formulas, including valuation considerations not modeled here.
The IFRS Foundation’s IAS 2 materials describe FIFO and weighted-average cost assignment; the 2021 issued text in paragraph 27 describes averaging for a whole period or as receipts arrive. IRS Publication 334 describes the relationship among available cost, closing inventory, COGS and gross profit. These are method references, not a claim that this simplified ledger establishes IFRS compliance or produces a tax-filing result. Sources were reviewed on November 18, 2026.Worked Example
If you input:
- Opening stock: 100 units at USD 10 each: USD 1,000.
- Receipt A: 50 units at USD 12 plus USD 50 acquisition cost: USD 650, or USD 13 per received unit.
- Sale A: 120 units at USD 20: revenue USD 2,400.
- Receipt B and sale B: Receive 40 units at USD 15 with no additional charge, then sell 30 units at USD 22: revenue USD 660.
Result:
Total available cost is USD 2,250 and revenue is USD 3,060. FIFO assigns 100 × 10 + 20 × 13 = USD 1,260 to sale A, then 30 × 13 = USD 390 to sale B. FIFO COGS is USD 1,650; the remaining 40 units are valued at USD 600, and gross profit is USD 1,410. Moving average starts sale A at USD 11 per unit, assigning USD 1,320 and retaining USD 330. Receipt B brings the remaining pool to 70 units costing USD 930. Sale B costs 30 × 930/70 = USD 2,790/7. Total moving-average COGS is USD 12,030/7 (about USD 1,718.57), ending value USD 3,720/7 (about USD 531.43) and gross profit USD 9,390/7 (about USD 1,341.43). FIFO minus moving-average COGS is −480/7, about USD −68.57. Both methods reconcile exactly to USD 2,250 before display rounding. Periodic weighted average includes all 190 available units at USD 225/19 each. Closing inventory is USD 9,000/19 (about USD 473.68), COGS is USD 33,750/19 (about USD 1,776.32) and gross profit is USD 24,390/19 (about USD 1,283.68).
Frequently Asked Questions
What does this cost of goods sold calculator add beyond beginning stock plus purchases minus ending stock?
FIFO allocations show the acquisition layers consumed. Moving average tracks the remaining pool’s cost as receipts and sales occur. The period-end panel adds a single average for all opening stock and receipts. All three reconcile to the available-cost equation.
Is moving average the same as a period-end weighted average?
Moving average uses the stock and cost on hand immediately before each sale. The period-end average pools all opening stock and purchases in the entered period, including purchases after earlier sales. Later price changes can therefore move COGS, ending inventory and gross profit.
Why does changing transaction order change the result?
Receipts change the quantity and cost available for subsequent sales. Moving a receipt after a sale can change the average cost used by that sale or create a stockout. Labels are not dates, and the tool never sorts rows automatically.
Can I include freight or other acquisition charges?
Each receipt accepts an additional acquisition cost allocated across that receipt’s units. Enter only costs appropriate to your records and reporting method. The calculator does not decide whether a charge is capitalizable, deductible or a selling expense.
What happens if I sell more units than are available?
The ledger becomes invalid and identifies the affected sale quantity. Add or move the relevant receipt before the sale, or correct the quantity. The model does not use future stock, create negative inventory or silently reduce a sale.
Why are some exported values fractions?
Partial allocations and moving averages can produce repeating decimals. Exact fractions prevent cumulative rounding from breaking cost reconciliation. The interface rounds for readability, while tiny nonzero amounts remain fractions and the CSV preserves exact values.
Can I compare multiple products or record returns?
Use a separate ledger for each interchangeable product and quantity unit. Returns, shrinkage, write-downs, manufacturing allocations and multi-product pools are outside this model. Do not represent those events by inventing negative receipts or sales.
Does the method with higher gross profit give the correct accounting answer?
A higher gross profit follows from assigning less cost to sales in the entered period. Accounting-method eligibility and changes require separate assessment. Gross profit excludes selling costs, overhead and taxes.
Similar Calculators
EOQ & Inventory Ordering Planner
Compare economic order quantities with pack sizes, all-units discounts, storage and order budgets. Visualize carrying costs, stock cycles and supplier tradeoffs.
Cash Conversion Cycle & Inventory Days Calculator
Calculate inventory, receivable and payable days together. Compare growth and timing scenarios, visualize operating-capital changes, weight balance snapshots and export the full analysis.
Profit Margin Calculator
Calculate gross, operating, and net profit margin percentages for your business or product.
Silver Scrap & Settlement Planner
Calculate recoverable fine silver from mixed lots, compare buyer payouts after fees, and visualize settlement changes across supplied silver-price scenarios.
