Merge pull request #21945 from rohitwaghchaure/fixed-v13-beta-2-issues

fix: manufacturing dashboard and work order summary chart
This commit is contained in:
rohitwaghchaure 2020-05-26 23:19:44 +05:30 committed by GitHub
commit ed98796f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 31 deletions

View File

@ -3,7 +3,7 @@
import frappe, erpnext, json import frappe, erpnext, json
from frappe import _ 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 from erpnext.accounts.utils import get_fiscal_year
def get_data(): def get_data():
@ -28,10 +28,10 @@ def get_dashboards():
{ "chart": "Job Card Analysis", "width": "Full" } { "chart": "Job Card Analysis", "width": "Full" }
], ],
"cards": [ "cards": [
{ "card": "Total Work Order" }, { "card": "Monthly Total Work Order" },
{ "card": "Completed Work Order" }, { "card": "Monthly Completed Work Order" },
{ "card": "Ongoing Job Card" }, { "card": "Ongoing Job Card" },
{ "card": "Total Quality Inspection"} { "card": "Monthly Quality Inspection"}
] ]
}] }]
@ -180,38 +180,37 @@ def get_charts():
}] }]
def get_number_cards(): def get_number_cards():
fiscal_year = get_fiscal_year(date=nowdate()) start_date = add_months(nowdate(), -1)
year_start_date = get_date_str(fiscal_year[1]) end_date = nowdate()
year_end_date = get_date_str(fiscal_year[2])
return [{ return [{
"doctype": "Number Card", "doctype": "Number Card",
"document_type": "Work Order", "document_type": "Work Order",
"name": "Total Work Order", "name": "Monthly Total Work Order",
"filters_json": json.dumps([ "filters_json": json.dumps([
['Work Order', 'docstatus', '=', 1], ['Work Order', 'docstatus', '=', 1],
['Work Order', 'creation', 'between', [year_start_date, year_end_date]] ['Work Order', 'creation', 'between', [start_date, end_date]]
]), ]),
"function": "Count", "function": "Count",
"is_public": 1, "is_public": 1,
"label": _("Total Work Order"), "label": _("Monthly Total Work Order"),
"show_percentage_stats": 1, "show_percentage_stats": 1,
"stats_time_interval": "Monthly" "stats_time_interval": "Weekly"
}, },
{ {
"doctype": "Number Card", "doctype": "Number Card",
"document_type": "Work Order", "document_type": "Work Order",
"name": "Completed Work Order", "name": "Monthly Completed Work Order",
"filters_json": json.dumps([ "filters_json": json.dumps([
['Work Order', 'status', '=', 'Completed'], ['Work Order', 'status', '=', 'Completed'],
['Work Order', 'docstatus', '=', 1], ['Work Order', 'docstatus', '=', 1],
['Work Order', 'creation', 'between', [year_start_date, year_end_date]] ['Work Order', 'creation', 'between', [start_date, end_date]]
]), ]),
"function": "Count", "function": "Count",
"is_public": 1, "is_public": 1,
"label": _("Completed Work Order"), "label": _("Monthly Completed Work Order"),
"show_percentage_stats": 1, "show_percentage_stats": 1,
"stats_time_interval": "Monthly" "stats_time_interval": "Weekly"
}, },
{ {
"doctype": "Number Card", "doctype": "Number Card",
@ -225,16 +224,19 @@ def get_number_cards():
"is_public": 1, "is_public": 1,
"label": _("Ongoing Job Card"), "label": _("Ongoing Job Card"),
"show_percentage_stats": 1, "show_percentage_stats": 1,
"stats_time_interval": "Monthly" "stats_time_interval": "Weekly"
}, },
{ {
"doctype": "Number Card", "doctype": "Number Card",
"document_type": "Quality Inspection", "document_type": "Quality Inspection",
"name": "Total Quality Inspection", "name": "Monthly Quality Inspection",
"filters_json": json.dumps([['Quality Inspection', 'docstatus', '=', 1]]), "filters_json": json.dumps([
['Quality Inspection', 'docstatus', '=', 1],
['Quality Inspection', 'creation', 'between', [start_date, end_date]]
]),
"function": "Count", "function": "Count",
"is_public": 1, "is_public": 1,
"label": _("Total Quality Inspection"), "label": _("Monthly Quality Inspection"),
"show_percentage_stats": 1, "show_percentage_stats": 1,
"stats_time_interval": "Monthly" "stats_time_interval": "Weekly"
}] }]

View File

@ -1,11 +1,13 @@
{ {
"actions": [], "actions": [],
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:",
"creation": "2020-04-18 04:50:46.187638", "creation": "2020-04-18 04:50:46.187638",
"doctype": "DocType", "doctype": "DocType",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"naming_series",
"workstation", "workstation",
"operator", "operator",
"column_break_4", "column_break_4",
@ -78,10 +80,17 @@
"fieldname": "remarks", "fieldname": "remarks",
"fieldtype": "Text", "fieldtype": "Text",
"label": "Remarks" "label": "Remarks"
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Naming Series",
"options": "DT-",
"reqd": 1
} }
], ],
"links": [], "links": [],
"modified": "2020-05-19 12:59:37.358483", "modified": "2020-05-26 22:14:54.479831",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Downtime Entry", "name": "Downtime Entry",

View File

@ -24,7 +24,12 @@ def get_data(filters):
if filters.get("workstation"): if filters.get("workstation"):
query_filters["workstation"] = 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): def get_chart_data(data, columns):
labels = sorted(list(set([d.workstation for d in data]))) labels = sorted(list(set([d.workstation for d in data])))
@ -44,7 +49,7 @@ def get_chart_data(data, columns):
"data": { "data": {
"labels": labels, "labels": labels,
"datasets": [ "datasets": [
{"name": "Dataset 1", "values": datasets} {"name": "Machine Downtime", "values": datasets}
] ]
}, },
"type": "bar" "type": "bar"
@ -88,7 +93,7 @@ def get_columns(filters):
"width": 160 "width": 160
}, },
{ {
"label": _("Downtime (In Mins)"), "label": _("Downtime (In Hours)"),
"fieldname": "downtime", "fieldname": "downtime",
"fieldtype": "Float", "fieldtype": "Float",
"width": 150 "width": 150

View File

@ -56,7 +56,7 @@ def get_chart_data(data, filters):
return get_chart_based_on_qty(data, filters) return get_chart_based_on_qty(data, filters)
def get_chart_based_on_status(data): def get_chart_based_on_status(data):
labels = ["Not Started", "In Process", "Stopped", "Completed"] labels = ["Completed", "In Process", "Stopped", "Not Started"]
status_wise_data = { status_wise_data = {
"Not Started": 0, "Not Started": 0,
@ -66,13 +66,10 @@ def get_chart_based_on_status(data):
} }
for d in data: for d in data:
if d.status == "In Process" and d.produced_qty: status_wise_data[d.status] += 1
status_wise_data["Completed"] += d.produced_qty
status_wise_data[d.status] += d.qty values = [status_wise_data["Completed"], status_wise_data["In Process"],
status_wise_data["Stopped"], status_wise_data["Not Started"]]
values = [status_wise_data["Not Started"], status_wise_data["In Process"],
status_wise_data["Stopped"], status_wise_data["Completed"]]
chart = { chart = {
"data": { "data": {