diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index fb526971ed..10654ddc21 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -256,8 +256,6 @@ def get_incoming_rate(args, raise_error_if_no_rate=True): if isinstance(args, str): args = json.loads(args) - voucher_no = args.get("voucher_no") or args.get("name") - in_rate = None if (args.get("serial_no") or "").strip(): in_rate = get_avg_purchase_rate(args.get("serial_no")) @@ -280,12 +278,13 @@ def get_incoming_rate(args, raise_error_if_no_rate=True): in_rate = ( _get_fifo_lifo_rate(previous_stock_queue, args.get("qty") or 0, valuation_method) if previous_stock_queue - else 0 + else None ) elif valuation_method == "Moving Average": - in_rate = previous_sle.get("valuation_rate") or 0 + in_rate = previous_sle.get("valuation_rate") if in_rate is None: + voucher_no = args.get("voucher_no") or args.get("name") in_rate = get_valuation_rate( args.get("item_code"), args.get("warehouse"),