Cost of Goods Sold: The Formula, Where It Sits in the Income Statement and Why It Defines Your Profit

Accountants reviewing cost of goods sold on a reporting dashboard

Cost of goods sold is what your business actually paid for the goods it sold during a period, not for everything it bought. The cost of goods sold formula is simple: opening inventory + net purchases − closing inventory. That figure is the first deduction from sales in the income statement, and it produces the gross profit that every other decision rests on.

Many shop and store owners look at the bank balance or total sales and assume they know their profit. If cost of goods sold is wrong, though, the real margin may be far thinner than it looks, or some products may be priced below cost without anyone noticing.

This guide walks through the formula with a worked example in Saudi riyals, the difference between periodic and perpetual inventory, where COGS sits in the income statement, whether it is a debit or a credit, how costing methods change it, and how a system can calculate it with every sales invoice.

What is Cost of Goods Sold?

Cost of goods sold (COGS) is the direct cost of the goods that left your inventory and went to customers during a given period. It does not include every business expense, only the costs directly tied to buying or making the goods and getting them ready for sale.

For a trading business, cost usually includes the supplier’s price, freight into the warehouse, non-recoverable customs duties and any preparation needed before the item can be sold. VAT paid on purchases is not part of cost when the business is VAT-registered and recovers that input tax in its return.

Sales staff salaries, showroom rent and marketing are not part of COGS. Those are operating expenses, and they appear in the income statement below gross profit.

The COGS Formula with a Worked Example

The basic formula is: COGS = opening inventory + net purchases − closing inventory. Net purchases are purchases plus freight-in, minus purchase returns and discounts received.

Take a household goods store in Riyadh. All figures are before VAT, because recoverable VAT is not part of cost:

ItemAmount (SAR)
——
Opening inventory (1 January)120,000
Purchases during the year340,000
Freight into the warehouse8,000
Purchase returns(5,000)
Net purchases343,000
Goods available for sale463,000
Closing inventory (31 December) per stock count(95,000)
Cost of goods sold368,000

If the store’s net sales for the year were SAR 560,000 before VAT, gross profit is 560,000 − 368,000 = SAR 192,000, a gross margin of about 34.3%. Note that the 15% output VAT collected from customers is not revenue. It is a liability payable to the Zakat, Tax and Customs Authority.

Any error in closing inventory flows straight into profit. If the count wrongly showed SAR 105,000 instead of 95,000, COGS would fall by SAR 10,000 and profit would rise by the same amount. That profit is not real, and the error reverses in the following year.

Also read: Debit and credit explained: how to find both sides of any double entry.

Periodic vs Perpetual Inventory

The key difference is timing. A periodic system calculates COGS once at the end of the period after a physical count, while a perpetual system records the cost of each item at the moment it is sold. Both are acceptable, but they give very different quality of information.

Point of ComparisonPeriodic InventoryPerpetual Inventory
———
When is COGS calculated?At month or year end after a physical countWith every sale
Inventory balance in the booksNot updated during the periodUpdated in real time by quantity and value
Profit per invoiceNot directly availableAvailable per invoice and per item
Detecting shrinkage and lossOnly at the count, mixed into COGSBy comparing system stock to the physical count
Best suited toVery small businesses with few itemsRetail, wholesale and online stores

Under a periodic system, any shortage, theft or damage simply disappears into cost of goods sold, and you never learn the cause. Under a perpetual system, the books know what should be on the shelf. When you count, the difference shows up as a separate adjustment you can investigate. Daysum has covered the valuation side of this in inventory valuation with FIFO and average cost in Odoo ERP.

COGS in the Income Statement and Gross Profit

COGS appears in the income statement directly below net sales, and the difference between the two is gross profit. Operating expenses are then deducted to reach operating profit.

Income Statement LineAmount (SAR)
——
Net sales560,000
Cost of goods sold(368,000)
Gross profit192,000
Selling and marketing expenses(64,000)
General and administrative expenses(78,000)
Operating profit50,000

Gross margin (192,000 ÷ 560,000) is the ratio to compare month by month. If it falls while selling prices stay the same, the cause is usually higher purchase costs, unplanned discounts or stock loss. To see how this figure links to the other reports, read the three financial statements in plain language.

Is COGS a Debit or a Credit?

Cost of goods sold is an expense account with a normal debit balance. It increases on the debit side and is closed to profit and loss at year end. The matching credit goes to inventory, because the goods have left the company’s assets.

Example: the store sells a blender for SAR 1,000 before VAT, and its cost in inventory is SAR 620. Under a perpetual system, this is the cost of goods sold journal entry together with the sales entry:

AccountDebitCredit
———
Cash or accounts receivable1,150
Sales1,000
Output VAT payable (15%)150
Cost of goods sold620
Inventory620

The first entry records revenue and VAT, and the second records the goods leaving stock at cost. Gross profit on this invoice alone is SAR 380.

Inventory Costing Methods and Their Effect on COGS

When you buy the same item at different prices, the costing method decides which cost is charged to sales. The two most common methods are first in, first out (FIFO) and weighted average. IAS 2, the international inventory standard, does not allow last in, first out.

Example: the store buys 100 units at SAR 50, then 100 units at SAR 56, and sells 120 units:

MethodCalculationCost of 120 Units
———
FIFO100 × 50 + 20 × 56SAR 6,120
Weighted average(5,000 + 5,600) ÷ 200 = 53 × 120SAR 6,360

The difference is SAR 240 on one item. Across a warehouse of thousands of items it becomes material to reported profit. What matters is choosing one method that suits your goods and applying it consistently, because switching between periods makes comparisons unreliable. Gold and jewellery traders face a different cost structure based on weight and karat, which Daysum explains in COGS management for gold and jewellery.

How Daysum Calculates Cost with Every Sales Invoice

In Daysum’s cloud system, built on Odoo, perpetual inventory valuation can be set up so that the cost of goods sold entry posts automatically when the sales invoice is posted. Cost follows the method chosen for each product: standard cost, average cost or FIFO.

The result is that you do not wait for the year-end count to learn your profit. You can see gross profit per invoice, per product and per branch, and trace the COGS figure in the income statement back to the entries and invoices behind it. These accounts sit on the chart of accounts explained in Odoo’s interface, charts of accounts and ledgers.

Because the invoice itself is issued in line with ZATCA e-invoicing requirements, revenue, VAT and cost are linked in one place instead of being keyed in three times. If you would like to see how this works with your own products, talk to the Daysum team for a walkthrough on your data.

Conclusion: Accurate Cost Means Real Profit

Cost of goods sold is not a number the accountant fills in at year end. It is the number that tells you whether you are selling at a profit. Use the correct formula, leave out recoverable VAT and operating expenses, and pick one costing method and stick to it.

Moving from periodic to perpetual inventory makes your profit visible day by day and lets you catch shortages before they pile up. If you want a second look at how your business calculates cost, or to move to a system that does it automatically, contact the Daysum team and we will review your current setup with you.

FAQs About Cost of Goods Sold

COGS = opening inventory + net purchases − closing inventory. Net purchases include freight-in, less purchase returns and discounts received. Use figures before VAT if the business recovers its input tax.

Cost of goods sold is an expense account with a normal debit balance, so it is debited when goods are sold. The matching credit is to inventory, because the goods have left the company's assets. At year end, the balance is closed to profit and loss.

A periodic system calculates COGS once at the end of the period after a physical stock count. A perpetual system records the cost of each item at the moment of sale and keeps the inventory balance current. Perpetual inventory shows profit per invoice and reveals shortages when system stock is compared with the count.

If the business is VAT-registered and recovers input tax, VAT is not part of cost of goods sold. Input VAT is recorded in a separate account and offset against output VAT in the return. A business that is not registered bears the VAT as part of its purchase cost.

For a trading business, sales staff salaries and shop rent are not part of COGS; they are operating expenses. Cost is limited to what is directly tied to buying goods and preparing them for sale, such as the purchase price, freight-in and non-recoverable duties. In manufacturing, direct labour does form part of production cost.

Share This Article

top
Business Challenges

Digital Transformation

Security

Automation

Gaining Efficiency