Merge pull request #22350 from AfshanKhan/ISS_20_21_02392

fix: Skipping total row for tree-view reports
This commit is contained in:
Deepesh Garg 2020-06-21 19:25:59 +05:30 committed by GitHub
commit 7f94765d02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 41 deletions

View File

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

View File

@ -23,7 +23,14 @@ class Analytics(object):
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 @@ class Analytics(object):
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 @@ class Analytics(object):
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 @@ class Analytics(object):
self.data.append(row)
self.data.append(total_row)
def get_rows_by_group(self):
self.get_periodic_data()
out = []

View File

@ -33,21 +33,6 @@ class TestAnalytics(unittest.TestCase):
report = execute(filters)
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",
@ -149,21 +134,6 @@ class TestAnalytics(unittest.TestCase):
report = execute(filters)
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",