Merge pull request #22350 from AfshanKhan/ISS_20_21_02392
fix: Skipping total row for tree-view reports
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.json b/erpnext/selling/report/sales_analytics/sales_analytics.json
index bf9edd6..de5c3a6 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.json
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.json
@@ -1,5 +1,5 @@
{
- "add_total_row": 0,
+ "add_total_row": 1,
"creation": "2018-09-21 12:46:29.451048",
"disable_prepared_report": 0,
"disabled": 0,
@@ -7,7 +7,7 @@
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
- "modified": "2020-04-30 19:49:02.303320",
+ "modified": "2020-06-19 17:41:03.132101",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Analytics",
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py
index 97d9322..4d113c8 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.py
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.py
@@ -23,7 +23,14 @@
self.get_columns()
self.get_data()
self.get_chart_data()
- return self.columns, self.data, None, self.chart
+
+ # Skipping total row for tree-view reports
+ skip_total_row = 0
+
+ if self.filters.tree_type in ["Supplier Group", "Item Group", "Customer Group", "Territory"]:
+ skip_total_row = 1
+
+ return self.columns, self.data, None, self.chart, None, skip_total_row
def get_columns(self):
self.columns = [{
@@ -194,9 +201,6 @@
def get_rows(self):
self.data = []
self.get_periodic_data()
- total_row = {
- "entity": "Total",
- }
for entity, period_data in iteritems(self.entity_periodic_data):
row = {
@@ -210,9 +214,6 @@
row[scrub(period)] = amount
total += amount
- if not total_row.get(scrub(period)): total_row[scrub(period)] = 0
- total_row[scrub(period)] += amount
-
row["total"] = total
if self.filters.tree_type == "Item":
@@ -220,8 +221,6 @@
self.data.append(row)
- self.data.append(total_row)
-
def get_rows_by_group(self):
self.get_periodic_data()
out = []
diff --git a/erpnext/selling/report/sales_analytics/test_analytics.py b/erpnext/selling/report/sales_analytics/test_analytics.py
index 7e8501d..4d81a1e 100644
--- a/erpnext/selling/report/sales_analytics/test_analytics.py
+++ b/erpnext/selling/report/sales_analytics/test_analytics.py
@@ -34,21 +34,6 @@
expected_data = [
{
- 'entity': 'Total',
- 'apr_2017': 0.0,
- 'may_2017': 0.0,
- 'jun_2017': 2000.0,
- 'jul_2017': 1000.0,
- 'aug_2017': 0.0,
- 'sep_2017': 1500.0,
- 'oct_2017': 1000.0,
- 'nov_2017': 0.0,
- 'dec_2017': 0.0,
- 'jan_2018': 0.0,
- 'feb_2018': 2000.0,
- 'mar_2018': 0.0
- },
- {
"entity": "_Test Customer 1",
"entity_name": "_Test Customer 1",
"apr_2017": 0.0,
@@ -150,21 +135,6 @@
expected_data = [
{
- 'entity': 'Total',
- 'apr_2017': 0.0,
- 'may_2017': 0.0,
- 'jun_2017': 20.0,
- 'jul_2017': 10.0,
- 'aug_2017': 0.0,
- 'sep_2017': 15.0,
- 'oct_2017': 10.0,
- 'nov_2017': 0.0,
- 'dec_2017': 0.0,
- 'jan_2018': 0.0,
- 'feb_2018': 20.0,
- 'mar_2018': 0.0
- },
- {
"entity": "_Test Customer 1",
"entity_name": "_Test Customer 1",
"apr_2017": 0.0,