fix: Lead owner efficiency report query and column fixes
This commit is contained in:
@@ -115,21 +115,21 @@ def get_filter_conditions(filters):
|
|||||||
|
|
||||||
def get_lead_quotation_count(leads):
|
def get_lead_quotation_count(leads):
|
||||||
return frappe.db.sql("""select count(name) from `tabQuotation`
|
return frappe.db.sql("""select count(name) from `tabQuotation`
|
||||||
where lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
where quotation_to = 'Lead' and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
||||||
|
|
||||||
def get_lead_opp_count(leads):
|
def get_lead_opp_count(leads):
|
||||||
return frappe.db.sql("""select count(name) from `tabOpportunity`
|
return frappe.db.sql("""select count(name) from `tabOpportunity`
|
||||||
where lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
where opportunity_from = 'Lead' and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
||||||
|
|
||||||
def get_quotation_ordered_count(leads):
|
def get_quotation_ordered_count(leads):
|
||||||
return frappe.db.sql("""select count(name)
|
return frappe.db.sql("""select count(name)
|
||||||
from `tabQuotation` where status = 'Ordered'
|
from `tabQuotation` where status = 'Ordered' and quotation_to = 'Lead'
|
||||||
and lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
||||||
|
|
||||||
def get_order_amount(leads):
|
def get_order_amount(leads):
|
||||||
return frappe.db.sql("""select sum(base_net_amount)
|
return frappe.db.sql("""select sum(base_net_amount)
|
||||||
from `tabSales Order Item`
|
from `tabSales Order Item`
|
||||||
where prevdoc_docname in (
|
where prevdoc_docname in (
|
||||||
select name from `tabQuotation` where status = 'Ordered'
|
select name from `tabQuotation` where status = 'Ordered'
|
||||||
and lead in (%s)
|
and quotation_to = 'Lead' and party_name in (%s)
|
||||||
)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
|
||||||
@@ -14,13 +14,58 @@ def execute(filters=None):
|
|||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return [
|
return [
|
||||||
_("Lead Owner") + ":Data:130",
|
{
|
||||||
_("Lead Count") + ":Int:80",
|
"fieldname": "lead_owner",
|
||||||
_("Opp Count") + ":Int:80",
|
"label": _("Lead Owner"),
|
||||||
_("Quot Count") + ":Int:80",
|
"fieldtype": "Data",
|
||||||
_("Order Count") + ":Int:100",
|
"width": "130"
|
||||||
_("Order Value") + ":Float:100",
|
},
|
||||||
_("Opp/Lead %") + ":Float:100",
|
{
|
||||||
_("Quot/Lead %") + ":Float:100",
|
"fieldname": "lead_count",
|
||||||
_("Order/Quot %") + ":Float:100"
|
"label": _("Lead Count"),
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": "80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "opp_count",
|
||||||
|
"label": _("Opp Count"),
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": "80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "quot_count",
|
||||||
|
"label": _("Quot Count"),
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": "80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "order_count",
|
||||||
|
"label": _("Order Count"),
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "order_value",
|
||||||
|
"label": _("Order Value"),
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "opp_lead",
|
||||||
|
"label": _("Opp/Lead %"),
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "quot_lead",
|
||||||
|
"label": _("Quot/Lead %"),
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "order_quot",
|
||||||
|
"label": _("Order/Quot %"),
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": "100"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user