---
title: "Why does batch quantity not match the stock ledger, and how do I fix it"
space: "ERPNext"
url: "https://docs.frappe.io/erpnext/why-does-batch-quantity-not-match-the-stock-ledger-and-how-do-i-fix-it"
updated: "2026-11-25"
---

## Why this happens

ERPNext keeps batch stock in two places:

- **The stock ledger.** Each stock transaction makes stock ledger entries, with the batch in its Serial and Batch Bundle. The Stock Ledger, Stock Balance and Batch-Wise Balance History reports add these entries up. This is the correct quantity.
- **The Batch Qty field on the Batch.** This is a stored total. ERPNext adds to it and takes from it each time a transaction for the batch is submitted or cancelled. It is a shortcut, so screens do not have to add up the ledger every time.

When an update to the stored total is missed or is wrong, the Batch Qty and the ledger differ. Common causes:

- **Backdated entries and reposts.** A repost recalculates the stock ledger, but it does not always change the stored Batch Qty.
- **Cancelled receipts.** When a receipt that created a batch is cancelled, the batch stays. Its Batch Qty should go back to 0. If later entries used the batch, the totals can stay out of step.
- **Rounding.** Quantities in UOMs with conversion factors (for example, boxes of 12 sold as single units) leave small decimal residues, such as 69.997 instead of 70.
- **Data changed outside a transaction**, for example by a data import or a database patch.

The stock ledger is the source of truth. Fix the Batch Qty to match it, not the other way round.

## How to find the batches that differ

1. Go to **Stock → Reports → Stock Qty vs Batch Qty**.
2. To narrow it down, select an **Item** or a **Batch**.
3. The report lists only the batches that differ. **Batch Qty** is the stored total, **Stock Qty** is the total from the stock ledger, and **Difference** is Stock Qty minus Batch Qty.



![](/files/imageeffd0c.webp)

To see where the quantity of one batch changed:

- **Batch-Wise Balance History** shows the opening, in, out and balance quantity of each batch in each warehouse for a date range.
- **Stock Ledger**, filtered by **Batch No**, shows each transaction of the batch.
- **Negative Batch Report** shows batches that went below zero at some point, with the transaction that caused it.
- **Stock Ledger Variance** shows stock ledger entries whose quantity or value does not add up, for example after a failed repost.

## How to fix it

### The Batch Qty is wrong, the ledger is right

This is the usual case. Use one of these:

- **For many batches:** in **Stock Qty vs Batch Qty**, tick the rows to fix and click **Update Batch Qty**. ERPNext sets each Batch Qty to the Stock Qty.
- **For one batch:** open the **Batch** and click **Recalculate Batch Qty**. You see "Batch Qty updated to …".

Run the report again. The batches you fixed are no longer listed.

### The ledger itself is wrong

If the Stock Ledger shows a quantity that is not physically there:

1. Check the **Negative Batch Report** and **Stock Ledger Variance** for the item.
2. If a **Repost Item Valuation** for the item is **Queued** or **Failed**, fix the error and click **Restart**. Wait until it is **Completed**.
3. If the quantity is still wrong, make a **Stock Reconciliation** for the batch with the counted quantity. Select the **Item**, **Warehouse** and **Batch No**, and enter the real **Qty**.
4. Then fix the Batch Qty as above.

### Small decimal residues

A difference such as 0.003 comes from rounding. Fix the Batch Qty with **Update Batch Qty** or **Recalculate Batch Qty**. If the ledger itself has a residue (for example, 0.003 left in stock that you do not have), make a **Stock Reconciliation** for the batch with quantity 0.

To avoid new residues, check the **Conversion Factor** of the item's UOMs and the precision of quantity fields in **System Settings**.

### Batches left active after a cancelled receipt

A batch made by a receipt is not deleted when you cancel the receipt. If you do not need it:

1. Open the **Batch**. Check that **Batch Qty** is 0 (click **Recalculate Batch Qty** first).
2. Tick **Disabled** and save. Disabled batches do not show in batch selection, or in Stock Qty vs Batch Qty.

You can delete the batch only if no transaction, even a cancelled one, still links to it.

## How to prevent it

- Avoid backdated entries for batch items.
- Do not change stock data with data import or database patches.
- After a large repost, run **Stock Qty vs Batch Qty** once.

## Related

- [Batch](https://docs.frappe.io/erpnext/batch)
- [Negative Batch Report](https://docs.frappe.io/erpnext/stock/reports/negative-batch-report)
- [Stock Ledger Variance Report](https://docs.frappe.io/erpnext/stock-reposting)
- [Stock Reconciliation](https://docs.frappe.io/erpnext/stock-reconciliation)