Merge pull request #21961 from rohitwaghchaure/fixed-filters-for-manufacturing-reports-pre-release

fix: filters for the manufacturing reports
diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
index c266ba8..cf2276f 100644
--- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
+++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
@@ -57,19 +57,19 @@
 		description: __('Checking this will automatically create a Sales Invoice whenever an appointment is booked for a Patient.')
 	},
 	{
-		fieldname: 'healthcare_service_items',
+		fieldname: 'inpatient_visit_charge_item',
 		title: __('Healthcare Service Items'),
-		description: __('Set up the Healthcare Service Items for billing. Click ') + "<a href='https://docs.erpnext.com/docs/user/manual/en/healthcare/healthcare_settings#2-default-healthcare-service-items' target='_blank'>here</a>" + __(' to know more')
+		description: __('You can create a service item for Inpatient Visit Charge and set it here. Similarly, you can set up other Healthcare Service Items for billing in this section. Click ') + "<a href='https://docs.erpnext.com/docs/user/manual/en/healthcare/healthcare_settings#2-default-healthcare-service-items' target='_blank'>here</a>" + __(' to know more')
 	},
 	{
-		fieldname: 'sb_in_ac',
+		fieldname: 'income_account',
 		title: __('Set up default Accounts for the Healthcare Facility'),
 		description: __('If you wish to override default accounts settings and configure the Income and Receivable accounts for Healthcare, you can do so here.')
 
 	},
 	{
-		fieldname: 'out_patient_sms_alerts',
+		fieldname: 'send_registration_msg',
 		title: __('Out Patient SMS alerts'),
-		description: __('You can set up Out Patient SMS alerts here. Click ') + "<a href='https://docs.erpnext.com/docs/user/manual/en/healthcare/healthcare_settings#4-out-patient-sms-alerts' target='_blank'>here</a>" + __(' to know more')
+		description: __('If you want to send SMS alert on Patient Registration, you can enable this option. Similary, you can set up Out Patient SMS alerts for other functionalities in this section. Click ') + "<a href='https://docs.erpnext.com/docs/user/manual/en/healthcare/healthcare_settings#4-out-patient-sms-alerts' target='_blank'>here</a>" + __(' to know more')
 	}
 ];
diff --git a/erpnext/healthcare/module_onboarding/healthcare/healthcare.json b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json
index db35149..3e50726 100644
--- a/erpnext/healthcare/module_onboarding/healthcare/healthcare.json
+++ b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json
@@ -10,7 +10,7 @@
  "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/healthcare",
  "idx": 0,
  "is_complete": 0,
- "modified": "2020-05-19 12:52:09.757729",
+ "modified": "2020-05-26 23:16:37.603361",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Healthcare",
@@ -20,13 +20,13 @@
    "step": "Create Patient"
   },
   {
-   "step": "Create Practitioner"
-  },
-  {
    "step": "Create Practitioner Schedule"
   },
   {
-   "step": "Setup Schedule and Employee for Healthcare Practitioner"
+   "step": "Introduction to Healthcare Practitioner"
+  },
+  {
+   "step": "Create Healthcare Practitioner"
   },
   {
    "step": "Explore Healthcare Settings"
diff --git a/erpnext/healthcare/onboarding_step/create_practitioner/create_practitioner.json b/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json
similarity index 64%
rename from erpnext/healthcare/onboarding_step/create_practitioner/create_practitioner.json
rename to erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json
index 614b201..c45a347 100644
--- a/erpnext/healthcare/onboarding_step/create_practitioner/create_practitioner.json
+++ b/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json
@@ -1,6 +1,6 @@
 {
  "action": "Create Entry",
- "creation": "2020-05-19 10:39:55.728057",
+ "creation": "2020-05-19 10:39:55.728058",
  "docstatus": 0,
  "doctype": "Onboarding Step",
  "idx": 0,
@@ -8,12 +8,12 @@
  "is_mandatory": 1,
  "is_single": 0,
  "is_skipped": 0,
- "modified": "2020-05-19 12:27:39.851375",
+ "modified": "2020-05-26 23:16:31.965521",
  "modified_by": "Administrator",
- "name": "Create Practitioner",
+ "name": "Create Healthcare Practitioner",
  "owner": "Administrator",
  "reference_document": "Healthcare Practitioner",
  "show_full_form": 1,
- "title": "Create Practitioner",
+ "title": "Create Healthcare Practitioner",
  "validate_action": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json b/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json
index f0c0f61..697b761 100644
--- a/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json
+++ b/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json
@@ -8,7 +8,7 @@
  "is_mandatory": 0,
  "is_single": 0,
  "is_skipped": 0,
- "modified": "2020-05-19 11:46:35.085270",
+ "modified": "2020-05-26 23:10:24.504030",
  "modified_by": "Administrator",
  "name": "Explore Clinical Procedure Templates",
  "owner": "Administrator",
diff --git a/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json b/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json
index 2bdab69..b2d5aef 100644
--- a/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json
+++ b/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json
@@ -8,7 +8,7 @@
  "is_mandatory": 1,
  "is_single": 1,
  "is_skipped": 0,
- "modified": "2020-05-19 12:26:48.682673",
+ "modified": "2020-05-26 23:10:24.507648",
  "modified_by": "Administrator",
  "name": "Explore Healthcare Settings",
  "owner": "Administrator",
diff --git a/erpnext/healthcare/onboarding_step/setup_schedule_and_employee_for_healthcare_practitioner/setup_schedule_and_employee_for_healthcare_practitioner.json b/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json
similarity index 67%
rename from erpnext/healthcare/onboarding_step/setup_schedule_and_employee_for_healthcare_practitioner/setup_schedule_and_employee_for_healthcare_practitioner.json
rename to erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json
index c5af177..fa4c903 100644
--- a/erpnext/healthcare/onboarding_step/setup_schedule_and_employee_for_healthcare_practitioner/setup_schedule_and_employee_for_healthcare_practitioner.json
+++ b/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json
@@ -9,12 +9,12 @@
  "is_mandatory": 1,
  "is_single": 0,
  "is_skipped": 0,
- "modified": "2020-05-19 12:26:42.492734",
+ "modified": "2020-05-26 22:07:07.482530",
  "modified_by": "Administrator",
- "name": "Setup Schedule and Employee for Healthcare Practitioner",
+ "name": "Introduction to Healthcare Practitioner",
  "owner": "Administrator",
  "reference_document": "Healthcare Practitioner",
  "show_full_form": 0,
- "title": "Setup Schedule and Employee for Healthcare Practitioner",
+ "title": "Introduction to Healthcare Practitioner",
  "validate_action": 0
 }
\ No newline at end of file
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
index bab6fb5..e369ba7 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -37,7 +37,7 @@
 				frappe.throw(_("Payroll date can not be less than employee's joining date."))
 			elif getdate(self.from_date) < getdate(date_of_joining):
 				frappe.throw(_("From date can not be less than employee's joining date."))
-			elif getdate(self.to_date) > getdate(relieving_date):
+			elif relieving_date and getdate(self.to_date) > getdate(relieving_date):
 				frappe.throw(_("To date can not be greater than employee's relieving date."))
 
 	def get_amount(self, sal_start_date, sal_end_date):
diff --git a/erpnext/manufacturing/dashboard_fixtures.py b/erpnext/manufacturing/dashboard_fixtures.py
index ef61f23..4a17fd0 100644
--- a/erpnext/manufacturing/dashboard_fixtures.py
+++ b/erpnext/manufacturing/dashboard_fixtures.py
@@ -3,7 +3,7 @@
 
 import frappe, erpnext, json
 from frappe import _
-from frappe.utils import nowdate, get_date_str
+from frappe.utils import nowdate, get_first_day, get_last_day, add_months
 from erpnext.accounts.utils import get_fiscal_year
 
 def get_data():
@@ -28,10 +28,10 @@
 			{ "chart": "Job Card Analysis", "width": "Full" }
 		],
 		"cards": [
-			{ "card": "Total Work Order" },
-			{ "card": "Completed Work Order" },
+			{ "card": "Monthly Total Work Order" },
+			{ "card": "Monthly Completed Work Order" },
 			{ "card": "Ongoing Job Card" },
-			{ "card": "Total Quality Inspection"}
+			{ "card": "Monthly Quality Inspection"}
 		]
 	}]
 
@@ -180,38 +180,37 @@
 	}]
 
 def get_number_cards():
-	fiscal_year = get_fiscal_year(date=nowdate())
-	year_start_date = get_date_str(fiscal_year[1])
-	year_end_date = get_date_str(fiscal_year[2])
+	start_date = add_months(nowdate(), -1)
+	end_date = nowdate()
 
 	return [{
 		"doctype": "Number Card",
 		"document_type": "Work Order",
-		"name": "Total Work Order",
+		"name": "Monthly Total Work Order",
 		"filters_json": json.dumps([
 			['Work Order', 'docstatus', '=', 1],
-			['Work Order', 'creation', 'between', [year_start_date, year_end_date]]
+			['Work Order', 'creation', 'between', [start_date, end_date]]
 		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Total Work Order"),
+		"label": _("Monthly Total Work Order"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
 		"document_type": "Work Order",
-		"name": "Completed Work Order",
+		"name": "Monthly Completed Work Order",
 		"filters_json": json.dumps([
 			['Work Order', 'status', '=', 'Completed'],
 			['Work Order', 'docstatus', '=', 1],
-			['Work Order', 'creation', 'between', [year_start_date, year_end_date]]
+			['Work Order', 'creation', 'between', [start_date, end_date]]
 		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Completed Work Order"),
+		"label": _("Monthly Completed Work Order"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
@@ -225,16 +224,19 @@
 		"is_public": 1,
 		"label": _("Ongoing Job Card"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	},
 	{
 		"doctype": "Number Card",
 		"document_type": "Quality Inspection",
-		"name": "Total Quality Inspection",
-		"filters_json": json.dumps([['Quality Inspection', 'docstatus', '=', 1]]),
+		"name": "Monthly Quality Inspection",
+		"filters_json": json.dumps([
+			['Quality Inspection', 'docstatus', '=', 1],
+			['Quality Inspection', 'creation', 'between', [start_date, end_date]]
+		]),
 		"function": "Count",
 		"is_public": 1,
-		"label": _("Total Quality Inspection"),
+		"label": _("Monthly Quality Inspection"),
 		"show_percentage_stats": 1,
-		"stats_time_interval": "Monthly"
+		"stats_time_interval": "Weekly"
 	}]
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
index 9acb4f0..b301a9e 100644
--- a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
+++ b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
@@ -1,11 +1,13 @@
 {
  "actions": [],
  "allow_import": 1,
+ "autoname": "naming_series:",
  "creation": "2020-04-18 04:50:46.187638",
  "doctype": "DocType",
  "editable_grid": 1,
  "engine": "InnoDB",
  "field_order": [
+  "naming_series",
   "workstation",
   "operator",
   "column_break_4",
@@ -78,10 +80,17 @@
    "fieldname": "remarks",
    "fieldtype": "Text",
    "label": "Remarks"
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Naming Series",
+   "options": "DT-",
+   "reqd": 1
   }
  ],
  "links": [],
- "modified": "2020-05-19 12:59:37.358483",
+ "modified": "2020-05-26 22:14:54.479831",
  "modified_by": "Administrator",
  "module": "Manufacturing",
  "name": "Downtime Entry",
diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
index ac144e2..668e981 100644
--- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
+++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
@@ -3,3 +3,31 @@
 
 frappe.ui.form.on('Manufacturing Settings', {
 });
+
+frappe.tour["Manufacturing Settings"] = [
+	{
+		fieldname: "material_consumption",
+		title: __("Allow Multiple Material Consumption"),
+		description: __("If ticked, multiple materials can be used for a single Work Order. This is useful if one or more time consuming products are being manufactured.")
+	},
+	{
+		fieldname: "backflush_raw_materials_based_on",
+		title: __("Backflush Raw Materials"),
+		description: __("The Stock Entry of type 'Manufacture' is known as backflush. Raw materials being consumed to manufacture finished goods is known as backflushing. <br><br> When creating Manufacture Entry, raw-material items are backflushed based on BOM of production item. If you want raw-material items to be backflushed based on Material Transfer entry made against that Work Order instead, then you can set it under this field.")
+	},
+	{
+		fieldname: "default_wip_warehouse",
+		title: __("Work In Progress Warehouse"),
+		description: __("This Warehouse will be auto-updated in the Work In Progress Warehouse field of Work Orders.")
+	},
+	{
+		fieldname: "default_fg_warehouse",
+		title: __("Finished Goods Warehouse"),
+		description: __("This Warehouse will be auto-updated in the Target Warehouse field of Work Order.")
+	},
+	{
+		fieldname: "update_bom_costs_automatically",
+		title: __("Update BOM Cost Automatically"),
+		description: __("If ticked, the BOM cost will be automatically updated based on Valuation Rate / Price List Rate / last purchase rate of raw materials.")
+	}
+];
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json b/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json
index 582aba4..7ef202e 100644
--- a/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json
+++ b/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json
@@ -1,5 +1,5 @@
 {
- "action": "Update Settings",
+ "action": "Show Form Tour",
  "creation": "2020-05-19 11:55:11.378374",
  "docstatus": 0,
  "doctype": "Onboarding Step",
@@ -8,7 +8,7 @@
  "is_mandatory": 0,
  "is_single": 1,
  "is_skipped": 0,
- "modified": "2020-05-19 12:12:28.145366",
+ "modified": "2020-05-26 20:28:03.558199",
  "modified_by": "Administrator",
  "name": "Explore Manufacturing Settings",
  "owner": "Administrator",
diff --git a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
index 2b2be4f..093309a 100644
--- a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
+++ b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
@@ -24,7 +24,12 @@
 	if filters.get("workstation"):
 		query_filters["workstation"] = filters.get("workstation")
 
-	return frappe.get_all("Downtime Entry", fields= fields, filters=query_filters)
+	data = frappe.get_all("Downtime Entry", fields= fields, filters=query_filters) or []
+	for d in data:
+		if d.downtime:
+			d.downtime = d.downtime / 60
+
+	return data
 
 def get_chart_data(data, columns):
 	labels = sorted(list(set([d.workstation for d in data])))
@@ -44,7 +49,7 @@
 		"data": {
 			"labels": labels,
 			"datasets": [
-				{"name": "Dataset 1", "values": datasets}
+				{"name": "Machine Downtime", "values": datasets}
 			]
 		},
 		"type": "bar"
@@ -88,7 +93,7 @@
 			"width": 160
 		},
 		{
-			"label": _("Downtime (In Mins)"),
+			"label": _("Downtime (In Hours)"),
 			"fieldname": "downtime",
 			"fieldtype": "Float",
 			"width": 150
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
index bc09ed4..fb047b2 100644
--- a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
@@ -56,7 +56,7 @@
 		return get_chart_based_on_qty(data, filters)
 
 def get_chart_based_on_status(data):
-	labels = ["Not Started", "In Process", "Stopped", "Completed"]
+	labels = ["Completed", "In Process", "Stopped", "Not Started"]
 
 	status_wise_data = {
 		"Not Started": 0,
@@ -66,13 +66,10 @@
 	}
 
 	for d in data:
-		if d.status == "In Process" and d.produced_qty:
-			status_wise_data["Completed"] += d.produced_qty
+		status_wise_data[d.status] += 1
 
-		status_wise_data[d.status] += d.qty
-
-	values = [status_wise_data["Not Started"], status_wise_data["In Process"],
-		status_wise_data["Stopped"], status_wise_data["Completed"]]
+	values = [status_wise_data["Completed"], status_wise_data["In Process"],
+		status_wise_data["Stopped"], status_wise_data["Not Started"]]
 
 	chart = {
 		"data": {
diff --git a/erpnext/projects/report/project_summary/project_summary.js b/erpnext/projects/report/project_summary/project_summary.js
index c12a83e..414b7b2 100644
--- a/erpnext/projects/report/project_summary/project_summary.js
+++ b/erpnext/projects/report/project_summary/project_summary.js
@@ -13,11 +13,30 @@
 			"reqd": 1
 		},
 		{
+			"fieldname": "is_active",
+			"label": __("Is Active"),
+			"fieldtype": "Select",
+			"options": "\nYes\nNo",
+			"default": "Yes",
+		},
+		{
 			"fieldname": "status",
 			"label": __("Status"),
 			"fieldtype": "Select",
-			"options": "Open\nCompleted\nCancelled",
+			"options": "\nOpen\nCompleted\nCancelled",
 			"default": "Open"
+		},
+		{
+			"fieldname": "project_type",
+			"label": __("Project Type"),
+			"fieldtype": "Link",
+			"options": "Project Type"
+		},
+		{
+			"fieldname": "priority",
+			"label": __("Priority"),
+			"fieldtype": "Select",
+			"options": "\nLow\nMedium\nHigh"
 		}
 	]
 };
diff --git a/erpnext/projects/report/project_summary/project_summary.py b/erpnext/projects/report/project_summary/project_summary.py
index a20d7f2..ea7f1ab 100644
--- a/erpnext/projects/report/project_summary/project_summary.py
+++ b/erpnext/projects/report/project_summary/project_summary.py
@@ -9,7 +9,7 @@
 	columns = get_columns()
 	data = []
 
-	data = frappe.db.get_all("Project", filters=filters, fields=["name", 'status', "percent_complete", "expected_start_date", "expected_end_date"], order_by="expected_end_date")
+	data = frappe.db.get_all("Project", filters=filters, fields=["name", 'status', "percent_complete", "expected_start_date", "expected_end_date", "project_type"], order_by="expected_end_date")
 
 	for project in data:
 		project["total_tasks"] = frappe.db.count("Task", filters={"project": project.name})
@@ -31,6 +31,13 @@
 			"width": 200
 		},
 		{
+			"fieldname": "project_type",
+			"label": _("Type"),
+			"fieldtype": "Link",
+			"options": "Project Type",
+			"width": 120
+		},
+		{
 			"fieldname": "status",
 			"label": _("Status"),
 			"fieldtype": "Data",
@@ -88,19 +95,19 @@
 
 	return {
 		"data": {
-			'labels': labels,
+			'labels': labels[:30],
 			'datasets': [
 				{
 					"name": "Overdue",
-					"values": overdue
+					"values": overdue[:30]
 				},
 				{
 					"name": "Completed",
-					"values": completed
+					"values": completed[:30]
 				},
 				{
 					"name": "Total Tasks",
-					"values": total
+					"values": total[:30]
 				},
 			]
 		},