We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Auto Email Report Should be fetched from site_config
#### Expected Behaviour
Adding the `max_reports_per_user` field in site_config should be fetched for Auto Email Report limit instead of the static 3 used currently.

Reference: https://discuss.erpnext.com/t/auto-email-report-why-there-is-a-limit-of-3-user-field/23296/4

Frappé version: 10.0.16


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `frappe/email/doctype/auto_email_report/auto_email_report.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2015, Frappe Technologies and contributors
3 # For license information, please see license.txt
4 
5 from __future__ import unicode_literals
6 import frappe, json
7 from frappe import _
8 from frappe.model.document import Document
9 from datetime import timedelta
10 import frappe.utils
11 from frappe.utils import now, global_date_format, format_time
12 from frappe.utils.xlsxutils import make_xlsx
13 from frappe.utils.csvutils import to_csv
14 
15 max_reports_per_user = 3
16 
17 class AutoEmailReport(Document):
18 	def autoname(self):
19 		self.name = _(self.report)
20 
21 	def validate(self):
22 		self.validate_report_count()
23 		self.validate_emails()
24 		self.validate_report_format()
25 
26 	def validate_emails(self):
27 		'''Cleanup list of emails'''
28 		if ',' in self.email_to:
29 			self.email_to.replace(',', '\n')
30 
31 		valid = []
32 		for email in self.email_to.split():
33 			if email:
34 				frappe.utils.validate_email_add(email, True)
35 				valid.append(email)
36 
37 		self.email_to = '\n'.join(valid)
38 
39 	def validate_report_count(self):
40 		'''check that there are only 3 enabled reports per user'''
41 		count = frappe.db.sql('select count(*) from `tabAuto Email Report` where user=%s and enabled=1', self.user)[0][0]
42 		if count > max_reports_per_user + (-1 if self.flags.in_insert else 0):
43 			frappe.throw(_('Only {0} emailed reports are allowed per user').format(max_reports_per_user))
44 
45 	def validate_report_format(self):
46 		""" check if user has select correct report format """
47 		valid_report_formats = ["HTML", "XLSX", "CSV"]
48 		if self.format not in valid_report_formats:
49 			frappe.throw(_("%s is not a valid report format. Report format should \
50 				one of the following %s"%(frappe.bold(self.format), frappe.bold(", ".join(valid_report_formats)))))
51 
52 	def get_report_content(self):
53 		'''Returns file in for the report in given format'''
54 		report = frappe.get_doc('Report', self.report)
55 
56 		if self.report_type=='Report Builder' and self.data_modified_till:
57 			self.filters = json.loads(self.filters) if self.filters else {}
58 			self.filters['modified'] = ('>', frappe.utils.now_datetime() - timedelta(hours=self.data_modified_till))
59 
60 		columns, data = report.get_data(limit=self.no_of_rows or 100, user = self.user,
61 			filters = self.filters, as_dict=True)
62 
63 		# add serial numbers
64 		columns.insert(0, frappe._dict(fieldname='idx', label='', width='30px'))
65 		for i in range(len(data)):
66 			data[i]['idx'] = i+1
67 
68 		if len(data)==0 and self.send_if_data:
69 			return None
70 
71 		if self.format == 'HTML':
72 			return self.get_html_table(columns, data)
73 
74 		elif self.format == 'XLSX':
75 			spreadsheet_data = self.get_spreadsheet_data(columns, data)
76 			xlsx_file = make_xlsx(spreadsheet_data, "Auto Email Report")
77 			return xlsx_file.getvalue()
78 
79 		elif self.format == 'CSV':
80 			spreadsheet_data = self.get_spreadsheet_data(columns, data)
81 			return to_csv(spreadsheet_data)
82 
83 		else:
84 			frappe.throw(_('Invalid Output Format'))
85 
86 	def get_html_table(self, columns=None, data=None):
87 
88 		date_time = global_date_format(now()) + ' ' + format_time(now())
89 		report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype')
90 
91 		return frappe.render_template('frappe/templates/emails/auto_email_report.html', {
92 			'title': self.name,
93 			'description': self.description,
94 			'date_time': date_time,
95 			'columns': columns,
96 			'data': data,
97 			'report_url': frappe.utils.get_url_to_report(self.report,
98 				self.report_type, report_doctype),
99 			'report_name': self.report,
100 			'edit_report_settings': frappe.utils.get_link_to_form('Auto Email Report',
101 				self.name)
102 		})
103 
104 	@staticmethod
105 	def get_spreadsheet_data(columns, data):
106 		out = [[_(df.label) for df in columns], ]
107 		for row in data:
108 			new_row = []
109 			out.append(new_row)
110 			for df in columns:
111 				new_row.append(frappe.format(row[df.fieldname], df, row))
112 
113 		return out
114 
115 	def get_file_name(self):
116 		return "{0}.{1}".format(self.report.replace(" ", "-").replace("/", "-"), self.format.lower())
117 
118 	def send(self):
119 		if self.filter_meta and not self.filters:
120 			frappe.throw(_("Please set filters value in Report Filter table."))
121 
122 		data = self.get_report_content()
123 		if not data:
124 			return
125 
126 		attachments = None
127 		if self.format == "HTML":
128 			message = data
129 		else:
130 			message = self.get_html_table()
131 
132 		if not self.format=='HTML':
133 			attachments = [{
134 				'fname': self.get_file_name(),
135 				'fcontent': data
136 			}]
137 
138 		frappe.sendmail(
139 			recipients = self.email_to.split(),
140 			subject = self.name,
141 			message = message,
142 			attachments = attachments,
143 			reference_doctype = self.doctype,
144 			reference_name = self.name
145 		)
146 
147 @frappe.whitelist()
148 def download(name):
149 	'''Download report locally'''
150 	auto_email_report = frappe.get_doc('Auto Email Report', name)
151 	auto_email_report.check_permission()
152 	data = auto_email_report.get_report_content()
153 
154 	if not data:
155 		frappe.msgprint(_('No Data'))
156 		return
157 
158 	frappe.local.response.filecontent = data
159 	frappe.local.response.type = "download"
160 	frappe.local.response.filename = auto_email_report.get_file_name()
161 
162 @frappe.whitelist()
163 def send_now(name):
164 	'''Send Auto Email report now'''
165 	auto_email_report = frappe.get_doc('Auto Email Report', name)
166 	auto_email_report.check_permission()
167 	auto_email_report.send()
168 
169 def send_daily():
170 	'''Check reports to be sent daily'''
171 	now = frappe.utils.now_datetime()
172 	for report in frappe.get_all('Auto Email Report',
173 		{'enabled': 1, 'frequency': ('in', ('Daily', 'Weekly'))}):
174 		auto_email_report = frappe.get_doc('Auto Email Report', report.name)
175 
176 		# if not correct weekday, skip
177 		if auto_email_report.frequency=='Weekly':
178 			if now.weekday()!={'Monday':0,'Tuesday':1,'Wednesday':2,
179 				'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}[auto_email_report.day_of_week]:
180 				continue
181 
182 		auto_email_report.send()
183 
184 
185 def send_monthly():
186 	'''Check reports to be sent monthly'''
187 	for report in frappe.get_all('Auto Email Report', {'enabled': 1, 'frequency': 'Monthly'}):
188 		frappe.get_doc('Auto Email Report', report.name).send()
189
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/frappe/email/doctype/auto_email_report/auto_email_report.py b/frappe/email/doctype/auto_email_report/auto_email_report.py
--- a/frappe/email/doctype/auto_email_report/auto_email_report.py
+++ b/frappe/email/doctype/auto_email_report/auto_email_report.py
@@ -12,7 +12,7 @@
 from frappe.utils.xlsxutils import make_xlsx
 from frappe.utils.csvutils import to_csv
 
-max_reports_per_user = 3
+max_reports_per_user = frappe.local.conf.max_reports_per_user or 3
 
 class AutoEmailReport(Document):
 	def autoname(self):

{"golden_diff": "diff --git a/frappe/email/doctype/auto_email_report/auto_email_report.py b/frappe/email/doctype/auto_email_report/auto_email_report.py\n--- a/frappe/email/doctype/auto_email_report/auto_email_report.py\n+++ b/frappe/email/doctype/auto_email_report/auto_email_report.py\n@@ -12,7 +12,7 @@\n from frappe.utils.xlsxutils import make_xlsx\n from frappe.utils.csvutils import to_csv\n \n-max_reports_per_user = 3\n+max_reports_per_user = frappe.local.conf.max_reports_per_user or 3\n \n class AutoEmailReport(Document):\n \tdef autoname(self):\n", "issue": "Auto Email Report Should be fetched from site_config\n#### Expected Behaviour\r\nAdding the `max_reports_per_user` field in site_config should be fetched for Auto Email Report limit instead of the static 3 used currently.\r\n\r\nReference: https://discuss.erpnext.com/t/auto-email-report-why-there-is-a-limit-of-3-user-field/23296/4\r\n\r\nFrapp\u00e9 version: 10.0.16\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2015, Frappe Technologies and contributors\n# For license information, please see license.txt\n\nfrom __future__ import unicode_literals\nimport frappe, json\nfrom frappe import _\nfrom frappe.model.document import Document\nfrom datetime import timedelta\nimport frappe.utils\nfrom frappe.utils import now, global_date_format, format_time\nfrom frappe.utils.xlsxutils import make_xlsx\nfrom frappe.utils.csvutils import to_csv\n\nmax_reports_per_user = 3\n\nclass AutoEmailReport(Document):\n\tdef autoname(self):\n\t\tself.name = _(self.report)\n\n\tdef validate(self):\n\t\tself.validate_report_count()\n\t\tself.validate_emails()\n\t\tself.validate_report_format()\n\n\tdef validate_emails(self):\n\t\t'''Cleanup list of emails'''\n\t\tif ',' in self.email_to:\n\t\t\tself.email_to.replace(',', '\\n')\n\n\t\tvalid = []\n\t\tfor email in self.email_to.split():\n\t\t\tif email:\n\t\t\t\tfrappe.utils.validate_email_add(email, True)\n\t\t\t\tvalid.append(email)\n\n\t\tself.email_to = '\\n'.join(valid)\n\n\tdef validate_report_count(self):\n\t\t'''check that there are only 3 enabled reports per user'''\n\t\tcount = frappe.db.sql('select count(*) from `tabAuto Email Report` where user=%s and enabled=1', self.user)[0][0]\n\t\tif count > max_reports_per_user + (-1 if self.flags.in_insert else 0):\n\t\t\tfrappe.throw(_('Only {0} emailed reports are allowed per user').format(max_reports_per_user))\n\n\tdef validate_report_format(self):\n\t\t\"\"\" check if user has select correct report format \"\"\"\n\t\tvalid_report_formats = [\"HTML\", \"XLSX\", \"CSV\"]\n\t\tif self.format not in valid_report_formats:\n\t\t\tfrappe.throw(_(\"%s is not a valid report format. Report format should \\\n\t\t\t\tone of the following %s\"%(frappe.bold(self.format), frappe.bold(\", \".join(valid_report_formats)))))\n\n\tdef get_report_content(self):\n\t\t'''Returns file in for the report in given format'''\n\t\treport = frappe.get_doc('Report', self.report)\n\n\t\tif self.report_type=='Report Builder' and self.data_modified_till:\n\t\t\tself.filters = json.loads(self.filters) if self.filters else {}\n\t\t\tself.filters['modified'] = ('>', frappe.utils.now_datetime() - timedelta(hours=self.data_modified_till))\n\n\t\tcolumns, data = report.get_data(limit=self.no_of_rows or 100, user = self.user,\n\t\t\tfilters = self.filters, as_dict=True)\n\n\t\t# add serial numbers\n\t\tcolumns.insert(0, frappe._dict(fieldname='idx', label='', width='30px'))\n\t\tfor i in range(len(data)):\n\t\t\tdata[i]['idx'] = i+1\n\n\t\tif len(data)==0 and self.send_if_data:\n\t\t\treturn None\n\n\t\tif self.format == 'HTML':\n\t\t\treturn self.get_html_table(columns, data)\n\n\t\telif self.format == 'XLSX':\n\t\t\tspreadsheet_data = self.get_spreadsheet_data(columns, data)\n\t\t\txlsx_file = make_xlsx(spreadsheet_data, \"Auto Email Report\")\n\t\t\treturn xlsx_file.getvalue()\n\n\t\telif self.format == 'CSV':\n\t\t\tspreadsheet_data = self.get_spreadsheet_data(columns, data)\n\t\t\treturn to_csv(spreadsheet_data)\n\n\t\telse:\n\t\t\tfrappe.throw(_('Invalid Output Format'))\n\n\tdef get_html_table(self, columns=None, data=None):\n\n\t\tdate_time = global_date_format(now()) + ' ' + format_time(now())\n\t\treport_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype')\n\n\t\treturn frappe.render_template('frappe/templates/emails/auto_email_report.html', {\n\t\t\t'title': self.name,\n\t\t\t'description': self.description,\n\t\t\t'date_time': date_time,\n\t\t\t'columns': columns,\n\t\t\t'data': data,\n\t\t\t'report_url': frappe.utils.get_url_to_report(self.report,\n\t\t\t\tself.report_type, report_doctype),\n\t\t\t'report_name': self.report,\n\t\t\t'edit_report_settings': frappe.utils.get_link_to_form('Auto Email Report',\n\t\t\t\tself.name)\n\t\t})\n\n\t@staticmethod\n\tdef get_spreadsheet_data(columns, data):\n\t\tout = [[_(df.label) for df in columns], ]\n\t\tfor row in data:\n\t\t\tnew_row = []\n\t\t\tout.append(new_row)\n\t\t\tfor df in columns:\n\t\t\t\tnew_row.append(frappe.format(row[df.fieldname], df, row))\n\n\t\treturn out\n\n\tdef get_file_name(self):\n\t\treturn \"{0}.{1}\".format(self.report.replace(\" \", \"-\").replace(\"/\", \"-\"), self.format.lower())\n\n\tdef send(self):\n\t\tif self.filter_meta and not self.filters:\n\t\t\tfrappe.throw(_(\"Please set filters value in Report Filter table.\"))\n\n\t\tdata = self.get_report_content()\n\t\tif not data:\n\t\t\treturn\n\n\t\tattachments = None\n\t\tif self.format == \"HTML\":\n\t\t\tmessage = data\n\t\telse:\n\t\t\tmessage = self.get_html_table()\n\n\t\tif not self.format=='HTML':\n\t\t\tattachments = [{\n\t\t\t\t'fname': self.get_file_name(),\n\t\t\t\t'fcontent': data\n\t\t\t}]\n\n\t\tfrappe.sendmail(\n\t\t\trecipients = self.email_to.split(),\n\t\t\tsubject = self.name,\n\t\t\tmessage = message,\n\t\t\tattachments = attachments,\n\t\t\treference_doctype = self.doctype,\n\t\t\treference_name = self.name\n\t\t)\n\n@frappe.whitelist()\ndef download(name):\n\t'''Download report locally'''\n\tauto_email_report = frappe.get_doc('Auto Email Report', name)\n\tauto_email_report.check_permission()\n\tdata = auto_email_report.get_report_content()\n\n\tif not data:\n\t\tfrappe.msgprint(_('No Data'))\n\t\treturn\n\n\tfrappe.local.response.filecontent = data\n\tfrappe.local.response.type = \"download\"\n\tfrappe.local.response.filename = auto_email_report.get_file_name()\n\n@frappe.whitelist()\ndef send_now(name):\n\t'''Send Auto Email report now'''\n\tauto_email_report = frappe.get_doc('Auto Email Report', name)\n\tauto_email_report.check_permission()\n\tauto_email_report.send()\n\ndef send_daily():\n\t'''Check reports to be sent daily'''\n\tnow = frappe.utils.now_datetime()\n\tfor report in frappe.get_all('Auto Email Report',\n\t\t{'enabled': 1, 'frequency': ('in', ('Daily', 'Weekly'))}):\n\t\tauto_email_report = frappe.get_doc('Auto Email Report', report.name)\n\n\t\t# if not correct weekday, skip\n\t\tif auto_email_report.frequency=='Weekly':\n\t\t\tif now.weekday()!={'Monday':0,'Tuesday':1,'Wednesday':2,\n\t\t\t\t'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}[auto_email_report.day_of_week]:\n\t\t\t\tcontinue\n\n\t\tauto_email_report.send()\n\n\ndef send_monthly():\n\t'''Check reports to be sent monthly'''\n\tfor report in frappe.get_all('Auto Email Report', {'enabled': 1, 'frequency': 'Monthly'}):\n\t\tfrappe.get_doc('Auto Email Report', report.name).send()\n", "path": "frappe/email/doctype/auto_email_report/auto_email_report.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2015, Frappe Technologies and contributors\n# For license information, please see license.txt\n\nfrom __future__ import unicode_literals\nimport frappe, json\nfrom frappe import _\nfrom frappe.model.document import Document\nfrom datetime import timedelta\nimport frappe.utils\nfrom frappe.utils import now, global_date_format, format_time\nfrom frappe.utils.xlsxutils import make_xlsx\nfrom frappe.utils.csvutils import to_csv\n\nmax_reports_per_user = frappe.local.conf.max_reports_per_user or 3\n\nclass AutoEmailReport(Document):\n\tdef autoname(self):\n\t\tself.name = _(self.report)\n\n\tdef validate(self):\n\t\tself.validate_report_count()\n\t\tself.validate_emails()\n\t\tself.validate_report_format()\n\n\tdef validate_emails(self):\n\t\t'''Cleanup list of emails'''\n\t\tif ',' in self.email_to:\n\t\t\tself.email_to.replace(',', '\\n')\n\n\t\tvalid = []\n\t\tfor email in self.email_to.split():\n\t\t\tif email:\n\t\t\t\tfrappe.utils.validate_email_add(email, True)\n\t\t\t\tvalid.append(email)\n\n\t\tself.email_to = '\\n'.join(valid)\n\n\tdef validate_report_count(self):\n\t\t'''check that there are only 3 enabled reports per user'''\n\t\tcount = frappe.db.sql('select count(*) from `tabAuto Email Report` where user=%s and enabled=1', self.user)[0][0]\n\t\tif count > max_reports_per_user + (-1 if self.flags.in_insert else 0):\n\t\t\tfrappe.throw(_('Only {0} emailed reports are allowed per user').format(max_reports_per_user))\n\n\tdef validate_report_format(self):\n\t\t\"\"\" check if user has select correct report format \"\"\"\n\t\tvalid_report_formats = [\"HTML\", \"XLSX\", \"CSV\"]\n\t\tif self.format not in valid_report_formats:\n\t\t\tfrappe.throw(_(\"%s is not a valid report format. Report format should \\\n\t\t\t\tone of the following %s\"%(frappe.bold(self.format), frappe.bold(\", \".join(valid_report_formats)))))\n\n\tdef get_report_content(self):\n\t\t'''Returns file in for the report in given format'''\n\t\treport = frappe.get_doc('Report', self.report)\n\n\t\tif self.report_type=='Report Builder' and self.data_modified_till:\n\t\t\tself.filters = json.loads(self.filters) if self.filters else {}\n\t\t\tself.filters['modified'] = ('>', frappe.utils.now_datetime() - timedelta(hours=self.data_modified_till))\n\n\t\tcolumns, data = report.get_data(limit=self.no_of_rows or 100, user = self.user,\n\t\t\tfilters = self.filters, as_dict=True)\n\n\t\t# add serial numbers\n\t\tcolumns.insert(0, frappe._dict(fieldname='idx', label='', width='30px'))\n\t\tfor i in range(len(data)):\n\t\t\tdata[i]['idx'] = i+1\n\n\t\tif len(data)==0 and self.send_if_data:\n\t\t\treturn None\n\n\t\tif self.format == 'HTML':\n\t\t\treturn self.get_html_table(columns, data)\n\n\t\telif self.format == 'XLSX':\n\t\t\tspreadsheet_data = self.get_spreadsheet_data(columns, data)\n\t\t\txlsx_file = make_xlsx(spreadsheet_data, \"Auto Email Report\")\n\t\t\treturn xlsx_file.getvalue()\n\n\t\telif self.format == 'CSV':\n\t\t\tspreadsheet_data = self.get_spreadsheet_data(columns, data)\n\t\t\treturn to_csv(spreadsheet_data)\n\n\t\telse:\n\t\t\tfrappe.throw(_('Invalid Output Format'))\n\n\tdef get_html_table(self, columns=None, data=None):\n\n\t\tdate_time = global_date_format(now()) + ' ' + format_time(now())\n\t\treport_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype')\n\n\t\treturn frappe.render_template('frappe/templates/emails/auto_email_report.html', {\n\t\t\t'title': self.name,\n\t\t\t'description': self.description,\n\t\t\t'date_time': date_time,\n\t\t\t'columns': columns,\n\t\t\t'data': data,\n\t\t\t'report_url': frappe.utils.get_url_to_report(self.report,\n\t\t\t\tself.report_type, report_doctype),\n\t\t\t'report_name': self.report,\n\t\t\t'edit_report_settings': frappe.utils.get_link_to_form('Auto Email Report',\n\t\t\t\tself.name)\n\t\t})\n\n\t@staticmethod\n\tdef get_spreadsheet_data(columns, data):\n\t\tout = [[_(df.label) for df in columns], ]\n\t\tfor row in data:\n\t\t\tnew_row = []\n\t\t\tout.append(new_row)\n\t\t\tfor df in columns:\n\t\t\t\tnew_row.append(frappe.format(row[df.fieldname], df, row))\n\n\t\treturn out\n\n\tdef get_file_name(self):\n\t\treturn \"{0}.{1}\".format(self.report.replace(\" \", \"-\").replace(\"/\", \"-\"), self.format.lower())\n\n\tdef send(self):\n\t\tif self.filter_meta and not self.filters:\n\t\t\tfrappe.throw(_(\"Please set filters value in Report Filter table.\"))\n\n\t\tdata = self.get_report_content()\n\t\tif not data:\n\t\t\treturn\n\n\t\tattachments = None\n\t\tif self.format == \"HTML\":\n\t\t\tmessage = data\n\t\telse:\n\t\t\tmessage = self.get_html_table()\n\n\t\tif not self.format=='HTML':\n\t\t\tattachments = [{\n\t\t\t\t'fname': self.get_file_name(),\n\t\t\t\t'fcontent': data\n\t\t\t}]\n\n\t\tfrappe.sendmail(\n\t\t\trecipients = self.email_to.split(),\n\t\t\tsubject = self.name,\n\t\t\tmessage = message,\n\t\t\tattachments = attachments,\n\t\t\treference_doctype = self.doctype,\n\t\t\treference_name = self.name\n\t\t)\n\n@frappe.whitelist()\ndef download(name):\n\t'''Download report locally'''\n\tauto_email_report = frappe.get_doc('Auto Email Report', name)\n\tauto_email_report.check_permission()\n\tdata = auto_email_report.get_report_content()\n\n\tif not data:\n\t\tfrappe.msgprint(_('No Data'))\n\t\treturn\n\n\tfrappe.local.response.filecontent = data\n\tfrappe.local.response.type = \"download\"\n\tfrappe.local.response.filename = auto_email_report.get_file_name()\n\n@frappe.whitelist()\ndef send_now(name):\n\t'''Send Auto Email report now'''\n\tauto_email_report = frappe.get_doc('Auto Email Report', name)\n\tauto_email_report.check_permission()\n\tauto_email_report.send()\n\ndef send_daily():\n\t'''Check reports to be sent daily'''\n\tnow = frappe.utils.now_datetime()\n\tfor report in frappe.get_all('Auto Email Report',\n\t\t{'enabled': 1, 'frequency': ('in', ('Daily', 'Weekly'))}):\n\t\tauto_email_report = frappe.get_doc('Auto Email Report', report.name)\n\n\t\t# if not correct weekday, skip\n\t\tif auto_email_report.frequency=='Weekly':\n\t\t\tif now.weekday()!={'Monday':0,'Tuesday':1,'Wednesday':2,\n\t\t\t\t'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}[auto_email_report.day_of_week]:\n\t\t\t\tcontinue\n\n\t\tauto_email_report.send()\n\n\ndef send_monthly():\n\t'''Check reports to be sent monthly'''\n\tfor report in frappe.get_all('Auto Email Report', {'enabled': 1, 'frequency': 'Monthly'}):\n\t\tfrappe.get_doc('Auto Email Report', report.name).send()\n", "path": "frappe/email/doctype/auto_email_report/auto_email_report.py"}]}