fix: Validate account in Sales/Purchase Taxes and Charges Template (#39013)

diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index cb0cac6..729bb67 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -2431,6 +2431,7 @@
 
 def validate_account_head(idx, account, company, context=""):
 	account_company = frappe.get_cached_value("Account", account, "company")
+	is_group = frappe.get_cached_value("Account", account, "is_group")
 
 	if account_company != company:
 		frappe.throw(
@@ -2440,6 +2441,12 @@
 			title=_("Invalid Account"),
 		)
 
+	if is_group:
+		frappe.throw(
+			_("Row {0}: Account {1} is a Group Account").format(idx, frappe.bold(account)),
+			title=_("Invalid Account"),
+		)
+
 
 def validate_cost_center(tax, doc):
 	if not tax.cost_center: