Added Number Cards for Opportunities
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
{
|
||||
"creation": "2025-06-18 20:11:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
|
||||
"filters_json": "[[\"Opportunity\",\"expected_closing\",\"Timespan\",\"this month\",false],[\"Opportunity\",\"status\",\"not in\",[\"Closed\",\"Lost\"],false]]",
|
||||
"function": "Count",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Opportunities Closing This Month",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Opportunities Closing This Month",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Document Type"
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
{
|
||||
"creation": "2025-06-18 20:11:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"method": "rangeldigital.rangel_digital.number_card.overdue_opportunities.overdue_opportunities.get_number_card_data",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Overdue Opportunities",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Overdue Opportunities",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Custom"
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from datetime import datetime
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_number_card_data():
|
||||
# Get today's date in YYYY-MM-DD format
|
||||
today = datetime.today().strftime('%Y-%m-%d')
|
||||
|
||||
# Fetch count of open opportunities closing before today
|
||||
count = frappe.db.count(
|
||||
"Opportunity",
|
||||
filters={
|
||||
"expected_closing": ["<", today],
|
||||
"status": ["not in", ["Closed", "Lost"]]
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"value": count,
|
||||
"fieldtype": "Int",
|
||||
"label": _("Overdue Opportunities")
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
{
|
||||
"aggregate_function_based_on": "base_opportunity_amount",
|
||||
"creation": "2020-07-20 20:17:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
|
||||
"filters_json": "[[\"Opportunity\",\"status\",\"not in\",[\"Closed\",\"Lost\"],false]]",
|
||||
"function": "Sum",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Pipeline Total",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Pipeline Total",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Document Type"
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
{
|
||||
"aggregate_function_based_on": "base_opportunity_amount",
|
||||
"creation": "2020-07-20 20:17:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
|
||||
"filters_json": "[[\"Opportunity\",\"expected_closing\",\"Timespan\",\"this month\",false],[\"Opportunity\",\"status\",\"not in\",[\"Closed\",\"Lost\"],false]]",
|
||||
"function": "Sum",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Pipeline Total (This Month)",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Pipeline Total (This Month)",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Document Type"
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
{
|
||||
"creation": "2020-07-20 20:17:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
|
||||
"filters_json": "[[\"Opportunity\",\"status\",\"not in\",[\"Closed\",\"Lost\"],false]]",
|
||||
"function": "Sum",
|
||||
"method": "rangeldigital.rangel_digital.number_card.pipeline_value.pipeline_value.get_number_card_data",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Pipeline Value",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Pipeline Value",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Custom"
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from datetime import datetime
|
||||
from frappe.utils import get_first_day, get_last_day
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_number_card_data():
|
||||
# Get the first and last day of the current month
|
||||
today = datetime.today()
|
||||
first_day = get_first_day(today).strftime('%Y-%m-%d')
|
||||
last_day = get_last_day(today).strftime('%Y-%m-%d')
|
||||
|
||||
# Fetch open opportunities closing this month
|
||||
opportunities = frappe.db.get_all(
|
||||
"Opportunity",
|
||||
filters={
|
||||
"status": ["not in", ["Closed", "Lost"]]
|
||||
},
|
||||
fields=["name", "sales_stage", "base_opportunity_amount"]
|
||||
)
|
||||
|
||||
total_theoretical_value = 0
|
||||
|
||||
for opp in opportunities:
|
||||
probability = 0
|
||||
if opp.sales_stage:
|
||||
probability = frappe.db.get_value("Sales Stage", opp.sales_stage, "opportunity_probability") or 0
|
||||
|
||||
theoretical_value = (opp.base_opportunity_amount or 0) * (probability / 100)
|
||||
total_theoretical_value += theoretical_value
|
||||
|
||||
return {
|
||||
"value": round(total_theoretical_value, 2),
|
||||
"fieldtype": "Currency",
|
||||
"label": _("Theoretical Value (This Month)")
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
{
|
||||
"creation": "2020-07-20 20:17:15.922486",
|
||||
"docstatus": 0,
|
||||
"doctype": "Number Card",
|
||||
"document_type": "Opportunity",
|
||||
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
|
||||
"filters_json": "[[\"Opportunity\",\"status\",\"not in\",[\"Closed\",\"Lost\"],false]]",
|
||||
"function": "Sum",
|
||||
"method": "rangeldigital.rangel_digital.number_card.pipeline_value_(this_month).pipeline_value_(this_month).get_number_card_data",
|
||||
"idx": 0,
|
||||
"is_public": 1,
|
||||
"is_standard": 1,
|
||||
"label": "Pipeline Value (This Month)",
|
||||
"modified": "2025-06-19 12:15:53.088837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Pipeline Value (This Month)",
|
||||
"owner": "Administrator",
|
||||
"show_percentage_stats": 0,
|
||||
"stats_time_interval": "",
|
||||
"type": "Custom"
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from datetime import datetime
|
||||
from frappe.utils import get_first_day, get_last_day
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_number_card_data():
|
||||
# Get the first and last day of the current month
|
||||
today = datetime.today()
|
||||
first_day = get_first_day(today).strftime('%Y-%m-%d')
|
||||
last_day = get_last_day(today).strftime('%Y-%m-%d')
|
||||
|
||||
# Fetch open opportunities closing this month
|
||||
opportunities = frappe.db.get_all(
|
||||
"Opportunity",
|
||||
filters={
|
||||
"expected_closing": ["between", [first_day, last_day]],
|
||||
"status": ["not in", ["Closed", "Lost"]]
|
||||
},
|
||||
fields=["name", "sales_stage", "base_opportunity_amount"]
|
||||
)
|
||||
|
||||
total_theoretical_value = 0
|
||||
|
||||
for opp in opportunities:
|
||||
probability = 0
|
||||
if opp.sales_stage:
|
||||
probability = frappe.db.get_value("Sales Stage", opp.sales_stage, "opportunity_probability") or 0
|
||||
|
||||
theoretical_value = (opp.base_opportunity_amount or 0) * (probability / 100)
|
||||
total_theoretical_value += theoretical_value
|
||||
|
||||
return {
|
||||
"value": round(total_theoretical_value, 2),
|
||||
"fieldtype": "Currency",
|
||||
"label": _("Theoretical Value (This Month)")
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user