fix: added deals by ongoing & won stages bar

This commit is contained in:
Shariq Ansari 2025-07-13 12:35:16 +05:30
parent f82019e510
commit de85ccfc51
2 changed files with 45 additions and 25 deletions

View File

@ -734,8 +734,10 @@ def get_deals_by_stage(from_date="", to_date="", user="", deal_conds=""):
f""" f"""
SELECT SELECT
d.status AS stage, d.status AS stage,
COUNT(*) AS count COUNT(*) AS count,
s.type AS status_type
FROM `tabCRM Deal` AS d FROM `tabCRM Deal` AS d
JOIN `tabCRM Deal Status` s ON d.status = s.name
WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s WHERE DATE(d.creation) BETWEEN %(from)s AND %(to)s
{deal_conds} {deal_conds}
GROUP BY d.status GROUP BY d.status

View File

@ -59,7 +59,7 @@
doctype="User" doctype="User"
:filters="{ name: ['in', users.data.crmUsers?.map((u) => u.name)] }" :filters="{ name: ['in', users.data.crmUsers?.map((u) => u.name)] }"
@change="(v) => updateFilter('user', v)" @change="(v) => updateFilter('user', v)"
:placeholder="__('Sales User')" :placeholder="__('Sales user')"
:hideMe="true" :hideMe="true"
> >
<template #prefix> <template #prefix>
@ -110,8 +110,14 @@
<div v-if="funnelConversion.data" class="border rounded-md min-h-80"> <div v-if="funnelConversion.data" class="border rounded-md min-h-80">
<AxisChart :config="funnelConversion.data" /> <AxisChart :config="funnelConversion.data" />
</div> </div>
<div v-if="lostDealReasons.data" class="border rounded-md"> <div v-if="dealsByStage.data" class="border rounded-md">
<AxisChart :config="lostDealReasons.data" /> <AxisChart :config="dealsByStage.data.bar" />
</div>
<div v-if="dealsByStage.data" class="border rounded-md">
<DonutChart :config="dealsByStage.data.donut" />
</div>
<div v-if="leadsBySource.data" class="border rounded-md">
<DonutChart :config="leadsBySource.data" />
</div> </div>
<div v-if="dealsByTerritory.data" class="border rounded-md"> <div v-if="dealsByTerritory.data" class="border rounded-md">
<AxisChart :config="dealsByTerritory.data" /> <AxisChart :config="dealsByTerritory.data" />
@ -119,11 +125,8 @@
<div v-if="dealsBySalesperson.data" class="border rounded-md"> <div v-if="dealsBySalesperson.data" class="border rounded-md">
<AxisChart :config="dealsBySalesperson.data" /> <AxisChart :config="dealsBySalesperson.data" />
</div> </div>
<div v-if="dealsByStage.data" class="border rounded-md"> <div v-if="lostDealReasons.data" class="border rounded-md">
<DonutChart :config="dealsByStage.data" /> <AxisChart :config="lostDealReasons.data" />
</div>
<div v-if="leadsBySource.data" class="border rounded-md">
<DonutChart :config="leadsBySource.data" />
</div> </div>
</div> </div>
</div> </div>
@ -266,7 +269,7 @@ const salesTrend = createResource({
transform(data = []) { transform(data = []) {
return { return {
data: data, data: data,
title: __('Sales Trend'), title: __('Sales trend'),
subtitle: __('Daily performance of leads, deals, and wins'), subtitle: __('Daily performance of leads, deals, and wins'),
xAxis: { xAxis: {
title: __('Date'), title: __('Date'),
@ -300,7 +303,7 @@ const funnelConversion = createResource({
transform(data = []) { transform(data = []) {
return { return {
data: data, data: data,
title: __('Funnel Conversion'), title: __('Funnel conversion'),
subtitle: __('Lead to deal conversion pipeline'), subtitle: __('Lead to deal conversion pipeline'),
xAxis: { xAxis: {
title: __('Stage'), title: __('Stage'),
@ -338,7 +341,7 @@ const dealsBySalesperson = createResource({
transform(r = { data: [], currency_symbol: '$' }) { transform(r = { data: [], currency_symbol: '$' }) {
return { return {
data: r.data || [], data: r.data || [],
title: __('Deals by Salesperson'), title: __('Deals by salesperson'),
subtitle: __('Number of deals and total value per salesperson'), subtitle: __('Number of deals and total value per salesperson'),
xAxis: { xAxis: {
title: __('Salesperson'), title: __('Salesperson'),
@ -346,10 +349,10 @@ const dealsBySalesperson = createResource({
type: 'category' as const, type: 'category' as const,
}, },
yAxis: { yAxis: {
title: __('Number of Deals'), title: __('Number of deals'),
}, },
y2Axis: { y2Axis: {
title: __('Deal Value') + ` (${r.currency_symbol})`, title: __('Deal value') + ` (${r.currency_symbol})`,
}, },
series: [ series: [
{ name: 'deals', type: 'bar' as const }, { name: 'deals', type: 'bar' as const },
@ -378,7 +381,7 @@ const dealsByTerritory = createResource({
transform(r = { data: [], currency_symbol: '$' }) { transform(r = { data: [], currency_symbol: '$' }) {
return { return {
data: r.data || [], data: r.data || [],
title: __('Deals by Territory'), title: __('Deals by territory'),
subtitle: __('Geographic distribution of deals and revenue'), subtitle: __('Geographic distribution of deals and revenue'),
xAxis: { xAxis: {
title: __('Territory'), title: __('Territory'),
@ -386,10 +389,10 @@ const dealsByTerritory = createResource({
type: 'category' as const, type: 'category' as const,
}, },
yAxis: { yAxis: {
title: __('Number of Deals'), title: __('Number of deals'),
}, },
y2Axis: { y2Axis: {
title: __('Deal Value') + ` (${r.currency_symbol})`, title: __('Deal value') + ` (${r.currency_symbol})`,
}, },
series: [ series: [
{ name: 'deals', type: 'bar' as const }, { name: 'deals', type: 'bar' as const },
@ -418,7 +421,7 @@ const lostDealReasons = createResource({
transform(data = []) { transform(data = []) {
return { return {
data: data, data: data,
title: __('Lost Deal Reasons'), title: __('Lost deal reasons'),
subtitle: __('Common reasons for losing deals'), subtitle: __('Common reasons for losing deals'),
xAxis: { xAxis: {
title: __('Reason'), title: __('Reason'),
@ -444,7 +447,7 @@ const forecastedRevenue = createResource({
transform(r = { data: [], currency_symbol: '$' }) { transform(r = { data: [], currency_symbol: '$' }) {
return { return {
data: r.data || [], data: r.data || [],
title: __('Revenue Forecast'), title: __('Revenue forecast'),
subtitle: __('Projected vs actual revenue based on deal probability'), subtitle: __('Projected vs actual revenue based on deal probability'),
xAxis: { xAxis: {
title: __('Month'), title: __('Month'),
@ -476,11 +479,26 @@ const dealsByStage = createResource({
auto: true, auto: true,
transform(data = []) { transform(data = []) {
return { return {
data: data, donut: {
title: __('Deals by Stage'), data: data,
subtitle: __('Current pipeline distribution'), title: __('Deals by stage'),
categoryColumn: 'stage', subtitle: __('Current pipeline distribution'),
valueColumn: 'count', categoryColumn: 'stage',
valueColumn: 'count',
},
bar: {
data: data.filter((d) => d.status_type != 'Lost'),
title: __('Deals by ongoing & won stage'),
xAxis: {
title: __('Stage'),
key: 'stage',
type: 'category' as const,
},
yAxis: {
title: __('Count'),
},
series: [{ name: 'count', type: 'bar' as const }],
},
} }
}, },
}) })
@ -499,7 +517,7 @@ const leadsBySource = createResource({
transform(data = []) { transform(data = []) {
return { return {
data: data, data: data,
title: __('Leads by Source'), title: __('Leads by source'),
subtitle: __('Lead generation channel analysis'), subtitle: __('Lead generation channel analysis'),
categoryColumn: 'source', categoryColumn: 'source',
valueColumn: 'count', valueColumn: 'count',