fix: Campaign Efficiency report only works in english (#17284)
* fix column translation and match * fix float results * fix import missing
This commit is contained in:
committed by
Deepesh Garg
parent
4e81fb20b9
commit
a26e2c064a
@@ -4,24 +4,70 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.utils import flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns, data = [], []
|
columns, data = [], []
|
||||||
columns=get_columns()
|
columns=get_columns("Campaign Name")
|
||||||
data=get_lead_data(filters, "Campaign Name")
|
data=get_lead_data(filters or {}, "Campaign Name")
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_columns():
|
def get_columns(based_on):
|
||||||
return [
|
return [
|
||||||
_("Campaign Name") + ":data:130",
|
{
|
||||||
_("Lead Count") + ":Int:80",
|
"fieldname": frappe.scrub(based_on),
|
||||||
_("Opp Count") + ":Int:80",
|
"label": _(based_on),
|
||||||
_("Quot Count") + ":Int:80",
|
"fieldtype": "Data",
|
||||||
_("Order Count") + ":Int:100",
|
"width": 150
|
||||||
_("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
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_lead_data(filters, based_on):
|
def get_lead_data(filters, based_on):
|
||||||
@@ -41,18 +87,18 @@ def get_lead_data(filters, based_on):
|
|||||||
data = []
|
data = []
|
||||||
for based_on_value, leads in lead_map.items():
|
for based_on_value, leads in lead_map.items():
|
||||||
row = {
|
row = {
|
||||||
based_on: based_on_value,
|
based_on_field: based_on_value,
|
||||||
"Lead Count": len(leads)
|
"lead_count": len(leads)
|
||||||
}
|
}
|
||||||
row["Quot Count"]= get_lead_quotation_count(leads)
|
row["quot_count"]= get_lead_quotation_count(leads)
|
||||||
row["Opp Count"] = get_lead_opp_count(leads)
|
row["opp_count"] = get_lead_opp_count(leads)
|
||||||
row["Order Count"] = get_quotation_ordered_count(leads)
|
row["order_count"] = get_quotation_ordered_count(leads)
|
||||||
row["Order Value"] = get_order_amount(leads)
|
row["order_value"] = get_order_amount(leads) or 0
|
||||||
|
|
||||||
row["Opp/Lead %"] = row["Opp Count"] / row["Lead Count"] * 100
|
row["opp_lead"] = flt(row["opp_count"]) / flt(row["lead_count"] or 1.0) * 100.0
|
||||||
row["Quot/Lead %"] = row["Quot Count"] / row["Lead Count"] * 100
|
row["quot_lead"] = flt(row["quot_count"]) / flt(row["lead_count"] or 1.0) * 100.0
|
||||||
|
|
||||||
row["Order/Quot %"] = row["Order Count"] / (row["Quot Count"] or 1) * 100
|
row["order_quot"] = flt(row["order_count"]) / flt(row["quot_count"] or 1.0) * 100.0
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user