Merge pull request #22458 from scmmishra/fix-email-digest-so-company

fix: add company filter in email digest
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.js b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.js
index 0fab8b7..db4f7c4 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.js
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.js
@@ -188,14 +188,15 @@
 	},
 
 	show_general_ledger: (frm) => {
-		if(frm.doc.docstatus===1) {
+		if(frm.doc.docstatus > 0) {
 			cur_frm.add_custom_button(__('Accounting Ledger'), function() {
 				frappe.route_options = {
 					voucher_no: frm.doc.name,
 					from_date: frm.doc.posting_date,
-					to_date: frm.doc.posting_date,
+					to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
 					company: frm.doc.company,
-					group_by: "Group by Voucher (Consolidated)"
+					group_by: "Group by Voucher (Consolidated)",
+					show_cancelled_entries: frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, __("View"));
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index 5685f83..a09face 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -13,15 +13,16 @@
 	refresh: function(frm) {
 		erpnext.toggle_naming_series();
 
-		if(frm.doc.docstatus==1) {
+		if(frm.doc.docstatus > 0) {
 			frm.add_custom_button(__('Ledger'), function() {
 				frappe.route_options = {
 					"voucher_no": frm.doc.name,
 					"from_date": frm.doc.posting_date,
-					"to_date": frm.doc.posting_date,
+					"to_date": moment(frm.doc.modified).format('YYYY-MM-DD'),
 					"company": frm.doc.company,
 					"finance_book": frm.doc.finance_book,
-					"group_by_voucher": 0
+					"group_by": '',
+					"show_cancelled_entries": frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, __('View'));
diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
index ad0ecc4..774159d 100644
--- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
+++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
@@ -280,7 +280,7 @@
  "idx": 1,
  "istable": 1,
  "links": [],
- "modified": "2020-06-18 14:06:54.833738",
+ "modified": "2020-06-24 14:06:54.833738",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Journal Entry Account",
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index a378a51..42c9fde 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -172,8 +172,8 @@
 		frm.toggle_display("base_paid_amount", frm.doc.paid_from_account_currency != company_currency);
 
 		frm.toggle_display("base_received_amount", (
-			frm.doc.paid_to_account_currency != company_currency 
-			&& frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency 
+			frm.doc.paid_to_account_currency != company_currency
+			&& frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency
 			&& frm.doc.base_paid_amount != frm.doc.base_received_amount
 		));
 
@@ -234,14 +234,15 @@
 	},
 
 	show_general_ledger: function(frm) {
-		if(frm.doc.docstatus==1) {
+		if(frm.doc.docstatus > 0) {
 			frm.add_custom_button(__('Ledger'), function() {
 				frappe.route_options = {
 					"voucher_no": frm.doc.name,
 					"from_date": frm.doc.posting_date,
-					"to_date": frm.doc.posting_date,
+					"to_date": moment(frm.doc.modified).format('YYYY-MM-DD'),
 					"company": frm.doc.company,
-					group_by: ""
+					"group_by": "",
+					"show_cancelled_entries": frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, "fa fa-table");
diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js
index 87e02fe..e923d4e 100644
--- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js
+++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js
@@ -25,9 +25,10 @@
 				frappe.route_options = {
 					"voucher_no": frm.doc.name,
 					"from_date": frm.doc.posting_date,
-					"to_date": frm.doc.posting_date,
+					"to_date": moment(frm.doc.modified).format('YYYY-MM-DD'),
 					"company": frm.doc.company,
-					group_by_voucher: 0
+					"group_by": "",
+					"show_cancelled_entries": frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, "fa fa-table");
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 2ecabe6..9ae5a87 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -408,6 +408,8 @@
 					row.expected_value_after_useful_life = asset_value_after_full_schedule
 
 	def validate_cancellation(self):
+		if self.status in ("In Maintenance", "Out of Order"):
+			frappe.throw(_("There are active maintenance or repairs against the asset. You must complete all of them before cancelling the asset."))
 		if self.status not in ("Submitted", "Partially Depreciated", "Fully Depreciated"):
 			frappe.throw(_("Asset cannot be cancelled, as it is already {0}").format(self.status))
 
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index dfdb487..56af4d9 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -51,7 +51,7 @@
 
 	def validate_email_id(self, args):
 		if not args.email_id:
-			frappe.throw(_("Row {0}: For supplier {0} Email Address is required to send email").format(args.idx, args.supplier))
+			frappe.throw(_("Row {0}: For Supplier {0}, Email Address is Required to Send Email").format(args.idx, args.supplier))
 
 	def on_submit(self):
 		frappe.db.set(self, 'status', 'Submitted')
@@ -154,7 +154,7 @@
 			sender=sender,attachments = attachments, send_email=True,
 		     	doctype=self.doctype, name=self.name)["name"]
 
-		frappe.msgprint(_("Email sent to supplier {0}").format(data.supplier))
+		frappe.msgprint(_("Email Sent to Supplier {0}").format(data.supplier))
 
 	def get_attachments(self):
 		attachments = [d.name for d in get_attachments(self.doctype, self.name)]
@@ -193,7 +193,7 @@
 def check_portal_enabled(reference_doctype):
 	if not frappe.db.get_value('Portal Menu Item',
 		{'reference_doctype': reference_doctype}, 'enabled'):
-		frappe.throw(_("Request for Quotation is disabled to access from portal, for more check portal settings."))
+		frappe.throw(_("The Access to Request for Quotation From Portal is Disabled. To Allow Access, Enable it in Portal Settings."))
 
 def get_list_context(context=None):
 	from erpnext.controllers.website_list_for_contact import get_list_context
@@ -259,7 +259,7 @@
 		sq_doc.flags.ignore_permissions = True
 		sq_doc.run_method("set_missing_values")
 		sq_doc.save()
-		frappe.msgprint(_("Supplier Quotation {0} created").format(sq_doc.name))
+		frappe.msgprint(_("Supplier Quotation {0} Created").format(sq_doc.name))
 		return sq_doc.name
 	except Exception:
 		return None
diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py
index 092baa4..9b4b0eb 100644
--- a/erpnext/controllers/trends.py
+++ b/erpnext/controllers/trends.py
@@ -33,7 +33,7 @@
 			frappe.throw(_("{0} is mandatory").format(f))
 
 	if not frappe.db.exists("Fiscal Year", filters.get("fiscal_year")):
-		frappe.throw(_("Fiscal Year: {0} does not exists").format(filters.get("fiscal_year")))
+		frappe.throw(_("Fiscal Year {0} Does Not Exist").format(filters.get("fiscal_year")))
 
 	if filters.get("based_on") == filters.get("group_by"):
 		frappe.throw(_("'Based On' and 'Group By' can not be same"))
diff --git a/erpnext/education/doctype/fees/fees.js b/erpnext/education/doctype/fees/fees.js
index 17ef449..867866f 100644
--- a/erpnext/education/doctype/fees/fees.js
+++ b/erpnext/education/doctype/fees/fees.js
@@ -55,14 +55,15 @@
 			frm.set_df_property('posting_date', 'read_only', 1);
 			frm.set_df_property('posting_time', 'read_only', 1);
 		}
-		if(frm.doc.docstatus===1) {
+		if(frm.doc.docstatus > 0) {
 			frm.add_custom_button(__('Accounting Ledger'), function() {
 				frappe.route_options = {
 					voucher_no: frm.doc.name,
 					from_date: frm.doc.posting_date,
-					to_date: frm.doc.posting_date,
+					to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
 					company: frm.doc.company,
-					group_by_voucher: false
+					group_by: '',
+					show_cancelled_entries: frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, __("View"));
diff --git a/erpnext/education/report/absent_student_report/absent_student_report.json b/erpnext/education/report/absent_student_report/absent_student_report.json
index 0d5eeba..92ad860 100644
--- a/erpnext/education/report/absent_student_report/absent_student_report.json
+++ b/erpnext/education/report/absent_student_report/absent_student_report.json
@@ -1,20 +1,21 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2013-05-13 14:04:03", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 3, 
- "is_standard": "Yes", 
- "modified": "2017-11-10 19:42:36.457449", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Absent Student Report", 
- "owner": "Administrator", 
- "ref_doctype": "Student Attendance", 
- "report_name": "Absent Student Report", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2013-05-13 14:04:03",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 3,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:16:40.251116",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Absent Student Report",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Student Attendance",
+ "report_name": "Absent Student Report",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Academics User"
diff --git a/erpnext/education/report/assessment_plan_status/assessment_plan_status.json b/erpnext/education/report/assessment_plan_status/assessment_plan_status.json
index 3000bec..cbca648 100644
--- a/erpnext/education/report/assessment_plan_status/assessment_plan_status.json
+++ b/erpnext/education/report/assessment_plan_status/assessment_plan_status.json
@@ -1,20 +1,21 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2017-11-09 15:07:30.404428", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 0, 
- "is_standard": "Yes", 
- "modified": "2017-11-28 18:35:44.903665", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Assessment Plan Status", 
- "owner": "Administrator", 
- "ref_doctype": "Assessment Plan", 
- "report_name": "Assessment Plan Status", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2017-11-09 15:07:30.404428",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:16:02.027410",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Assessment Plan Status",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Assessment Plan",
+ "report_name": "Assessment Plan Status",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Academics User"
diff --git a/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.json b/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.json
index 61976b4..416db9d 100644
--- a/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.json
+++ b/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.json
@@ -1,24 +1,26 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2017-05-05 14:46:13.776133", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 0, 
- "is_standard": "Yes", 
- "modified": "2018-02-08 15:11:24.904628", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Course wise Assessment Report", 
- "owner": "Administrator", 
- "ref_doctype": "Assessment Result", 
- "report_name": "Course wise Assessment Report", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2017-05-05 14:46:13.776133",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:15:15.477530",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Course wise Assessment Report",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "query": "",
+ "ref_doctype": "Assessment Result",
+ "report_name": "Course wise Assessment Report",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Instructor"
-  }, 
+  },
   {
    "role": "Education Manager"
   }
diff --git a/erpnext/education/report/final_assessment_grades/final_assessment_grades.json b/erpnext/education/report/final_assessment_grades/final_assessment_grades.json
index 4d444b4..6a23494 100644
--- a/erpnext/education/report/final_assessment_grades/final_assessment_grades.json
+++ b/erpnext/education/report/final_assessment_grades/final_assessment_grades.json
@@ -1,24 +1,25 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2018-01-22 17:04:43.412054", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 0, 
- "is_standard": "Yes", 
- "modified": "2019-02-08 15:11:35.339434", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Final Assessment Grades", 
- "owner": "Administrator", 
- "ref_doctype": "Assessment Result", 
- "report_name": "Final Assessment Grades", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2018-01-22 17:04:43.412054",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:13:35.373756",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Final Assessment Grades",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Assessment Result",
+ "report_name": "Final Assessment Grades",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Instructor"
-  }, 
+  },
   {
    "role": "Education Manager"
   }
diff --git a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.json b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.json
index fe7d158..fa9be65 100644
--- a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.json
+++ b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.json
@@ -1,24 +1,25 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2017-03-27 17:47:16.831433", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 0, 
- "is_standard": "Yes", 
- "modified": "2017-11-10 19:42:30.300729", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Student and Guardian Contact Details", 
- "owner": "Administrator", 
- "ref_doctype": "Program Enrollment", 
- "report_name": "Student and Guardian Contact Details", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2017-03-27 17:47:16.831433",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:16:50.639488",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Student and Guardian Contact Details",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Program Enrollment",
+ "report_name": "Student and Guardian Contact Details",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Instructor"
-  }, 
+  },
   {
    "role": "Academics User"
   }
diff --git a/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.json b/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.json
index eb547b7..8baf8f9 100644
--- a/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.json
+++ b/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.json
@@ -1,20 +1,21 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2016-11-28 22:07:03.859124", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 2, 
- "is_standard": "Yes", 
- "modified": "2017-11-10 19:41:12.328346", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Student Batch-Wise Attendance", 
- "owner": "Administrator", 
- "ref_doctype": "Student Attendance", 
- "report_name": "Student Batch-Wise Attendance", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2016-11-28 22:07:03.859124",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 2,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:16:59.823709",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Student Batch-Wise Attendance",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Student Attendance",
+ "report_name": "Student Batch-Wise Attendance",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Academics User"
diff --git a/erpnext/education/report/student_fee_collection/student_fee_collection.json b/erpnext/education/report/student_fee_collection/student_fee_collection.json
index eb945cf..8deb865 100644
--- a/erpnext/education/report/student_fee_collection/student_fee_collection.json
+++ b/erpnext/education/report/student_fee_collection/student_fee_collection.json
@@ -1,21 +1,22 @@
 {
- "add_total_row": 0, 
- "creation": "2016-06-22 02:58:41.024538", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 3, 
- "is_standard": "Yes", 
- "modified": "2018-12-17 16:46:46.176620", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Student Fee Collection", 
- "owner": "Administrator", 
- "prepared_report": 0, 
- "query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nGROUP BY\n student", 
- "ref_doctype": "Fees", 
- "report_name": "Student Fee Collection", 
- "report_type": "Query Report", 
+ "add_total_row": 0,
+ "creation": "2016-06-22 02:58:41.024538",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 3,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:14:39.452551",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Student Fee Collection",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nGROUP BY\n student",
+ "ref_doctype": "Fees",
+ "report_name": "Student Fee Collection",
+ "report_type": "Query Report",
  "roles": [
   {
    "role": "Academics User"
diff --git a/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.json b/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.json
index e10f190..1423d4f 100644
--- a/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.json
+++ b/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.json
@@ -1,20 +1,21 @@
 {
- "add_total_row": 0, 
- "apply_user_permissions": 1, 
- "creation": "2013-05-13 14:04:03", 
- "disabled": 0, 
- "docstatus": 0, 
- "doctype": "Report", 
- "idx": 3, 
- "is_standard": "Yes", 
- "modified": "2017-11-10 19:42:43.376658", 
- "modified_by": "Administrator", 
- "module": "Education", 
- "name": "Student Monthly Attendance Sheet", 
- "owner": "Administrator", 
- "ref_doctype": "Student Attendance", 
- "report_name": "Student Monthly Attendance Sheet", 
- "report_type": "Script Report", 
+ "add_total_row": 0,
+ "creation": "2013-05-13 14:04:03",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 3,
+ "is_standard": "Yes",
+ "modified": "2020-06-24 17:16:13.307053",
+ "modified_by": "Administrator",
+ "module": "Education",
+ "name": "Student Monthly Attendance Sheet",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Student Attendance",
+ "report_name": "Student Monthly Attendance Sheet",
+ "report_type": "Script Report",
  "roles": [
   {
    "role": "Academics User"
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index 6bb9af9..fa63ec2 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -213,12 +213,15 @@
 	refresh: function(frm) {
 		frm.trigger("toggle_fields");
 
-		if(frm.doc.docstatus === 1 && frm.doc.approval_status !== "Rejected") {
+		if(frm.doc.docstatus > 0 && frm.doc.approval_status !== "Rejected") {
 			frm.add_custom_button(__('Accounting Ledger'), function() {
 				frappe.route_options = {
 					voucher_no: frm.doc.name,
 					company: frm.doc.company,
-					group_by_voucher: false
+					from_date: frm.doc.posting_date,
+					to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
+					group_by: '',
+					show_cancelled_entries: frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, __("View"));
diff --git a/erpnext/loan_management/loan_common.js b/erpnext/loan_management/loan_common.js
index 3a47a88..d9dd415 100644
--- a/erpnext/loan_management/loan_common.js
+++ b/erpnext/loan_management/loan_common.js
@@ -9,12 +9,15 @@
 		}
 
 		if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual'].includes(frm.doc.doctype)
-			&& frm.doc.docstatus == 1) {
+			&& frm.doc.docstatus > 0) {
 
 			frm.add_custom_button(__("Accounting Ledger"), function() {
 				frappe.route_options = {
 					voucher_no: frm.doc.name,
-					company: frm.doc.company
+					company: frm.doc.company,
+					from_date: frm.doc.posting_date,
+					to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
+					show_cancelled_entries: frm.doc.docstatus === 2
 				};
 
 				frappe.set_route("query-report", "General Ledger");
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 560286e..016ab14 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -98,11 +98,17 @@
 		elif self.get_items_from == "Material Request":
 			self.get_mr_items()
 
+	def get_so_mr_list(self, field, table):
+		"""Returns a list of Sales Orders or Material Requests from the respective tables"""
+		so_mr_list = [d.get(field) for d in self.get(table) if d.get(field)]
+		return so_mr_list
+
 	def get_so_items(self):
-		so_list = [d.sales_order for d in self.sales_orders if d.sales_order]
-		if not so_list:
-			msgprint(_("Please enter Sales Orders in the above table"))
-			return []
+		# Check for empty table or empty rows
+		if not self.get("sales_orders") or not self.get_so_mr_list("sales_order", "sales_orders"):
+			frappe.throw(_("Please fill the Sales Orders table"), title=_("Sales Orders Required"))
+
+		so_list = self.get_so_mr_list("sales_order", "sales_orders")
 
 		item_condition = ""
 		if self.item_code:
@@ -134,10 +140,11 @@
 		self.calculate_total_planned_qty()
 
 	def get_mr_items(self):
-		mr_list = [d.material_request for d in self.material_requests if d.material_request]
-		if not mr_list:
-			msgprint(_("Please enter Material Requests in the above table"))
-			return []
+		# Check for empty table or empty rows
+		if not self.get("material_requests") or not self.get_so_mr_list("material_request", "material_requests"):
+			frappe.throw(_("Please fill the Material Requests table"), title=_("Material Requests Required"))
+
+		mr_list = self.get_so_mr_list("material_request", "material_requests")
 
 		item_condition = ""
 		if self.item_code:
@@ -628,16 +635,18 @@
 
 	if warehouse_list:
 		warehouses = list(set(warehouse_list))
-	
+
 		if doc.get("for_warehouse") and doc.get("for_warehouse") in warehouses:
 			warehouses.remove(doc.get("for_warehouse"))
 
 		warehouse_list = None
 
 	doc['mr_items'] = []
-	po_items = doc.get('po_items') if doc.get('po_items') else doc.get('items')
-	if not po_items:
-		frappe.throw(_("Items are required to pull the raw materials which is associated with it."))
+
+	po_items = doc.get('po_items')
+	if not po_items or not [row.get('item_code') for row in po_items if row.get('item_code')]:
+		frappe.throw(_("Items to Manufacture are required to pull the Raw Materials associated with it."),
+			title=_("Items Required"))
 
 	company = doc.get('company')
 	ignore_existing_ordered_qty = doc.get('ignore_existing_ordered_qty')
diff --git a/erpnext/portal/product_configurator/utils.py b/erpnext/portal/product_configurator/utils.py
index 6b6b8c5..f8af30a 100644
--- a/erpnext/portal/product_configurator/utils.py
+++ b/erpnext/portal/product_configurator/utils.py
@@ -239,13 +239,12 @@
 	if exact_match:
 		data = get_product_info_for_website(exact_match[0])
 		product_info = data.product_info
+		product_info["allow_items_not_in_stock"] = cint(data.cart_settings.allow_items_not_in_stock)
 		if not data.cart_settings.show_price:
 			product_info = None
 	else:
 		product_info = None
 
-	product_info["allow_items_not_in_stock"] = cint(data.cart_settings.allow_items_not_in_stock)
-
 	return {
 		'next_attribute': next_attribute,
 		'valid_options_for_attributes': valid_options_for_attributes,
diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js
index 2ce49e7..87b21b7 100644
--- a/erpnext/public/js/controllers/stock_controller.js
+++ b/erpnext/public/js/controllers/stock_controller.js
@@ -55,8 +55,9 @@
 				frappe.route_options = {
 					voucher_no: me.frm.doc.name,
 					from_date: me.frm.doc.posting_date,
-					to_date: me.frm.doc.posting_date,
-					company: me.frm.doc.company
+					to_date: moment(me.frm.doc.modified).format('YYYY-MM-DD'),
+					company: me.frm.doc.company,
+					show_cancelled_entries: me.frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "Stock Ledger");
 			}, __("View"));
@@ -71,9 +72,10 @@
 				frappe.route_options = {
 					voucher_no: me.frm.doc.name,
 					from_date: me.frm.doc.posting_date,
-					to_date: me.frm.doc.posting_date,
+					to_date: moment(me.frm.doc.modified).format('YYYY-MM-DD'),
 					company: me.frm.doc.company,
-					group_by: "Group by Voucher (Consolidated)"
+					group_by: "Group by Voucher (Consolidated)",
+					show_cancelled_entries: me.frm.doc.docstatus === 2
 				};
 				frappe.set_route("query-report", "General Ledger");
 			}, __("View"));
diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.py b/erpnext/stock/report/stock_ageing/stock_ageing.py
index 723ed5c..d5878cb 100644
--- a/erpnext/stock/report/stock_ageing/stock_ageing.py
+++ b/erpnext/stock/report/stock_ageing/stock_ageing.py
@@ -187,7 +187,7 @@
 						transferred_item_details[(d.voucher_no, d.name)].append(fifo_queue.pop(0))
 					else:
 						# all from current batch
-						batch[0] -= qty_to_pop
+						batch[0] = flt(batch[0]) - qty_to_pop
 						transferred_item_details[(d.voucher_no, d.name)].append([qty_to_pop, batch[1]])
 						qty_to_pop = 0
 
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index 883e603..87168e1 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -79,47 +79,52 @@
 
 	def handle_hold_time(self, status):
 		if self.service_level_agreement:
-			# set response and resolution variance as None as the issue is on Hold for status as Replied
+			# set response and resolution variance as None as the issue is on Hold
 			pause_sla_on = frappe.db.get_all("Pause SLA On Status", fields=["status"],
 				filters={"parent": self.service_level_agreement})
 			hold_statuses = [entry.status for entry in pause_sla_on]
 			update_values = {}
 
-			if self.status in hold_statuses and status not in hold_statuses:
-				update_values['on_hold_since'] = frappe.flags.current_time or now_datetime()
-				if not self.first_responded_on:
-					update_values['response_by'] = None
-					update_values['response_by_variance'] = 0
-				update_values['resolution_by'] = None
-				update_values['resolution_by_variance'] = 0
+			if hold_statuses:
+				if self.status in hold_statuses and status not in hold_statuses:
+					update_values['on_hold_since'] = frappe.flags.current_time or now_datetime()
+					if not self.first_responded_on:
+						update_values['response_by'] = None
+						update_values['response_by_variance'] = 0
+					update_values['resolution_by'] = None
+					update_values['resolution_by_variance'] = 0
 
-			# calculate hold time when status is changed from Replied to any other status
-			if self.status not in hold_statuses and status in hold_statuses:
-				hold_time = self.total_hold_time if self.total_hold_time else 0
-				now_time = frappe.flags.current_time or now_datetime()
-				update_values['total_hold_time'] = hold_time + time_diff_in_seconds(now_time, self.on_hold_since)
+				# calculate hold time when status is changed from any hold status to any non-hold status
+				if self.status not in hold_statuses and status in hold_statuses:
+					hold_time = self.total_hold_time if self.total_hold_time else 0
+					now_time = frappe.flags.current_time or now_datetime()
+					last_hold_time = 0
+					if self.on_hold_since:
+						# last_hold_time will be added to the sla variables
+						last_hold_time = time_diff_in_seconds(now_time, self.on_hold_since)
+						update_values['total_hold_time'] = hold_time + last_hold_time
 
-			# re-calculate SLA variables after issue changes from Replied to Open
-			# add hold time to SLA variables
-			if self.status == "Open" and status in hold_statuses:
-				start_date_time = get_datetime(self.service_level_agreement_creation)
-				priority = get_priority(self)
-				now_time = frappe.flags.current_time or now_datetime()
-				hold_time = time_diff_in_seconds(now_time, self.on_hold_since)
+					# re-calculate SLA variables after issue changes from any hold status to any non-hold status
+					# add hold time to SLA variables
+					start_date_time = get_datetime(self.service_level_agreement_creation)
+					priority = get_priority(self)
+					now_time = frappe.flags.current_time or now_datetime()
 
-				if not self.first_responded_on:
-					response_by = get_expected_time_for(parameter="response", service_level=priority, start_date_time=start_date_time)
-					update_values['response_by'] = add_to_date(response_by, seconds=round(hold_time))
-					response_by_variance = round(time_diff_in_hours(self.response_by, now_time))
-					update_values['response_by_variance'] = response_by_variance + (hold_time // 3600)
+					if not self.first_responded_on:
+						response_by = get_expected_time_for(parameter="response", service_level=priority, start_date_time=start_date_time)
+						response_by = add_to_date(response_by, seconds=round(last_hold_time))
+						response_by_variance = round(time_diff_in_hours(response_by, now_time))
+						update_values['response_by'] = response_by
+						update_values['response_by_variance'] = response_by_variance + (last_hold_time // 3600)
 
-				resolution_by = get_expected_time_for(parameter="resolution", service_level=priority, start_date_time=start_date_time)
-				update_values['resolution_by'] = add_to_date(resolution_by, seconds=round(hold_time))
-				resolution_by_variance = round(time_diff_in_hours(self.resolution_by, now_time))
-				update_values['resolution_by_variance'] = resolution_by_variance + (hold_time // 3600)
-				update_values['on_hold_since'] = None
+					resolution_by = get_expected_time_for(parameter="resolution", service_level=priority, start_date_time=start_date_time)
+					resolution_by = add_to_date(resolution_by, seconds=round(last_hold_time))
+					resolution_by_variance = round(time_diff_in_hours(resolution_by, now_time))
+					update_values['resolution_by'] = resolution_by
+					update_values['resolution_by_variance'] = resolution_by_variance + (last_hold_time // 3600)
+					update_values['on_hold_since'] = None
 
-			self.db_set(update_values)
+				self.db_set(update_values)
 
 	def update_agreement_status(self):
 		if self.service_level_agreement and self.agreement_fulfilled == "Ongoing":