What this calculator does
This calculator assigns inventory costs under two cost-flow assumptions, FIFO (first-in, first-out) and LIFO (last-in, first-out). Enter purchase lots and the number of units sold. It returns cost of goods sold (COGS) and ending inventory under each method, and the difference between them. It suits small business owners, bookkeepers and students comparing how the choice of method changes reported profit and stock value.
How to use it
First, fill in Purchase lots: one lot per line, oldest first, written as quantity, unit cost (for example 100, 10.50). Semicolons can also separate lots. Use a point for decimals and leave out thousands separators and currency symbols. Put opening inventory on the first line. Second, fill in Units sold: the total units sold or disposed of in the period. It must not exceed the total quantity of all lots.
Formula
For lots \(i = 1 \dots n\) with quantity \(q_i\) and unit cost \(c_i\), and units sold \(S\):
$$COGS_{FIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,S-\sum_{j<i} q_j\right)\right)$$
$$COGS_{LIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,S-\sum_{j>i} q_j\right)\right)$$
$$EI_m=\sum_{i=1}^{n} q_i c_i - COGS_m,\qquad \Delta = COGS_{LIFO}-COGS_{FIFO}$$
Here \(EI_m\) is ending inventory under method \(m\), and \(\Delta\) is the COGS difference. A positive \(\Delta\) means LIFO gives higher COGS.
Conventions and assumptions
- FIFO: units sold come from the earliest lots first; ending inventory is the most recent purchases.
- LIFO: units sold come from the latest lots first; ending inventory is the earliest lots.
- Periodic layering: all lots are treated as on hand before the sale, with one total for units sold. Perpetual LIFO with interleaved sales can give different results.
- Opening inventory: enter it as the first line at its carried cost.
- Unit cost: used as entered. Enter invoice price minus trade discounts plus freight and other acquisition charges, as IRS Publication 538 (2022) describes purchase cost.
- Unit LIFO only: a single item with specific-goods LIFO; dollar-value and index pools are not used.
- Partial lots: a lot may be partly consumed, and quantities may be decimals.
- Rounding: no intermediate rounding; currency shows 2 decimals.
- Currency: amounts are in whatever currency the unit costs use.
- Weighted-average cost is not included.
Worked example
Lots: 100 units at 10, 150 at 12, 200 at 14. Units sold: 250. Total units available are 450 and the cost of goods available is:
$$100\times 10 + 150\times 12 + 200\times 14 = 5600$$
FIFO takes 100 at 10 and 150 at 12:
$$COGS_{FIFO} = 1000 + 1800 = 2800,\quad EI_{FIFO} = 5600 - 2800 = 2800$$
LIFO takes 200 at 14 and 50 at 12:
$$COGS_{LIFO} = 2800 + 600 = 3400,\quad EI_{LIFO} = 5600 - 3400 = 2200$$
$$\Delta = 3400 - 2800 = 600$$
Ending inventory is 200 units under both methods.
How to read the result
When costs rose across the lots, LIFO reports higher COGS and lower ending inventory than FIFO, so the difference is positive. When costs fell, the difference is negative. If there is a single lot, all lots share one unit cost, nothing is sold, or everything is sold, the difference is zero. The method totals always satisfy COGS plus ending inventory equals cost of goods available. Limitations: the tool does not model perpetual LIFO, dollar-value LIFO, lower of cost or market adjustments, or weighted-average cost. Tax rules for adopting or changing a method are complex, so confirm with a qualified adviser or the IRS.
FAQ
Why do FIFO and LIFO give different COGS?
They assume different units were sold. With changing prices, the lots consumed carry different unit costs, so COGS and ending inventory differ.
Can I enter opening inventory?
Yes. Put it on the first line at its carried cost so it counts as the oldest layer.
Why was my input refused?
Each line needs exactly two plain numbers. A value such as 1,000 is read as two numbers, so write 1000. Units sold also cannot exceed total quantity.
Does this include weighted-average cost?
No. The source used here covers FIFO and LIFO, so weighted-average is not offered.
Is LIFO accepted everywhere?
Rules vary by country and by reporting framework. This tool follows the IRS description and does not assert acceptance elsewhere.
Sources
- Publication 538 (01/2022), Accounting Periods and Methods, Internal Revenue Service (US), 2022