diff --git a/app/transactions/page.tsx b/app/transactions/page.tsx index 6b43d23..5b44999 100644 --- a/app/transactions/page.tsx +++ b/app/transactions/page.tsx @@ -2,7 +2,15 @@ import { useCallback, useMemo } from "react"; import { PageLayout, PageHeader } from "@/components/layout"; -import { RefreshCw, Receipt, Euro, ChevronDown, ChevronUp } from "lucide-react"; +import { + RefreshCw, + Receipt, + Euro, + ChevronDown, + ChevronUp, + CheckCircle2, + Tag, +} from "lucide-react"; import { TransactionFilters, TransactionBulkActions, @@ -105,6 +113,7 @@ export default function TransactionsPage() { isLoading: isLoadingChart, totalAmount: chartTotalAmount, totalCount: chartTotalCount, + transactions: chartTransactions, } = useTransactionsChartData({ selectedAccounts, selectedCategories, @@ -175,6 +184,23 @@ export default function TransactionsPage() { const totalAmount = chartTotalAmount ?? 0; const displayTotalCount = chartTotalCount ?? totalTransactions; + // Calculate percentages from chart transactions (all filtered transactions) + const reconciledPercent = useMemo(() => { + if (chartTransactions.length === 0) return "0.00"; + const reconciledCount = chartTransactions.filter( + (t) => t.isReconciled + ).length; + return ((reconciledCount / chartTransactions.length) * 100).toFixed(2); + }, [chartTransactions]); + + const categorizedPercent = useMemo(() => { + if (chartTransactions.length === 0) return "0.00"; + const categorizedCount = chartTransactions.filter( + (t) => t.categoryId !== null + ).length; + return ((categorizedCount / chartTransactions.length) * 100).toFixed(2); + }, [chartTransactions]); + // Persist statistics collapsed state in localStorage const [isStatsExpanded, setIsStatsExpanded] = useLocalStorage( "transactions-stats-expanded", @@ -271,7 +297,7 @@ export default function TransactionsPage() { {/* Summary cards */} {!isLoadingTransactions && ( - + @@ -283,7 +309,10 @@ export default function TransactionsPage() { {displayTotalCount} - + @@ -304,7 +333,49 @@ export default function TransactionsPage() { {formatCurrency(totalAmount)} - + = 0 + ? "text-emerald-600" + : "text-red-600" + }`} + /> + + + + + + + + + Pointé + + + {reconciledPercent}% + + + + + + + + + + + + Catégorisé + + + {categorizedPercent}% + + + diff --git a/components/dashboard/overview-cards.tsx b/components/dashboard/overview-cards.tsx index 58b9b69..f6620b4 100644 --- a/components/dashboard/overview-cards.tsx +++ b/components/dashboard/overview-cards.tsx @@ -41,13 +41,13 @@ export function OverviewCards({ data }: OverviewCardsProps) { const reconciled = data.transactions.filter((t) => t.isReconciled).length; const total = data.transactions.length; const reconciledPercent = - total > 0 ? Math.round((reconciled / total) * 100) : 0; + total > 0 ? ((reconciled / total) * 100).toFixed(2) : "0.00"; const categorized = data.transactions.filter( (t) => t.categoryId !== null ).length; const categorizedPercent = - total > 0 ? Math.round((categorized / total) * 100) : 0; + total > 0 ? ((categorized / total) * 100).toFixed(2) : "0.00"; const formatCurrency = (amount: number) => { return new Intl.NumberFormat("fr-FR", { diff --git a/hooks/use-transactions-chart-data.ts b/hooks/use-transactions-chart-data.ts index f5892e0..d49bbf4 100644 --- a/hooks/use-transactions-chart-data.ts +++ b/hooks/use-transactions-chart-data.ts @@ -220,6 +220,7 @@ export function useTransactionsChartData({ isLoading, totalAmount, totalCount, + transactions: transactionsData?.transactions || [], }; }
+ Pointé +
+ {reconciledPercent}% +
+ Catégorisé +
+ {categorizedPercent}% +