otals[exp.category] = (categoryTotals[exp.category] || 0) + amount;
                    totalAmount += amount;
                }
            });
            return Object.entries(categoryTotals)
                .map(([category, total]) => ({
                    category,
                    total,
                    percentage: totalAmount > 0 ? (total / totalAmount) * 100 : 0
                }))
                .sort((a, b) => b.total - a.total);
        }

        function calculateIncome(expenses) {
   