feat: added project in Sales Analytics report

This commit is contained in:
Anupam K 2020-09-11 13:59:07 +05:30
parent cd89994b33
commit ed08e593c3
2 changed files with 28 additions and 2 deletions

View File

@ -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
},

View File

@ -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()