How FIFO and Moving Average valuation work
The valuation method decides the rate at which ERPNext values each unit that leaves stock. That rate sets the value of the stock you keep and your cost of goods sold (COGS).
Why the valuation method matters
ERPNext values stock perpetually. Every stock movement (a receipt, an issue, a transfer, or a manufacture) updates the quantity and the value of the item in the stock ledger at once.
The valuation rate is the cost of one unit of an item in a warehouse. It includes the purchase price and the costs to make the item ready for sale, such as freight and duties. When stock goes out, ERPNext must choose which cost to use. The valuation method makes that choice.
ERPNext has three valuation methods:
- FIFO (First In, First Out)
- Moving Average
- LIFO (Last In, First Out)
How FIFO works
FIFO assumes that the oldest stock goes out first. For each item and warehouse, ERPNext keeps a queue of layers. Each layer is a quantity and a rate.
- Each receipt adds a layer at its incoming rate.
- Each issue takes units from the oldest layers first, at the rates of those layers.
The valuation rate at any moment is the weighted average of the layers that remain. Each unit that goes out is costed at the rate of the layer it comes from.
| Step | Transaction | Queue after | Stock value |
|---|---|---|---|
| 1 | Receive 10 at 100 | 10 at 100 | 1,000 |
| 2 | Receive 10 at 120 | 10 at 100, 10 at 120 | 2,200 |
| 3 | Issue 15 | 5 at 120 | 600 |
At step 3, the 15 units cost (10 × 100) + (5 × 120) = 1,600. In a company with perpetual inventory, ERPNext books 1,600 to COGS and credits the stock account by 1,600. The remaining 5 units keep their rate of 120.
Advantages of FIFO:
- COGS reflects the price you paid for the units that went out.
- The remaining stock is valued at the most recent purchase prices.
- You can trace which layers each issue consumed, which helps audits.
- It matches the physical flow of perishable and shelf-life items, which you issue oldest first.
Disadvantages of FIFO:
- When prices rise, older and cheaper layers go to COGS first. This can understate COGS and overstate profit.
- ERPNext must store and walk the layer queue for each item and warehouse, which takes more computation.
- A backdated entry changes which layers later issues consume. ERPNext must recompute all later entries.
How Moving Average works
Moving Average keeps one average rate for each item and warehouse. Each receipt recalculates the average:
new average = (current qty × current average + incoming qty × incoming rate)
/ (current qty + incoming qty)Issues go out at the current average and do not change it. Only receipts and revaluations change the average.
| Step | Transaction | Qty in stock | Average rate | Stock value |
|---|---|---|---|---|
| 1 | Receive 10 at 100 | 10 | 100 | 1,000 |
| 2 | Receive 10 at 120 | 20 | 110 | 2,200 |
| 3 | Issue 15 | 5 | 110 | 550 |
At step 2, the average becomes (10 × 100 + 10 × 120) / 20 = 110. At step 3, the 15 units cost 15 × 110 = 1,650. ERPNext books 1,650 to COGS, and the remaining 5 units are worth 550.
Advantages of Moving Average:
- One blended rate smooths price changes, so COGS and margins are steadier.
- ERPNext keeps one rate for each item and warehouse, not a queue of layers.
- "One item, one current cost" is easy to understand and to reconcile.
- It suits interchangeable, fast-moving items, such as fasteners, fuel, or bulk chemicals.
Disadvantages of Moving Average:
- The cost of goods that go out is a blend. It can differ from the price you paid for the units you shipped.
- When prices change fast, the average trails the current market cost.
- You cannot say which units left at which cost, only what the average was.
- A backdated receipt changes the average for all later entries. ERPNext must recompute all later entries.
How LIFO works
LIFO keeps the same queue of layers as FIFO, but each issue takes units from the newest layers first. In the example above, the 15 units issued at step 3 cost (10 × 120) + (5 × 100) = 1,700. The remaining 5 units stay at 100.
FIFO and Moving Average compared
With the same receipts and issues, FIFO and Moving Average give the same total cost. They split that cost differently between COGS and the stock you keep. In the examples above, the total is 2,200 for both methods:
| Method | COGS | Value of remaining stock | Total |
|---|---|---|---|
| FIFO | 1,600 | 600 | 2,200 |
| Moving Average | 1,650 | 550 | 2,200 |
| Aspect | FIFO | Moving Average |
|---|---|---|
| Cost of goods that go out | Rate of the oldest remaining layer | Current average rate |
| Tracks the cost of each lot | Yes | No |
| Value of remaining stock | Most recent purchase prices | The average rate |
| Data that ERPNext keeps | A queue of quantity and rate layers | One average rate |
| Backdated entry causes reposting | Yes | Yes |
| Computation | Higher | Lower |
| Suits | Perishable, lot-rotated, and high-value items | Interchangeable, high-volume items |
Backdated entries cause reposting
With FIFO, Moving Average, and LIFO, the value of each stock ledger entry depends on the entries before it. So ERPNext must recompute every later entry for the item and warehouse when you:
- create a backdated stock transaction,
- cancel or amend an old stock transaction,
- submit a Landed Cost Voucher against an old receipt, or
- change a past valuation rate.
This recomputation is called reposting. ERPNext recalculates the quantity, rate, value, and accounting entries of each later stock ledger entry. On items with a long history, reposting is slow and changes the value of stock that you considered settled. Learn more in Repost item valuation.
Where the valuation method is set
ERPNext looks for the valuation method in this order, and uses the first one it finds:
- Valuation Method on the Item.
- Default Stock Valuation Method on the Company, in the Stock and Manufacturing tab. The default is FIFO.
- Default Valuation Method in Stock Settings. ERPNext uses this setting only when a document has no company, for example a Batch.
Set the method at each level so that every item gets the method you expect. Serialized items are valued at Moving Average once stock transactions exist, unless you use serial number wise valuation.
After an item has stock transactions, you can change its method only from FIFO to Moving Average. Learn how in Change the valuation method.
Choose a valuation method
| Your situation | Method |
|---|---|
| Perishable or shelf-life items that you issue oldest first | FIFO |
| High-value or lot-traceable items that need precise cost | FIFO |
| Tax or reporting rules that expect the actual cost flow | FIFO |
| Interchangeable, fast-moving items | Moving Average |
| You want steadier margins | Moving Average |
| You want less valuation data to maintain | Moving Average |
Good practices for both methods:
- Set the method before the item has any stock transaction.
- Use perpetual inventory, so that the stock value and the accounts stay in step.
- Group your backdated corrections, and enter them when few users work, because they cause reposting.
- Submit Landed Cost Vouchers soon after the receipt, to avoid large revaluations later.
- Compare the stock value with the stock account balance regularly. Use the Stock and Account Value Comparison report.
- Use the same method for items of the same kind, so that their margins are comparable.