brotherton-erpnext/selling/page/sales_funnel/sales_funnel.py

34 lines
1.5 KiB
Python
Raw Normal View History

2013-10-04 15:49:30 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
@webnotes.whitelist()
def get_funnel_data(from_date, to_date):
active_leads = webnotes.conn.sql("""select count(*) from `tabLead`
2013-10-31 13:36:11 +00:00
where (date(`modified`) between %s and %s)
2013-10-04 15:49:30 +00:00
and status != "Do Not Contact" """, (from_date, to_date))[0][0]
active_leads += webnotes.conn.sql("""select count(distinct customer) from `tabContact`
2013-10-31 13:36:11 +00:00
where (date(`modified`) between %s and %s)
2013-10-04 15:49:30 +00:00
and status != "Passive" """, (from_date, to_date))[0][0]
opportunities = webnotes.conn.sql("""select count(*) from `tabOpportunity`
2013-10-31 13:36:11 +00:00
where docstatus = 1 and (date(`creation`) between %s and %s)
2013-10-04 15:49:30 +00:00
and status != "Lost" """, (from_date, to_date))[0][0]
quotations = webnotes.conn.sql("""select count(*) from `tabQuotation`
2013-10-31 13:36:11 +00:00
where docstatus = 1 and (date(`creation`) between %s and %s)
2013-10-04 15:49:30 +00:00
and status != "Lost" """, (from_date, to_date))[0][0]
sales_orders = webnotes.conn.sql("""select count(*) from `tabQuotation`
2013-10-31 13:36:11 +00:00
where docstatus = 1 and (date(`creation`) between %s and %s)""", (from_date, to_date))[0][0]
2013-10-04 15:49:30 +00:00
return [
{ "title": "Active Leads / Customers", "value": active_leads, "color": "#B03B46" },
{ "title": "Opportunities", "value": opportunities, "color": "#F09C00" },
{ "title": "Quotations", "value": quotations, "color": "#006685" },
{ "title": "Sales Orders", "value": sales_orders, "color": "#00AD65" }
]