Back

How Average Cost Is Calculated in the System

The system calculates the cost of each product automatically using the moving weighted average method: whenever a new quantity comes in at a different price, the unit’s average cost is recalculated based on the existing quantity and its price and the new quantity and its price. This average is what appears on the product page as Average Cost Price, and it is what is used to calculate the cost of sales, the invoice profit, and the inventory value. This guide explains the formula, which movements change the average and which don’t, and how the system handles discounts, currencies, and backdated movements.

🛈

Note: the average is one per product across all warehouses, not a separate average for each warehouse. Buying a quantity in one warehouse changes the product’s cost in all warehouses.

The Average Cost Formula

When a quantity that affects the average comes in (such as a purchase invoice), the system calculates:

New average cost = (current average × current quantity + incoming quantity × incoming unit price) ÷ (current quantity + incoming quantity)
  • Current quantity: the product’s total balance across all warehouses before the movement’s date.
  • Incoming unit price: the purchase price after deducting discounts, converted to your account’s default currency at the exchange rate on the movement’s date.
  • Movements are calculated in the order of their dates, not the order in which they were entered.
  • Movements in Draft or Under Delivery status don’t enter the calculation until they are executed.

Example: you have 6 units at an average cost of 100, and you bought 14 units at a price of 125.

New average = (100 × 6 + 125 × 14) ÷ (6 + 14) = 2,350 ÷ 20 = 117.5

Movements That Change the Average Cost

Movement Effect on the Average
Purchase invoice (or the addition requisition linked to it) Changes it by the purchase price after the discount.
Manual stock addition (Add Stock Operation) or a stock addition requisition Changes it by the unit price written in the movement. If you leave the price as is, the current average cost is suggested, so the average doesn’t change.
Finished product and waste from a manufacturing order Change it by the manufacturing cost.
Refund invoice and credit note Depending on the “Returns Cost Calculation Method” setting (see below).

Movements That Don’t Change the Average Cost

These movements take the current average cost as their price, so the average doesn’t change:

  • Sales invoices and manual issues: the cost of the unit sold is recorded at the average cost on the date of sale.
  • Purchase returns and purchase debit notes: goes out at the average cost on its date, not at the original purchase price.
  • Stock transfers between warehouses.
  • The stocktaking sheet (surplus or shortage).
  • Issuing raw materials for a manufacturing order.

The Returns Cost Calculation Method

From Product Settings → System Defaults, the Returns Cost Calculation Method setting determines at which cost returns go back into stock:

Option What Happens
By Selling Price The returned quantity goes back at the cost recorded for it in the original sales invoice, and the return enters the average calculation.
By Latest Average Cost The returned quantity goes back at the current average cost at the time the return is created, so the average doesn’t change.

This setting applies to all branches.

How the System Works

Discounts and Taxes

  • The line discount, and the line’s share of the invoice’s total discount, are subtracted from the unit price.
  • Exclusive tax doesn’t enter the cost. Inclusive tax is extracted from the price first, so the cost is always without tax.

Currencies

  • If the purchase invoice is in a foreign currency, the price is converted to the default currency at the exchange rate on the movement’s receipt date.
  • If you edit the local currency rates for a past date, the average cost is recalculated for the products that have movements from that date.

Example: buying 10 units at a price of 20 dollars with a discount of 2 dollars per unit, and an exchange rate of 50: the unit price entering the formula = (20 − 2) × 50 = 900 in the default currency.

Purchase Expenses (Shipping and Customs)

Purchase expenses don’t enter the cost automatically. To charge them to the products’ cost, use expense allocation from the addition requisition linked to the purchase invoice; the allocated expense value is then added to the cost of each line.

Backdated Movements, Editing, and Deleting

  • When a movement is added, edited, or deleted with a past date, the system recalculates the average for all movements from that date until today.
  • The cost of later sales invoices changes, their cost of sales entries are reposted, and the activity log shows that the average cost price changed.
  • If the date is older than 3 days, the recalculation is done in the background, so the new average may appear after a few minutes.

Example: you have 10 units at an average of 100, and you sold 4 units on January 5 (their cost is 400). Then you added a purchase invoice dated January 3: 10 units at a price of 130.

The system recalculates from January 3: average = (100 × 10 + 130 × 10) ÷ 20 = 115, so the cost of the January 5 sales invoice becomes 4 × 115 = 460 instead of 400, and its entry is adjusted.

Zero and Negative Stock

  • If the balance is zero, the average becomes the price of the incoming quantity itself.
  • If the balance is negative (when negative stock is allowed) and a quantity comes in at a price, the average becomes the price of that quantity directly, without weighting.

⚠

Warning: selling while stock is negative records an inaccurate cost, because the quantity is sold before its purchase price is known. Record purchase invoices with their correct date before sales invoices to get accurate cost and profits.

Where the Average Cost Appears

Location What It Shows
The product page in Products The Average Cost Price card. It appears for those who have the permission to add or edit products or purchase invoices.
The Invoice Profit tab in a sales invoice For each line: the selling price, the average price, and the profit. It appears when the “Profit Tab in Invoice” setting is enabled and you have the permission to view profit.
Cost of Sales entry From the cost of sales account to the inventory account, at the value of the average cost × the quantity sold.
Item Sales Profits report The total cost and profit for each item.
Estimated Inventory Value report The inventory value at the average purchase price or at the purchase price, depending on your choice.
Stock movement The cost of each movement and the balance after it.

Related Settings

  • Selling Below Average Cost (in the sales settings): determines whether an item may be sold at a price lower than its average cost.
  • Returns Cost Calculation Method (in the inventory settings): as in the previous section.
  • The system has no option for another costing method such as First In, First Out (FIFO); the weighted average is the approved method.

Frequently Asked Questions

  • Why did the profit of an old sales invoice change? Because a purchase or addition movement was entered, edited, or deleted with a date earlier than the invoice, so the average and the invoice’s cost were recalculated.
  • Why is the average cost different from the last purchase price? Because the average combines all the existing quantities at their prices, not just the last invoice.
  • Does each warehouse have a different average cost? No, the average is one per product across all warehouses.
  • Why didn’t the average change after a stock transfer or stocktaking? Because these movements are recorded at the current average cost and don’t affect it.
  • I edited an old purchase invoice and the average didn’t change immediately. Why? Because the recalculation for dates older than 3 days is done in the background; wait a little, then refresh the page.
  • Does tax enter the cost? No, the cost is always without tax.
  • How do I add the shipping cost to the product’s cost? From expense allocation on the addition requisition linked to the purchase invoice.