feat: filter based on accounting dimension in profitability analysis
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
index 889ede5..4412212 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
@@ -16,11 +16,24 @@
 				"fieldname": "based_on",
 				"label": __("Based On"),
 				"fieldtype": "Select",
-				"options": ["Cost Center", "Project"],
+				"options": ["Cost Center", "Project", "Accounting Dimension"],
 				"default": "Cost Center",
 				"reqd": 1
 			},
 			{
+				"fieldname": "accounting_dimension",
+				"label": __("Accounting Dimension"),
+				"fieldtype": "Link",
+				"options": "Accounting Dimension",
+				"get_query": () =>{
+					return {
+						filters: {
+							"disabled": 0
+						}
+					}
+				}
+			},
+			{
 				"fieldname": "fiscal_year",
 				"label": __("Fiscal Year"),
 				"fieldtype": "Link",
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
index 183e279..c05aa94 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
@@ -16,8 +16,8 @@
 
 
 def execute(filters=None):
-	if not filters.get("based_on"):
-		filters["based_on"] = "Cost Center"
+	if filters.get("based_on") == "Accounting Dimension" and not filters.get("accounting_dimension"):
+		frappe.throw(_("Select Accounting Dimension."))
 
 	based_on = filters.based_on.replace(" ", "_").lower()
 	validate_filters(filters)
@@ -37,6 +37,8 @@
 		)
 	elif based_on == "project":
 		return frappe.get_all("Project", fields=["name"], filters={"company": company}, order_by="name")
+	elif based_on == "accounting_dimension":
+		return frappe.get_all("Accounting Dimension", fields=["name"], order_by="name")
 	else:
 		filters = {}
 		doctype = frappe.unscrub(based_on)
@@ -60,7 +62,9 @@
 		filters.get("company"),
 		filters.get("from_date"),
 		filters.get("to_date"),
-		based_on,
+		based_on
+		if based_on != "accounting_dimension"
+		else filters.accounting_dimension.replace(" ", "_").lower(),
 		gl_entries_by_account,
 		ignore_closing_entries=not flt(filters.get("with_period_closing_entry")),
 	)