def METHOD_NAME(date_range, company, field, limit=None):
	if field == "total_sales_amount":
		select_field = "sum(`base_net_total`)"
	elif field == "total_commission":
		select_field = "sum(`total_commission`)"
	filters = {"sales_partner": ["!=", ""], "docstatus": 1, "company": company}
	if date_range:
		date_range = frappe.parse_json(date_range)
		filters["transaction_date"] = ["between", [date_range[0], date_range[1]]]
	return frappe.get_list(
		"Sales Order",
		fields=[
			"`sales_partner` as name",
			"{} as value".format(select_field),
		],
		filters=filters,
		group_by="sales_partner",
		order_by="value DESC",
		limit=limit,
	)