def METHOD_NAME(filters, tree_view=False):
	"""Calculates number of new and repeated customers and revenue."""
	company_condition = ""
	if filters.get("company"):
		company_condition = " and company=%(company)s"
	customers = []
	customers_in = {}
	for si in frappe.db.sql(
		"""select territory, posting_date, customer, base_grand_total from `tabSales Invoice`
		where docstatus=1 and posting_date <= %(to_date)s
		{company_condition} order by posting_date""".format(
			company_condition=company_condition
		),
		filters,
		as_dict=1,
	):
		key = si.territory if tree_view else si.posting_date.strftime("%Y-%m")
		new_or_repeat = "new" if si.customer not in customers else "repeat"
		customers_in.setdefault(key, {"new": [0, 0.0], "repeat": [0, 0.0]})
		# if filters.from_date <= si.posting_date.strftime('%Y-%m-%d'):
		if getdate(filters.from_date) <= getdate(si.posting_date):
			customers_in[key][new_or_repeat][0] += 1
			customers_in[key][new_or_repeat][1] += si.base_grand_total
		if new_or_repeat == "new":
			customers.append(si.customer)
	return customers_in