diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 621b9df1245e..88d4e4689772 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -314,6 +314,30 @@ def test_stock_reco_for_serial_and_batch_item(self): self.assertEqual(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Inactive") self.assertEqual(frappe.db.exists("Batch", batch_no), None) + def test_stock_reco_balance_qty_for_serial_and_batch_item(self): + from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry + + item = create_item("_TestBatchSerialItemReco_1") + item.has_batch_no = 1 + item.create_new_batch = 1 + item.has_serial_no = 1 + item.batch_number_series = "TBS-BATCH1-.##" + item.serial_no_series = "TBS1-.####" + item.save() + + warehouse = "_Test Warehouse for Stock Reco2" + warehouse = create_warehouse(warehouse) + + make_stock_entry(item_code=item.name, target=warehouse, qty=10, basic_rate=100) + + sr = create_stock_reconciliation(item_code=item.name, warehouse=warehouse, qty=10, rate=200) + + qty_after_transaction = frappe.db.get_value( + "Stock Ledger Entry", {"voucher_no": sr.name, "is_cancelled": 0}, "qty_after_transaction" + ) + + self.assertEqual(qty_after_transaction, 20) + def test_stock_reco_for_serial_and_batch_item_with_future_dependent_entry(self): """ Behaviour: 1) Create Stock Reconciliation, which will be the origin document diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 7e6d3edae102..4f8f06023deb 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -579,7 +579,7 @@ def process_sle(self, sle): if get_serial_nos(sle.serial_no): self.get_serialized_values(sle) self.wh_data.qty_after_transaction += flt(sle.actual_qty) - if sle.voucher_type == "Stock Reconciliation": + if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no: self.wh_data.qty_after_transaction = sle.qty_after_transaction self.wh_data.stock_value = flt(self.wh_data.qty_after_transaction) * flt(