fix: add party and party_name columns to trend reports

(cherry picked from commit d05204a960)
This commit is contained in:
Karuppasamy923
2025-06-17 13:29:08 +05:30
committed by Mergify
parent c5bf889391
commit ceab26d5f1
4 changed files with 21 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ def get_chart_data(data, conditions, filters):
datapoints = [] datapoints = []
start = 2 if filters.get("based_on") in ["Item", "Supplier"] else 1 start = 3 if filters.get("based_on") in ["Item", "Supplier"] else 1
if filters.get("group_by"): if filters.get("group_by"):
start += 1 start += 1

View File

@@ -98,9 +98,10 @@ def get_data(filters, conditions):
sel_col = "t1.supplier" sel_col = "t1.supplier"
if filters.get("based_on") in ["Item", "Customer", "Supplier"]: if filters.get("based_on") in ["Item", "Customer", "Supplier"]:
inc = 2 inc = 3
else: else:
inc = 1 inc = 1
data1 = frappe.db.sql( data1 = frappe.db.sql(
""" select {} from `tab{}` t1, `tab{} Item` t2 {} """ select {} from `tab{}` t1, `tab{} Item` t2 {}
where t2.parent = t1.name and t1.company = {} and {} between {} and {} and where t2.parent = t1.name and t1.company = {} and {} between {} and {} and
@@ -330,11 +331,20 @@ def based_wise_columns_query(based_on, trans):
based_on_details["addl_tables"] = "" based_on_details["addl_tables"] = ""
elif based_on == "Customer": elif based_on == "Customer":
based_on_details["based_on_cols"] = [ if trans == "Quotation":
"Customer:Link/Customer:120", based_on_details["based_on_cols"] = [
"Territory:Link/Territory:120", "Party:Link/Customer:120",
] "Party Name:Data:120",
based_on_details["based_on_select"] = "t1.customer_name, t1.territory, " "Territory:Link/Territory:120",
]
based_on_details["based_on_select"] = "t1.party_name, t1.customer_name, t1.territory,"
else:
based_on_details["based_on_cols"] = [
"Customer:Link/Customer:120",
"Customer Name:Data:120",
"Territory:Link/Territory:120",
]
based_on_details["based_on_select"] = "t1.customer, t1.customer_name, t1.territory,"
based_on_details["based_on_group_by"] = "t1.party_name" if trans == "Quotation" else "t1.customer" based_on_details["based_on_group_by"] = "t1.party_name" if trans == "Quotation" else "t1.customer"
based_on_details["addl_tables"] = "" based_on_details["addl_tables"] = ""
@@ -347,9 +357,10 @@ def based_wise_columns_query(based_on, trans):
elif based_on == "Supplier": elif based_on == "Supplier":
based_on_details["based_on_cols"] = [ based_on_details["based_on_cols"] = [
"Supplier:Link/Supplier:120", "Supplier:Link/Supplier:120",
"Supplier Name:Data:120",
"Supplier Group:Link/Supplier Group:140", "Supplier Group:Link/Supplier Group:140",
] ]
based_on_details["based_on_select"] = "t1.supplier, t3.supplier_group," based_on_details["based_on_select"] = "t1.supplier, t1.supplier_name, t3.supplier_group,"
based_on_details["based_on_group_by"] = "t1.supplier" based_on_details["based_on_group_by"] = "t1.supplier"
based_on_details["addl_tables"] = ",`tabSupplier` t3" based_on_details["addl_tables"] = ",`tabSupplier` t3"
based_on_details["addl_tables_relational_cond"] = " and t1.supplier = t3.name" based_on_details["addl_tables_relational_cond"] = " and t1.supplier = t3.name"

View File

@@ -25,7 +25,7 @@ def get_chart_data(data, conditions, filters):
datapoints = [] datapoints = []
start = 2 if filters.get("based_on") in ["Item", "Customer"] else 1 start = 3 if filters.get("based_on") in ["Item", "Customer"] else 1
if filters.get("group_by"): if filters.get("group_by"):
start += 1 start += 1

View File

@@ -24,7 +24,7 @@ def get_chart_data(data, conditions, filters):
datapoints = [] datapoints = []
start = 2 if filters.get("based_on") in ["Item", "Customer"] else 1 start = 3 if filters.get("based_on") in ["Item", "Customer"] else 1
if filters.get("group_by"): if filters.get("group_by"):
start += 1 start += 1