[Fix] Valuation rate for serialized items (#15017)
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 22db7f1..53267d6 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -223,9 +223,10 @@
tuple(serial_no))[0][0])
new_stock_qty = self.qty_after_transaction + actual_qty
+
if new_stock_qty > 0:
new_stock_value = (self.qty_after_transaction * self.valuation_rate) + stock_value_change
- if new_stock_value > 0:
+ if new_stock_value >= 0:
# calculate new valuation rate only if stock value is positive
# else it remains the same as that of previous entry
self.valuation_rate = new_stock_value / new_stock_qty