Cost the stock, keep the ledger
Enter the opening inventory and then the purchases and sales in the order they happened. This page runs the ledger under your chosen costing method (FIFO, LIFO or a moving weighted average), costs every sale as it occurs, and reconciles: cost of goods sold plus ending inventory always equals the goods that were available, and any sale that asks for more than the shelf holds is stopped and named.
Purchases need their unit cost. Sales are costed by the method, so their cost field is ignored. Rows left completely empty are skipped. The note field is for your own reference (a date, a supplier, an order number) and appears in the ledger.
Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice, and it is not tax or accounting advice. Which costing methods you may use, and when you must stay consistent with one, is set by your accounting standards and tax rules, not by this page.
What this calculator does
It is a costing engine, not a single formula. Purchases stack into the inventory at their own costs; every sale is then costed by consuming those layers (oldest first under FIFO, newest first under LIFO) or at the moving average under weighted average, where the average is rebuilt after each purchase and each sale’s cost is rounded to cents as it is posted. The output is the full transaction ledger, line by line, with the balance in units and value after every event, the layers left on the shelf at the end, and a comparison table running all three methods over your identical figures. The reconciliation is built in and stated in the results: under every method, cost of goods sold and ending inventory sum to the same goods available; the methods only argue about where the cost sits, in the period’s expenses or on the shelf.
How to use it
- Order is data. Layers and moving averages are both sequence-dependent: enter purchases and sales in the order they actually happened. A purchase entered after a sale it really preceded will cost that sale from the wrong layer or at the wrong average, and no method choice can repair a scrambled timeline.
- The opening inventory is layer zero. Bring it in at its carried cost per unit, the figure your books already hold, not at today’s replacement price. Every later number inherits this starting layer, and restating it quietly rewrites history.
- Know which weighted average you are looking at. This page runs the perpetual (moving) average, recalculated after each purchase, which is what inventory systems do. A periodic average (one average for the whole period, applied at the end) gives different sale costs on the same figures; if your accounts use the periodic form, your ledger here will differ in the sales lines while agreeing on the goods available.
- A blocked sale is information. The engine refuses a sale larger than the stock on hand at that moment and names the transaction. In real records that event means a missing purchase, a mis-keyed quantity, shrinkage, or a genuinely negative stock position your system allowed; each has a different fix, and the ledger shows exactly where the timeline breaks.
- The method is an accounting policy, not a preference per period. Standards and tax rules restrict switching (and LIFO is not permitted under IFRS at all, while US rules allow it with conformity requirements). Run the comparison here to understand your policy’s consequences; change the policy itself only with your accountant and within the rules that govern you.
How it is calculated
- Goods available = opening units and value + all purchases. Every method starts from this same total, shown in the results.
- FIFO: each sale consumes the oldest remaining layers first; its cost is the sum of the consumed units at their layer costs.
- LIFO: each sale consumes the newest remaining layers first, same construction.
- Weighted average (moving): after each purchase the average cost = value on hand / units on hand; each sale is costed at the current average, rounded to cents when posted, and the value on hand falls by the posted cost.
- Cost of goods sold = the sum of the posted sale costs. Ending inventory = goods available value – COGS, cross-checked against the layers remaining, and the units reconcile the same way: sold units + ending units = available units.
Worked examples
One set of books, three stories. Opening 100 units at $10. Buy 50 at $12. Sell 120. Buy 40 at $13. Sell 30. Goods available: 190 units costing $2,120. Under FIFO, the first sale costs 100 at $10 plus 20 at $12 ($1,240), the second costs 30 at $12 ($360): COGS is $1,600 and the shelf ends holding 40 units at $13, $520. Under LIFO, the sales cost from the newest layers back ($1,300 and $390): COGS is $1,690 and ending inventory $430. Under the moving average, the average after the first purchase is $10.6667, the first sale posts at $1,280.00, the second purchase lifts the average to exactly $12.00 and the second sale posts $360: COGS $1,640, ending $480. Three methods, three profits on identical trading, and each pair sums to the same $2,120.
Why the order of entries matters. Move the second purchase (40 at $13) to before the first sale and FIFO’s first sale still costs $1,240 (the $13 layer waits its turn), but LIFO’s first sale now reaches into the $13 layer and costs $1,360 instead of $1,300, and the weighted average moves too. The timeline is part of the data; the ledger makes its effect visible instead of hiding it in a single period figure.
Reading your results
Read the reconciliation first: if COGS plus ending does not equal goods available, something is wrong with the inputs, not the method; on this page it always ties, in all three methods, because the engine derives one figure from the other two. Then read the comparison table as a policy statement. In a period of rising purchase prices, FIFO leaves the newest costs on the shelf (ending inventory tracks replacement cost) and reports the lower COGS; LIFO does the reverse, charging recent costs against revenue and leaving old costs stranded in the inventory figure, sometimes for years. The weighted average walks between them. None of the three is the truth about your stock; each is a convention, defensible when applied consistently and disclosed, and the comparison table shows the size of the convention’s effect on your own numbers rather than in the abstract.
Limitations
- Costs are as entered per purchase. Landed cost elements (freight in, duties, handling) belong inside the unit cost you enter for each purchase if your policy capitalises them; the engine cannot split a supplier invoice into product and freight for you.
- One product, one ledger. Each run costs a single item. Multi-product inventories repeat the exercise per item; there is no basket effect to model, but there is also no shortcut.
- Returns, shrinkage and write-downs are transactions you must add. A customer return is a purchase-shaped event at its original cost (reverse the sale’s layer logic by re-entering carefully); a write-down to net realisable value is an accounting adjustment this engine does not perform.
- Periodic weighted average and specific identification are not offered. The average here is the moving, perpetual form; specific identification (costing each unit by its own serial identity) belongs to industries whose systems track units individually.
Frequently asked questions
What is the difference between FIFO, LIFO and weighted average?
All three start from the same purchases and the same total cost; they differ in which costs a sale is charged with. FIFO charges the oldest costs, leaving the newest in inventory. LIFO charges the newest costs, leaving the oldest in inventory. Weighted average charges every sale at the running average cost of what is on hand. In rising prices FIFO therefore shows the lowest cost of goods sold and the highest ending inventory of the three, LIFO the opposite, and the average sits between, as the comparison table on your own figures will show.
Why do COGS and ending inventory always add up to the same total?
Because every dollar of goods available has only two places to go: out the door with a sale, or still on the shelf at the end. The methods are allocation conventions over a fixed total, not different totals. That identity is also the engine’s self-check: a costing run that does not reconcile has an input error in it, whatever method produced it.
Can I switch methods whenever one gives a better answer?
No. Costing method is an accounting policy: standards require consistency period to period, changes need justification and disclosure, LIFO carries extra conformity rules in the US and is prohibited under IFRS, and tax filings may be tied to the book method. Use the comparison on this page to understand what your current policy does to your figures; treat any change as an accountant-led project, not a toggle.
What does it mean when a sale is blocked for insufficient stock?
That at that point in the entered timeline, the shelf holds fewer units than the sale asks for. In live records the usual causes are a purchase that happened but was not recorded, quantities keyed in the wrong unit (cases versus eaches is the classic), theft or damage never written off, or sales genuinely shipped against stock that had not arrived. The ledger names the transaction where the break occurs, which is where the investigation starts.
Related calculators
Method: perpetual layer costing under FIFO or LIFO, and moving weighted average with sale costs rounded to cents when posted; goods available reconciled against cost of goods sold plus ending inventory, exactly as defined on this page. Last reviewed: 13 October 2026.