From 7d9fc8447f2abc8e538a5ad7d57790a772a763f5 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sat, 24 Oct 2026 09:39:45 +0330 Subject: [PATCH] fix(reports): show Tahesab sales link only when connection exists Require both the tahesab org module and at least one enabled accounting connection. --- apps/web/src/views/ReportsView.vue | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/web/src/views/ReportsView.vue b/apps/web/src/views/ReportsView.vue index f020009..9e2bc96 100644 --- a/apps/web/src/views/ReportsView.vue +++ b/apps/web/src/views/ReportsView.vue @@ -38,6 +38,7 @@ import type { ReportsPeriodCompareRowDto, ReportsViewFilters, SavedViewDto, + TahesabConnectionDto, TeamDto, } from '@mento/shared'; import { @@ -107,6 +108,14 @@ const builderResult = ref(null); const orgUsers = ref([]); const orgTeams = ref([]); const teamsAvailable = ref(true); +/** ماژول ته‌حساب فعال + حداقل یک اتصال تنظیم‌شده */ +const hasTahesabSetup = ref(false); + +const showTahesabSalesReport = computed( + () => + Boolean(auth.user?.enabledModules?.includes('tahesab')) && + hasTahesabSetup.value, +); const currency = computed( () => @@ -597,8 +606,27 @@ async function copyShareLink() { } } +async function loadTahesabSetup() { + if (!auth.user?.enabledModules?.includes('tahesab')) { + hasTahesabSetup.value = false; + return; + } + try { + const { data } = await api.get( + '/integrations/tahesab/connections/public', + ); + hasTahesabSetup.value = (data ?? []).some((c) => c.enabled); + } catch { + hasTahesabSetup.value = false; + } +} + async function bootstrap() { - await Promise.all([loadSavedViews(), loadFilterOptions()]); + await Promise.all([ + loadSavedViews(), + loadFilterOptions(), + loadTahesabSetup(), + ]); const viewId = typeof route.query.view === 'string' ? route.query.view.trim() : ''; if (viewId) { @@ -1140,7 +1168,7 @@ const activityMax = computed(() => >