fix: Validate Filters in Sales Funnel. (#21761)
* fix: Validate Filters in Sales Funnel. * fix: Style fixes
This commit is contained in:
parent
d94a38eb51
commit
c734db5d45
@ -90,6 +90,10 @@ erpnext.SalesFunnel = class SalesFunnel {
|
|||||||
|
|
||||||
get_data(btn) {
|
get_data(btn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
if (!this.company) {
|
||||||
|
frappe.throw(__("Please Select a Company."));
|
||||||
|
}
|
||||||
|
|
||||||
const method_map = {
|
const method_map = {
|
||||||
"sales_funnel": "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data",
|
"sales_funnel": "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data",
|
||||||
"opp_by_lead_source": "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source",
|
"opp_by_lead_source": "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source",
|
||||||
|
@ -8,8 +8,17 @@ from frappe import _
|
|||||||
from erpnext.accounts.report.utils import convert
|
from erpnext.accounts.report.utils import convert
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
def validate_filters(from_date, to_date, company):
|
||||||
|
if from_date and to_date and (from_date >= to_date):
|
||||||
|
frappe.throw(_("To Date must be greater than From Date"))
|
||||||
|
|
||||||
|
if not company:
|
||||||
|
frappe.throw(_("Please Select a Company"))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_funnel_data(from_date, to_date, company):
|
def get_funnel_data(from_date, to_date, company):
|
||||||
|
validate_filters(from_date, to_date, company)
|
||||||
|
|
||||||
active_leads = frappe.db.sql("""select count(*) from `tabLead`
|
active_leads = frappe.db.sql("""select count(*) from `tabLead`
|
||||||
where (date(`modified`) between %s and %s)
|
where (date(`modified`) between %s and %s)
|
||||||
and status != "Do Not Contact" and company=%s""", (from_date, to_date, company))[0][0]
|
and status != "Do Not Contact" and company=%s""", (from_date, to_date, company))[0][0]
|
||||||
@ -38,6 +47,8 @@ def get_funnel_data(from_date, to_date, company):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_opp_by_lead_source(from_date, to_date, company):
|
def get_opp_by_lead_source(from_date, to_date, company):
|
||||||
|
validate_filters(from_date, to_date, company)
|
||||||
|
|
||||||
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability', 'source'])
|
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability', 'source'])
|
||||||
|
|
||||||
if opportunities:
|
if opportunities:
|
||||||
@ -68,6 +79,8 @@ def get_opp_by_lead_source(from_date, to_date, company):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_pipeline_data(from_date, to_date, company):
|
def get_pipeline_data(from_date, to_date, company):
|
||||||
|
validate_filters(from_date, to_date, company)
|
||||||
|
|
||||||
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability'])
|
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability'])
|
||||||
|
|
||||||
if opportunities:
|
if opportunities:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user