From e9f4a34d8dcd775c747bb1e5df3d5bfe154e25f3 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 23 Oct 2025 23:49:50 +0530 Subject: [PATCH] fix: get valuation rate based of previous SLEs for material receipt (cherry picked from commit fa9ef6708f4c5450a39f770298a5901dfef9271a) --- erpnext/stock/doctype/stock_entry/stock_entry.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 4b28f6094c1..332f05fafd2 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -539,7 +539,7 @@ frappe.ui.form.on("Stock Entry", { const item = locals[cdt][cdn]; item.transfer_qty = flt(item.qty) * flt(item.conversion_factor); - const args = { + let args = { item_code: item.item_code, posting_date: frm.doc.posting_date, posting_time: frm.doc.posting_time, @@ -553,6 +553,10 @@ frappe.ui.form.on("Stock Entry", { allow_zero_valuation: 1, }; + if (item.batch_no && frm.doc.purpose == "Material Receipt") { + args.qty = Math.abs(args.qty) * -1; + } + if (item.item_code || item.serial_no) { frappe.call({ method: "erpnext.stock.utils.get_incoming_rate",