Fix a negative or abnormally high valuation rate ​

A negative or very high valuation rate almost always comes from one wrong stock transaction, not from a fault in the valuation method. Find that transaction in the Stock Ledger, correct it, then repost item valuation so that ERPNext recalculates every later entry.

You may see one of these symptoms:

  • The Stock Balance report shows a negative balance value while the quantity is positive.
  • The valuation rate of an item jumps to 10 or 1,000 times its normal cost.
  • The cost of goods sold on a Delivery Note or a Sales Invoice is far too high, or negative.
  • A BOM or a Stock Entry uses an unexpected rate for a raw material.

Common causes ​

The valuation rate is the balance value divided by the balance quantity. When a value is booked at the wrong rate and only a small quantity is left, the rate moves far off.

CauseWhat goes wrongWhat you see in the Stock Ledger
Negative stockWith Allow negative stock on in Stock Settings, stock goes out before it comes in. The outgoing entries use a guessed or old rate. The receipt comes in at another rate, and the gap stays in the balance value.Balance Qty goes below zero. After the receipt, Avg Rate (Balance Stock) jumps, or Balance Value turns negative.
Zero-rate receiptA Purchase Receipt, Material Receipt, or Stock Reconciliation has a rate of 0, often with Allow Zero Valuation Rate selected. The average falls. Later issues at the old rate take out more value than is left.Incoming Rate is 0 on a receipt. The rate then falls, and later Balance Value turns negative.
Backdated entryA transaction posted before existing entries changes the rate of every later entry. If the repost is queued or failed, later entries keep their old values.Entries after the backdated one do not add up. A Repost Item Valuation for the item shows Queued or Failed.
Serial number at a wrong rateEach serial number carries the rate at which it came in. A serial number that came in at a wrong rate, or at 0, moves that rate in every transfer and delivery.Incoming Rate on a Material Transfer or Delivery Note is far from the usual cost.
Wrong UOM conversionYou buy in one unit, such as Box, and stock in another, such as Nos. A wrong Conversion Factor spreads the amount over too few or too many units.In Qty looks wrong for the document, and Incoming Rate is a multiple of the expected rate, for example 12 times.

Find the entry where the rate went wrong ​

  1. Open the Stock Ledger report.
  2. Set Company, Items, and Warehouses. Set From Date to a date when the rate was still normal.
  3. Read these columns from top to bottom:
    • Incoming Rate: look for a 0, or a rate far above the normal cost.
    • Balance Qty: look for a row where it goes below zero.
    • Avg Rate (Balance Stock): find the first row where it jumps or turns negative.
    • Balance Value: it should be close to Balance Qty × Avg Rate (Balance Stock). A negative value with a positive quantity marks the problem.
  4. Open the document in Voucher # on the first wrong row, and the receipt immediately before it. One of them is the source entry.

Check one warehouse at a time. Each warehouse has its own valuation rate, so a problem in one warehouse can look like a jump in a transfer to another.

To find all affected items at once, use the Stock Ledger Invariant Check report, the Incorrect Stock Value Report, and the Stock Valuation Comparison report. Also check the Repost Item Valuation list for documents with the status Failed.

Correct the source entry ​

Correct the source entry first. A repost alone runs the same wrong numbers again.

CauseFix
Negative stockPost the missing receipt with a posting date and time before the first issue, so that stock never goes below zero.
Zero-rate receiptCancel the receipt and amend it with the correct rate. For a Stock Reconciliation, amend it with the correct Valuation Rate.
Wrong rate on a Purchase ReceiptCancel and amend it. If only freight or duty is missing, use a Landed Cost Voucher instead.
Wrong UOM conversionCorrect the Conversion Factor in the UOM table of the item. Then cancel and amend the affected documents.
Serial number at a wrong rateCancel and amend the receipt of that serial number. Later transfers and deliveries take the corrected rate after the repost.

Repost item valuation ​

When you cancel or amend a backdated entry, ERPNext usually creates a repost on its own. Create one yourself if it did not, or if the earlier repost failed.

  1. Create a new Repost Item Valuation.
  2. Set Based On:
    • Item and Warehouse: enter the Item Code, the Warehouse, and the Posting Date and Posting Time of the source entry, or slightly earlier.
    • Transaction: enter the Voucher Type and Voucher No of the source entry.
  3. Submit. The repost runs in the background. Its Status moves from Queued to In Progress to Completed.
  4. If the status is Failed, read the Error Log. It usually names a negative stock row that you still need to fix. Fix it, then select Restart.
  5. Run the Stock Ledger report again, and check that Avg Rate (Balance Stock) is normal.

The repost also updates the general ledger, so stock and account values match again. Stock Reposting Settings can limit reposts to certain hours. If nothing happens, check the time slot there. Learn more about reposting item valuation.

Why a BOM or Sales Invoice rate can differ from the Stock Ledger ​

A BOM and a Sales Invoice take their rates at another time, or from another place, than the Stock Ledger. A difference is not always an error.

DocumentWhere its rate comes fromWhy it differs
BOMRate Of Materials Based On: valuation rate, last purchase rate, or price list. With valuation rate, it takes the average across warehouses, or the source warehouse if set.The cost is fixed when you save the BOM. It changes only when you select Update Cost, or when Update BOM Cost Automatically is on in Manufacturing Settings. The Stock Ledger is per warehouse and current.
Sales InvoiceThe Rate is the selling price from the price list or a pricing rule, not the cost.The Delivery Note books the cost of goods sold, or the Sales Invoice when Update Stock is selected. It uses the valuation rate at its posting date and time.
Delivery Note, Stock EntryThe valuation rate at the posting date and time, in the source warehouse.A later backdated entry changes this rate after you submit. The repost updates it, but a printed copy keeps the old value.

If a BOM shows a wrong raw material cost, fix the raw material's valuation first. Then open the BOM and select Update Cost.

Prevent the problem ​

  • Keep negative stock off. In Stock Settings, leave Allow negative stock cleared, so that nobody can issue stock before it comes in.
  • Give every receipt a rate. Select Allow Zero Valuation Rate only for items that are truly free, such as free samples. Set a Valuation Rate in the Item for opening stock and free items.
  • Check UOM conversion factors in the Item before the first purchase in a new unit.
  • Limit backdated entries. In Stock Settings, set Role allowed to create/edit back-dated transactions, so that only a few users can post them.
  • Watch the repost queue. Check the Repost Item Valuation list each week for Failed documents, and fix each one before more entries pile up.

Get help ​

If the rate is still wrong after a completed repost, raise a ticket on support.frappe.io. Include:

  • The item code and the warehouse.
  • A Stock Ledger export for the period where the rate went wrong.
  • The name of the Repost Item Valuation and, if it failed, its Error Log.