fix: show avg time number card based on closed_on date

(cherry picked from commit eddf8c9295d39a8c41db7ad67ef4fc2dd5ad671b)
This commit is contained in:
Shariq Ansari 2025-07-07 14:30:29 +05:30 committed by Mergify
parent 6ae7787811
commit 10cf868df5
2 changed files with 7 additions and 9 deletions

View File

@ -274,9 +274,9 @@ def get_average_time_to_close(from_date, to_date, conds="", return_result=False)
result = frappe.db.sql(
f"""
SELECT
AVG(CASE WHEN d.creation >= %(from_date)s AND d.creation < DATE_ADD(%(to_date)s, INTERVAL 1 DAY)
AVG(CASE WHEN d.closed_on >= %(from_date)s AND d.closed_on < DATE_ADD(%(to_date)s, INTERVAL 1 DAY)
THEN TIMESTAMPDIFF(DAY, COALESCE(l.creation, d.creation), d.closed_on) END) as current_avg,
AVG(CASE WHEN d.creation >= %(prev_from_date)s AND d.creation < %(prev_to_date)s
AVG(CASE WHEN d.closed_on >= %(prev_from_date)s AND d.closed_on < %(prev_to_date)s
THEN TIMESTAMPDIFF(DAY, COALESCE(l.creation, d.creation), d.closed_on) END) as prev_avg
FROM `tabCRM Deal` d
LEFT JOIN `tabCRM Lead` l ON d.lead = l.name

View File

@ -8,13 +8,6 @@
</div>
<div class="flex-1 overflow-y-auto">
<div class="mb-3 flex flex-col">
<SidebarLink
:label="__('Dashboard')"
:icon="LucideLayoutDashboard"
:to="'Dashboard'"
:isCollapsed="isSidebarCollapsed"
class="mx-2 my-0.5"
/>
<SidebarLink
id="notifications-btn"
:label="__('Notifications')"
@ -205,6 +198,11 @@ const isFCSite = ref(window.is_fc_site)
const isDemoSite = ref(window.is_demo_site)
const links = [
{
label: 'Dashboard',
icon: LucideLayoutDashboard,
to: 'Dashboard',
},
{
label: 'Leads',
icon: LeadsIcon,