From 1bd7ea99f42a277268b23beda5a6faf9fee02a36 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Mon, 15 Apr 2019 17:03:09 +0530 Subject: [PATCH] fix(batch): Only consider valid stock ledger entries --- erpnext/stock/doctype/batch/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 3de720580a6..9c532096c6c 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -118,7 +118,7 @@ class Batch(Document): frappe.throw(_("The selected item cannot have Batch")) def calculate_batch_qty(self): - self.batch_qty = frappe.db.get_value("Stock Ledger Entry", {"batch_no": self.batch_id}, "sum(actual_qty)") + self.batch_qty = frappe.db.get_value("Stock Ledger Entry", {"docstatus": 1, "batch_no": self.batch_id}, "sum(actual_qty)") def before_save(self): has_expiry_date, shelf_life_in_days = frappe.db.get_value('Item', self.item, ['has_expiry_date', 'shelf_life_in_days'])