Enhance Telegram bot UI with YTD comparison, 12-month evolution, and improved navigation
- Add YTD year-over-year comparison table for cash flow evolution - Extend monthly evolution from 6 to 12 months with dynamic year extraction - Simplify monthly view to show only Net values aligned with YTD table - Upgrade client/supplier display from Top 5 to Top 10 with alphabetical sorting - Remove Refresh and Export buttons from dashboard and evolution views - Add get_trends() API method for 12-month historical data from backend - Fix default years to 2025/2024 for accurate YTD calculations Changes: - client.py: New get_trends() method calls /api/dashboard/trends endpoint - helpers.py: Rewrite get_cashflow_evolution_data() to use trends and calculate YTD - formatters.py: Complete redesign with YTD table and simplified 12-month Net view - menus.py: Alphabetical sorting for clients/suppliers, removed refresh buttons - handlers.py: Disabled refresh/export buttons on dashboard and evolution views 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -332,14 +332,17 @@ def create_client_list_keyboard(clients: List[Dict], max_items: int = 10, page:
|
||||
"""
|
||||
keyboard = []
|
||||
|
||||
# Sort clients alphabetically by name
|
||||
sorted_clients = sorted(clients, key=lambda x: x.get('name', '').lower())
|
||||
|
||||
# Calculate pagination
|
||||
total_clients = len(clients)
|
||||
total_clients = len(sorted_clients)
|
||||
total_pages = (total_clients + max_items - 1) // max_items # Ceiling division
|
||||
start_idx = page * max_items
|
||||
end_idx = min(start_idx + max_items, total_clients)
|
||||
|
||||
# Display clients for current page
|
||||
display_clients = clients[start_idx:end_idx]
|
||||
display_clients = sorted_clients[start_idx:end_idx]
|
||||
|
||||
# Add client buttons (1 per row)
|
||||
for client in display_clients:
|
||||
@@ -385,10 +388,9 @@ def create_client_list_keyboard(clients: List[Dict], max_items: int = 10, page:
|
||||
|
||||
keyboard.append(nav_buttons)
|
||||
|
||||
# Navigation row: Back and Refresh (2 buttons per row)
|
||||
# Navigation row: Back button only
|
||||
keyboard.append([
|
||||
InlineKeyboardButton("< Înapoi", callback_data="action:menu"),
|
||||
InlineKeyboardButton("Refresh", callback_data="action:refresh:clienti")
|
||||
InlineKeyboardButton("< Înapoi", callback_data="action:menu")
|
||||
])
|
||||
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
@@ -410,14 +412,17 @@ def create_supplier_list_keyboard(suppliers: List[Dict], max_items: int = 10, pa
|
||||
"""
|
||||
keyboard = []
|
||||
|
||||
# Sort suppliers alphabetically by name
|
||||
sorted_suppliers = sorted(suppliers, key=lambda x: x.get('name', '').lower())
|
||||
|
||||
# Calculate pagination
|
||||
total_suppliers = len(suppliers)
|
||||
total_suppliers = len(sorted_suppliers)
|
||||
total_pages = (total_suppliers + max_items - 1) // max_items # Ceiling division
|
||||
start_idx = page * max_items
|
||||
end_idx = min(start_idx + max_items, total_suppliers)
|
||||
|
||||
# Display suppliers for current page
|
||||
display_suppliers = suppliers[start_idx:end_idx]
|
||||
display_suppliers = sorted_suppliers[start_idx:end_idx]
|
||||
|
||||
# Add supplier buttons (1 per row)
|
||||
for supplier in display_suppliers:
|
||||
@@ -463,10 +468,9 @@ def create_supplier_list_keyboard(suppliers: List[Dict], max_items: int = 10, pa
|
||||
|
||||
keyboard.append(nav_buttons)
|
||||
|
||||
# Navigation row: Back and Refresh (2 buttons per row)
|
||||
# Navigation row: Back button only
|
||||
keyboard.append([
|
||||
InlineKeyboardButton("< Înapoi", callback_data="action:menu"),
|
||||
InlineKeyboardButton("Refresh", callback_data="action:refresh:furnizori")
|
||||
InlineKeyboardButton("< Înapoi", callback_data="action:menu")
|
||||
])
|
||||
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
|
||||
Reference in New Issue
Block a user