feat: added project in Sales Analytics report
This commit is contained in:
parent
cd89994b33
commit
ed08e593c3
@ -8,7 +8,7 @@ frappe.query_reports["Sales Analytics"] = {
|
|||||||
fieldname: "tree_type",
|
fieldname: "tree_type",
|
||||||
label: __("Tree Type"),
|
label: __("Tree Type"),
|
||||||
fieldtype: "Select",
|
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",
|
default: "Customer",
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ class Analytics(object):
|
|||||||
|
|
||||||
def get_columns(self):
|
def get_columns(self):
|
||||||
self.columns = [{
|
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 "",
|
"options": self.filters.tree_type if self.filters.tree_type != "Order Type" else "",
|
||||||
"fieldname": "entity",
|
"fieldname": "entity",
|
||||||
"fieldtype": "Link" if self.filters.tree_type != "Order Type" else "Data",
|
"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_sales_transactions_based_on_order_type()
|
||||||
self.get_rows_by_group()
|
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):
|
def get_sales_transactions_based_on_order_type(self):
|
||||||
if self.filters["value_quantity"] == 'Value':
|
if self.filters["value_quantity"] == 'Value':
|
||||||
value_field = "base_net_total"
|
value_field = "base_net_total"
|
||||||
@ -198,6 +202,28 @@ class Analytics(object):
|
|||||||
|
|
||||||
self.get_groups()
|
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):
|
def get_rows(self):
|
||||||
self.data = []
|
self.data = []
|
||||||
self.get_periodic_data()
|
self.get_periodic_data()
|
||||||
|
Loading…
Reference in New Issue
Block a user