Skip to content

Commit

Permalink
fix: sider issues and resolve test case errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedyusufshaikh committed Aug 24, 2021
1 parent 171640e commit 7f5ff69
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_formatted_data(self):

if self.filters.get("based_on") == "Opportunity Owner":

if d.get(based_on) == '[]' or d.get(based_on) == None:
if d.get(based_on) == '[]' or d.get(based_on) is None:
temp = ["Not Assigned"]
else:
temp = json.loads(d.get(based_on))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import unittest
from erpnext.crm.report.opportunity_summary_by_sales_stage.opportunity_summary_by_sales_stage import execute
from erpnext.crm.report.sales_pipeline_analytics.test_sales_pipeline_analytics import create_company,create_customer,create_lead,create_opportunity
from erpnext.crm.report.sales_pipeline_analytics.test_sales_pipeline_analytics import create_company,create_customer,create_opportunity

class TestOpportunitySummaryBySalesStage(unittest.TestCase):

@classmethod
def setUpClass(self):
create_company()
create_customer()
create_lead()
create_opportunity()

def test_opportunity_summary_by_sales_stage(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ def get_periodic_data(self):

if self.filters.get('pipeline_by') == 'Owner':

if value == None or value == '[]':
temp = ["Not Assgined"]
if value is None or value == '[]':
temp = ["Not Assigned"]
else:
temp = json.loads(value)
temp = json.loads(value)
self.check_for_assigned_to(period,value,count,temp,info)

else:
Expand All @@ -211,21 +211,21 @@ def insert_formatted_data(self,period,value,val,temp):
for user in temp:
if self.filters.get("assigned_to") == user:
value = user
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0.0)
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0)
self.periodic_data[value][period] += val
else:
for user in temp:
value = user
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0.0)
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0)
self.periodic_data[value][period] += val
else:
value = temp[0]
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0.0)
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0)
self.periodic_data[value][period] += val

else:
value = value
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0.0)
self.periodic_data.setdefault(value,frappe._dict()).setdefault(period,0)
self.periodic_data[value][period] += val

def check_for_assigned_to(self,period,value,count,temp,info):
Expand Down Expand Up @@ -283,6 +283,7 @@ def append_data(self,pipeline_by,period_by):
period = info.get(period_by)
if self.filters.get('range') == 'Quaterly':
period = "Q" + str(info.get(period_by))

count = period_data.get(period,0.0)
row[period] = count
self.data.append(row)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ class TestSalesPipelineAnalytics(unittest.TestCase):
def setUpClass(self):
create_company()
create_customer()
create_lead()
create_opportunity()


def test_sales_pipeline_analytics(self):
self.check_for_monthly_and_number()
self.check_for_monthly_and_amount()
self.check_for_quarterly_and_number()
self.check_for_quarterly_and_amount()
self.check_for_all_filters()



def check_for_monthly_and_number(self):
filters = {
'pipeline_by':"Owner",
Expand Down Expand Up @@ -61,7 +58,6 @@ def check_for_monthly_and_number(self):

self.assertEqual(expected_data,report[1])


def check_for_monthly_and_amount(self):
filters = {
'pipeline_by':"Owner",
Expand Down Expand Up @@ -103,7 +99,6 @@ def check_for_monthly_and_amount(self):

self.assertEqual(expected_data,report[1])


def check_for_quarterly_and_number(self):
filters = {
'pipeline_by':"Owner",
Expand Down Expand Up @@ -145,7 +140,6 @@ def check_for_quarterly_and_number(self):

self.assertEqual(expected_data,report[1])


def check_for_quarterly_and_amount(self):
filters = {
'pipeline_by':"Owner",
Expand Down Expand Up @@ -187,7 +181,6 @@ def check_for_quarterly_and_amount(self):

self.assertEqual(expected_data,report[1])


def check_for_all_filters(self):
filters = {
'pipeline_by':"Owner",
Expand All @@ -212,7 +205,6 @@ def check_for_all_filters(self):

self.assertEqual(expected_data,report[1])


def create_company():
doc = frappe.db.exists('Company','__Test Company')
if not doc:
Expand All @@ -228,15 +220,6 @@ def create_customer():
doc.customer_name = '_Test Customer'
doc.insert()

def create_lead():
doc = frappe.db.exists("Lead","_Test Lead")
if not doc:
doc = frappe.new_doc("Lead")
doc.lead_name = '_Test Lead'
doc.company_name = 'Client Company'
doc.company = "__Test Company"
doc.insert()

def create_opportunity():
doc = frappe.db.exists({"doctype":"Opportunity","title":"Client Company"})
if not doc:
Expand Down

0 comments on commit 7f5ff69

Please sign in to comment.