- What is a moving average price?
- How do I enable moving average price?
- How do I fix my cost price?
- Where can I see the cost price?

## What is a moving average price?

Moving average price is a method for calculating cost price after each purchase (goods acquisition) by using previously calculated values and current quantity. Using this method helps valuating the inventory more correctly.

Here is the formula for calculating the cost price using the following variables:

**P**- Cost price to calculate**S**- Current inventory value**N**- Value of newly purchased goods**Q**- Total quantity on hand (including new quantity purchased)

P = (S + N) / Q

To put it more simple, new cost price is calculated by taking product's inventory value (total quantity multiplied by previously calculated cost price) and newly purchased value, and then dividing the result by total quantity on hand.

Cost price = (Product on hand value + Purchased value) / Total quantity

As you can see from the definition above, calculating correct cost price using this method heavily depends on the current and correct stock quantities. In other words, keeping the stock quantities up to date at the moment of the purchase is essential for cost price to be calculated correctly.

#### Negative stock quantity

In case your stock quantity goes negative, calculated cost price will be incorrect. If negative stock quantity is detected during moving average price calculation, previous cost price will be considered to be a zero, and only the last (current) purchase price will be used.

To better understand how the price is calculated, let's track one product transactions and see how the price is calculated with every new purchase. For the simplicity, we are looking only into purchases, and we assume some sales happens in between, reflecting the "*Quantity*" column .

Description | Qty. | Change qty. |
Cost per unit |
Calculated cost price | Total inventory value |
---|---|---|---|---|---|

Opening balance |
10 | - | $5 | $5 |
$50 |

Purchase #1 |
10 | 10 | $6 | ($50 + $60) / 20 = $5.5 |
20 x $5.5 = $110 |

Sales #1 |
20 | -5 | $5.5 | 15 x $5.5 = $82.5 | |

Purchase #2 |
15 | 5 | $7 | ($82.5 + $35) / 20 = $5.875 |
20 * $5.875 = $117.5 |

Average moving price after second purchase will be **$5.875**.

## How do I enable moving average price?

Moving average price is enabled by default for new installations. If you do not have moving average price enabled, you can do that anytime by visiting Settings > Product settings > Moving average price, and turning on "Enable moving average price" option.

#### Cost price on product screen

If moving average price is enabled, the field for product cost price in product screen will be disabled and will always show a currently calculated cost price.

## How do I fix my cost price?

It can happen that the cost price goes out of the sync with the system. The most simple scenario for this would be selling a product before creating a purchase document and putting new quantities on stock. Selling a product before creating a purchase will reduce the quantity more then the actual physical quantity is, so the system will use the wrong quantity in the formula, making moving average price incorrect after calculation.

To recalculate cost prices for your products, follow the steps below.

- Go to Management > Products
- Click Moving average price, a new screen will open
- Select product group or a products you wish to recalculate cost price for
- Select the period from when the calculation should start
- Click Start button

#### Time required to calculate cost prices

Time required to recalculate cost prices depends on the number of documents and on a period selected. During the calculation process you will see an overall and a product-wise progress bar, so you get some idea of the time required to complete the request.

## Where can I see the cost price?

Current cost price will always be presented in the product screen(s) and the stock view. You can visit Stock history and see how the cost price was changed over time with each transaction. For more information about stock history, please see Quantity on hand.