diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js index 80874c1deb..0e565a3fb6 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.js +++ b/erpnext/selling/report/sales_analytics/sales_analytics.js @@ -8,7 +8,7 @@ frappe.query_reports["Sales Analytics"] = { fieldname: "tree_type", label: __("Tree Type"), fieldtype: "Select", - options: ["Customer Group","Customer","Item Group","Item","Territory","Order Type"], + options: ["Customer Group", "Customer", "Item Group", "Item", "Territory", "Order Type", "Project"], default: "Customer", reqd: 1 }, diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py index 4d113c8e9e..dbaf2acab9 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.py +++ b/erpnext/selling/report/sales_analytics/sales_analytics.py @@ -34,7 +34,7 @@ class Analytics(object): def get_columns(self): self.columns = [{ - "label": _(self.filters.tree_type + " ID"), + "label": _(self.filters.tree_type), "options": self.filters.tree_type if self.filters.tree_type != "Order Type" else "", "fieldname": "entity", "fieldtype": "Link" if self.filters.tree_type != "Order Type" else "Data", @@ -97,6 +97,10 @@ class Analytics(object): self.get_sales_transactions_based_on_order_type() self.get_rows_by_group() + elif self.filters.tree_type == "Project": + self.get_sales_transactions_based_on_project() + self.get_rows() + def get_sales_transactions_based_on_order_type(self): if self.filters["value_quantity"] == 'Value': value_field = "base_net_total" @@ -198,6 +202,28 @@ class Analytics(object): self.get_groups() + def get_sales_transactions_based_on_project(self): + if self.filters["value_quantity"] == 'Value': + value_field = "base_net_total as value_field" + else: + value_field = "total_qty as value_field" + + entity = "project as entity" + + self.entries = frappe.get_all(self.filters.doc_type, + fields=[entity, value_field, self.date_field], + filters={ + "docstatus": 1, + "company": self.filters.company, + "project": ["!=", ""], + self.date_field: ('between', [self.filters.from_date, self.filters.to_date]) + }, debug =True + ) + + self.entity_names = {} + for d in self.entries: + self.entity_names.setdefault(d.entity, d.entity_name) + def get_rows(self): self.data = [] self.get_periodic_data()