# COGS calculator: cost of goods sold and margin | MyRecords

> Work out cost of goods sold from opening stock, purchases and closing stock, then gross profit, gross margin and markup on cost. Any currency, arithmetic shown.

Canonical: https://myrecords.cloud/resources/free-tools/cogs-calculator/
Last updated: 2026-12-03

Free tool · Finance and assets

**Cost of goods sold (COGS) calculator**

Opening stock plus purchases less closing stock, then gross profit and gross margin from your sales.

-   Works for any country
-   No sign-up
-   Runs in your browser
-   Facts verified 3 Dec 2026

An estimate to help you plan. Nothing you type is uploaded.

 Formula and worked example

In short

Cost of goods sold = opening stock + net purchases + freight-in − closing stock. With opening stock of EUR 85,000, net purchases of 408,000, freight-in of 18,000 and closing stock of 96,000, cost of goods sold is 85,000 + 408,000 + 18,000 − 96,000 = EUR 415,000. On net sales of 640,000, gross profit is 225,000 and gross margin is 35.16%.

Also called: Cost of goods sold calculator, Cost of sales calculator, COGS formula calculator, Gross profit calculator, Periodic inventory COGS calculator.

## How it is calculated

**Cost of goods sold** (COGS, also called cost of sales) is the cost of the goods a business sold in a period. It is not the cost of everything it bought.

-   **Net purchases** = purchases − purchase returns, allowances and discounts
-   **Goods available for sale** = opening stock + net purchases + freight-in, duty and handling
-   **Cost of goods sold** = goods available for sale − closing stock
-   **Gross profit** = net sales − cost of goods sold
-   **Gross margin** = gross profit ÷ net sales
-   **Markup on cost** = gross profit ÷ cost of goods sold

The idea is simple. What was there at the start, plus what came in, is everything that could have been sold. Whatever is not on the shelf at the end was sold, or lost.

## Worked example

Alder Foods (a made-up company) has these figures for a year, in EUR.

| Line | Figure |
| --- | --- |
| Net purchases: 420,000 − 12,000 | €408,000.00 |
| Goods available for sale: 85,000 + 408,000 + 18,000 | €511,000.00 |
| Cost of goods sold: 511,000 − 96,000 | €415,000.00 |
| Gross profit: 640,000 − 415,000 | €225,000.00 |
| Gross margin: 225,000 ÷ 640,000 | 35.16% |
| Markup on cost: 225,000 ÷ 415,000 | 54.22% |
| Cost of goods sold as a share of sales: 415,000 ÷ 640,000 | 64.84% |

Opening stock is 85,000, purchases are 420,000 with 12,000 of returns and discounts, freight-in is 18,000, closing stock is 96,000 and net sales are 640,000.

## Notes

-   **Tax you can claim back** (VAT or GST paid on purchases) is not a cost. Leave it out of purchases and out of sales.
-   **Loss and damage.** Goods stolen, spoiled or written down are no longer in closing stock, so this formula counts them inside cost of goods sold. To see them apart, compare the result with the cost recorded sale by sale.
-   **Stock that has lost value.** Under IAS 2, stock is carried at the lower of cost and net realisable value. A write-down lowers closing stock and raises the cost of the period.
-   **Service businesses** have no stock. Their direct cost is often called cost of services or cost of revenue.
-   This page gives general information to help you plan. It is not accounting or tax advice.

## In MyRecords

With perpetual inventory on, MyRecords records the cost of each sale as it happens. The stock ledger in Inventory shows the running quantity and value of every item, with the reason for each valuation rate. A landed cost voucher in Purchasing adds freight or duty to the cost of the items received. Accounting shows profit and loss by month, quarter, half-year or year with gross profit by item, and each amount opens the entries behind it.

## Official sources

Checked 3 Dec 2026

1.  [OpenStax, Principles of Accounting Volume 1, 6.2 Perpetual versus Periodic Inventory Systems](https://openstax.org/books/principles-financial-accounting/pages/6-2-compare-and-contrast-perpetual-versus-periodic-inventory-systems) cost of goods sold = beginning inventory + net purchases − ending inventory; net purchases = purchases − purchase discounts − purchase returns and allowances
2.  [IFRS Foundation, IAS 2 Inventories](https://www.ifrs.org/issued-standards/list-of-standards/ias-2-inventories/) the cost of inventories includes the costs of purchase and of bringing them to their present location and condition; inventories are measured at the lower of cost and net realisable value
3.  [OpenStax, Principles of Finance, 5.1 The Income Statement](https://openstax.org/books/principles-finance/pages/5-1-the-income-statement) sales − cost of goods sold = gross profit; gross margin = gross profit ÷ sales

Inside MyRecords

## The cost of each sale, *recorded as it happens.*

The stock ledger in MyRecords shows the running quantity and value of every item, with the reason for each valuation rate. Profit and loss shows gross profit by item, and each amount opens the entries behind it.

-   [Financial statements](https://myrecords.cloud/product/accounting/financial-statements/) P&L, Schedule III balance sheet, cash flow, trial balance.
-   [Inventory](https://myrecords.cloud/product/inventory/) Stock by warehouse, batch, expiry and serial, with reorder alerts.
-   [Purchasing](https://myrecords.cloud/product/purchasing/) Material requests to supplier payments, with AI bill reading.

[See Financial statements](https://myrecords.cloud/product/accounting/financial-statements/) [See the whole system](https://myrecords.cloud/product/)

*(Picture: The Inventory overview in MyRecords on the demo company)*

**Part of one system,** on one set of books:

-   [Accounting and GST](https://myrecords.cloud/product/accounting/)
-   [CRM](https://myrecords.cloud/product/crm/)
-   [HR and payroll](https://myrecords.cloud/product/hr/)
-   [Chat](https://myrecords.cloud/product/chat/)
-   [AI Assistant](https://myrecords.cloud/product/ai-assistant/)

## Who uses it, *and for what*

-   **Shop and trading business owners** Find the cost of what was sold in a month or a year from a stock count.
-   **Accountants** Check the cost of goods sold in the books against the stock count.
-   **New businesses** See gross profit and gross margin before the first full set of accounts.
-   **Students** See net purchases, goods available for sale and cost of goods sold worked in steps.

Questions

## Questions people ask

Something else on your mind?

Ask us anything about modules, a quote or moving across. A person from our team replies.

[Ask a question](https://myrecords.cloud/contact/)

**What is the cost of goods sold formula?**

Cost of goods sold = opening stock + net purchases + freight-in − closing stock. Net purchases are purchases less returns and discounts received. Freight, duty and handling paid to bring the goods in are added to the cost. 85,000 + 408,000 + 18,000 − 96,000 = 415,000.

**What goes into cost of goods sold and what stays out?**

It holds the cost of the goods that were sold: the purchase price, freight-in, import duty and handling, and for a manufacturer the materials, labour and factory costs of making them. Selling costs, office rent, salaries of office staff and interest stay out. They are operating or finance costs.

**How do I get gross profit from cost of goods sold?**

Gross profit = net sales − cost of goods sold. Gross margin = gross profit ÷ net sales. With net sales of 640,000 and cost of goods sold of 415,000, gross profit is 225,000 and gross margin is 35.16%.

**What is the difference between gross margin and markup?**

Both use the same gross profit. Gross margin divides it by sales; markup divides it by cost. In the worked example 225,000 is 35.16% of sales and 54.22% of cost.

**Does this work if I track stock item by item all the time?**

A business that records the cost of each sale as it happens already has cost of goods sold in its books. This formula is the periodic method: it works from a stock count at the start and the end. It is also a good check on the running figure, because a gap between the two points to loss, damage or a counting error.

**Does the valuation method change cost of goods sold?**

Yes. Closing stock valued by first in, first out or by weighted average cost can give different figures when purchase prices move, and cost of goods sold moves by the same amount the other way. Use the same method each period.

Last updated 3 Dec 2026 Facts last verified 3 Dec 2026 against the official sources below

This tool gives an estimate to help you plan. Rules change; confirm with your accountant before you file or pay.

Any business, anywhere

## One system for any business, anywhere.

Accounting, sales, stock, HR and payroll, CRM, support and an AI Assistant in one place. It works in any country and currency, and we customise it to the way your business runs.

[See every app](https://myrecords.cloud/product/) [Works worldwide](https://myrecords.cloud/solutions/worldwide/)

Free, no obligation

Request a quote

-   For the apps and modules you pick
-   At our best price, in writing
-   Your questions, answered by our team

[Request a quote](https://myrecords.cloud/contact/?topic=quote) [or contact us](https://myrecords.cloud/contact/)
