refactor: added new filters in the Batch-wise balance history report (#23676)

* refactor: added new filters in the Batch-wise balance history report

* fix: added semicolon

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js
index 2499c80..74b5a5a 100644
--- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js
+++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js
@@ -4,6 +4,14 @@
 frappe.query_reports["Batch-Wise Balance History"] = {
 	"filters": [
 		{
+			"fieldname":"company",
+			"label": __("Company"),
+			"fieldtype": "Link",
+			"options": "Company",
+			"default": frappe.defaults.get_user_default("Company"),
+			"reqd": 1
+		},
+		{
 			"fieldname":"from_date",
 			"label": __("From Date"),
 			"fieldtype": "Date",
@@ -20,12 +28,46 @@
 			"reqd": 1
 		},
 		{
-			"fieldname": "item",
-			"label": __("Item"),
+			"fieldname":"item_code",
+			"label": __("Item Code"),
 			"fieldtype": "Link",
 			"options": "Item",
-			"width": "80"
-		}
+			"get_query": function() {
+				return {
+					filters: {
+						"has_batch_no": 1
+					}
+				};
+			}
+		},
+		{
+			"fieldname":"warehouse",
+			"label": __("Warehouse"),
+			"fieldtype": "Link",
+			"options": "Warehouse",
+			"get_query": function() {
+				let company = frappe.query_report.get_filter_value('company');
+				return {
+					filters: {
+						"company": company
+					}
+				};
+			}
+		},
+		{
+			"fieldname":"batch_no",
+			"label": __("Batch No"),
+			"fieldtype": "Link",
+			"options": "Batch",
+			"get_query": function() {
+				let item_code = frappe.query_report.get_filter_value('item_code');
+				return {
+					filters: {
+						"item": item_code
+					}
+				};
+			}
+		},
 	],
 	"formatter": function (value, row, column, data, default_formatter) {
 		if (column.fieldname == "Batch" && data && !!data["Batch"]) {
@@ -43,4 +85,4 @@
 
 		frappe.set_route("query-report", "Stock Ledger");
 	}
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
index 8f3e246..087c12e 100644
--- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
+++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
@@ -57,6 +57,10 @@
 	else:
 		frappe.throw(_("'To Date' is required"))
 
+	for field in ["item_code", "warehouse", "batch_no", "company"]:
+		if filters.get(field):
+			conditions += " and {0} = {1}".format(field, frappe.db.escape(filters.get(field)))
+
 	return conditions