Skip to main content

Microtec

Inventory Valuation and COGS Calculator

Enter opening stock and the purchases and sales of one item to see cost of goods sold, ending inventory and gross profit under FIFO and weighted average, side by side.

SAR
Weighted average type

Advanced mode adds a date to each movement. The calculator follows the order of the list.

First in, first out FIFOLower cost

Cost of goods sold
—
Ending inventory
—
Gross profit
—

Moving weighted averageLower cost

Cost of goods sold
—
Ending inventory
—
Gross profit
—

How was this calculated?
MovementQtyCost inCost outBalance qtyBalance value

The cost of goods sold formula is simple at company level, but for a single item bought at changing prices the answer depends on the valuation method. Enter opening stock and the item's purchases and sales in order, and the calculator works out cost of goods sold and ending inventory under first in, first out (FIFO) and weighted average side by side, with the profit gap between them. Both methods are accepted in the financial statements of companies in Saudi Arabia; LIFO is not. For the whole business, the COGS formula tab works from opening and closing balances and purchases.

Short answerCost of goods sold equals opening inventory plus purchases minus closing inventory. The valuation method decides which purchase prices go to cost and which stay on the shelf.

How to calculate cost of goods sold under both methods

Under FIFO the oldest units are treated as sold first, so each sale is costed from the oldest purchase layer still in stock and the newest units remain at the end. Under moving weighted average, the unit cost is recalculated after every purchase (stock value ÷ stock quantity) and each sale is costed at that average. Periodic weighted average works out one average at the end of the period from everything that was available for sale.

COGS = Opening + Purchases − Ending  ·  WAC = Stock value ÷ Stock quantity

Example, an item with rising prices: opening stock 100 units at SAR 10; buy 200 at SAR 12; sell 150 at SAR 20; buy 100 at SAR 15; sell 180 at SAR 22. Goods available for sale SAR 4,900.00, sales SAR 6,960.00, and 70 units left.
FIFO: COGS SAR 3,850.00, ending inventory SAR 1,050.00 (70 units at 15), gross profit SAR 3,110.00.
Moving weighted average: COGS SAR 4,004.00, ending inventory SAR 896.00, gross profit SAR 2,956.00.
Periodic weighted average: COGS SAR 4,042.50, ending inventory SAR 857.50. Load it with the "Example: rising purchase prices" button.

The cost of goods sold formula for a whole period

If you do not track every movement but you do count stock at the start and end of the period, cost of goods sold is what was available for sale less what is left: opening inventory, plus purchases and freight-in, less purchase returns, less closing inventory. This is the periodic system, and closing inventory is the physical count valued under one of the two methods.

Example, a shop over a full year: opening inventory SAR 50,000, purchases SAR 180,000, closing inventory SAR 65,000. COGS is SAR 165,000.00; on net sales of SAR 240,000, gross profit is SAR 75,000.00, or 31.3% of sales.

Why FIFO and weighted average give different results

When purchase prices rise, FIFO gives lower cost, higher profit and an ending inventory closer to market price, because what remains is what you bought last. When prices fall, the effect reverses. Weighted average lands between the two and smooths out price swings. The gap is not a real gain or loss: cost plus ending inventory is the same under both methods, and only the timing of cost in the income statement changes.

Ending inventory sits on the balance sheet and feeds into the zakat base, so the valuation method moves both figures. Pick one method, keep it from year to year, and disclose any change in the financial statements.

Why LIFO is not offered here

Last in, first out (LIFO) is not permitted under IAS 2 Inventories, and IFRS is the framework endorsed in the Kingdom. IAS 2 allows FIFO and weighted average, and specific identification for items that are not interchangeable, such as property or vehicles tracked by serial number. Finance staff used to US GAAP, where LIFO is still permitted, need to drop it when preparing accounts for a Saudi entity.

Download the item's movements in Excel

The "Download Excel with movements" button gives you two sheets. The moving average sheet is built with formulas, each row taking its cost and balance from the row above, so changing a quantity or price updates the whole table, with a cell for the periodic average. The FIFO sheet lists the layers used by each sale. The comparison and both movement tables also download as a PDF.

Common mistakes in inventory valuation

  • Costing every unit sold at the latest purchase price.
  • Leaving freight on purchases out of inventory cost.
  • Entering movements out of date order, which changes the average and the FIFO layers.
  • Carrying closing stock at cost when its net realisable value is lower; IAS 2 requires the lower of the two.
  • Switching method between years without disclosure.

What to do after the result

Compare cost of goods sold here with your books for the same item; a large gap points to a missing movement or a wrong price. If what you need is the value of stock at the closing date, take the ending inventory figure under your company's method and test it against net realisable value before you book it. Download the Excel file to carry on with the rest of the month, or keep the PDF with the stock count file.

When you carry hundreds of items, not one

The calculator walks through one item. In a store or warehouse with hundreds of items, every purchase invoice shifts an average or adds a layer, every sale, return and transfer moves the balance, and manual costing falls behind. At Microtec we offer anyone running a store or warehouse in the Kingdom accounting software (ERP) with purchasing, inventory, sales and finance together. Load your fastest-moving items into the trial and watch their cost for a month.

Frequently asked questions

What is the cost of goods sold formula?

Add opening inventory and purchases, then subtract closing inventory. A shop that started with SAR 50,000 of stock, bought SAR 180,000 and ended with SAR 65,000 has a cost of goods sold of SAR 165,000.

What is the difference between FIFO and weighted average?

FIFO costs each sale at the oldest purchase prices still in stock, while weighted average costs it at the average cost of all units on hand. With rising prices, FIFO gives lower cost and higher profit.

Is LIFO allowed in Saudi Arabia?

No. IAS 2, which applies in Saudi Arabia under IFRS, does not permit LIFO. It allows FIFO, weighted average and specific identification for items that are not interchangeable.

What is the difference between moving and periodic weighted average?

Moving average is recalculated after every purchase, so each sale is costed at the average of that moment; periodic average is one figure for the whole period, worked out at its end. They differ slightly when prices change between sales.

↑