feat(telegram): Unify Trezorerie button (Casa + Banca combined)

- Replace separate [Trezorerie Casa] and [Trezorerie Banca] buttons
  with single unified [Trezorerie] button in main menu
- Add format_treasury_combined_response() formatter showing:
  - Grand total (Sold Trezorerie)
  - Casa section with total + all accounts
  - Banca section with total + all accounts
- Compact menu layout: Row 2 [Sold Companie][Trezorerie],
  Row 3 [Sold Clienti][Sold Furnizori], Row 4 [Evolutie Incasari]
- Use Romanian number format (period as thousands separator)

Also includes:
- Oracle pool: Support both SERVICE_NAME and SID connections
  (ORACLE_SERVICE_NAME takes priority over ORACLE_SID)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 19:15:05 +02:00
parent ab160b628d
commit 4a886f0b64
9 changed files with 843 additions and 19 deletions

View File

@@ -187,6 +187,61 @@ def format_treasury_banca_response(data: Dict[str, Any], company_name: str = Non
return text
def format_treasury_combined_response(data: Dict[str, Any], company_name: str = None) -> str:
"""
Format combined treasury data (Casa + Banca) for Telegram.
Shows grand total, Casa section with accounts, and Banca section with accounts
in a single unified message. Compact format without section titles.
Args:
data: Dict with 'casa' and 'banca' keys from get_treasury_breakdown_split()
company_name: Company name (kept for compatibility, not used)
Returns:
Formatted Markdown string with grand total and both sections
Example:
data = {'casa': {...}, 'banca': {...}}
text = format_treasury_combined_response(data)
"""
def format_amount(amount: int) -> str:
"""Format amount with period as thousands separator (Romanian style)."""
return f"{amount:,}".replace(",", ".")
text = ""
# Extract totals - rounded to whole RON
casa_total = round(data.get('casa', {}).get('total', 0))
banca_total = round(data.get('banca', {}).get('total', 0))
grand_total = casa_total + banca_total
# Grand total header
text += f"**Sold Trezorerie:** {format_amount(grand_total)} RON\n\n"
# Casa section - compact
text += f"**Casa:** {format_amount(casa_total)} RON\n"
casa_accounts = data.get('casa', {}).get('accounts', [])
if casa_accounts:
for acc in casa_accounts:
name = acc.get('name', 'N/A')
balance = round(acc.get('balance', 0))
text += f" - {name}: {format_amount(balance)} RON\n"
text += "\n"
# Banca section - compact
text += f"**Banca:** {format_amount(banca_total)} RON\n"
banca_accounts = data.get('banca', {}).get('accounts', [])
if banca_accounts:
for acc in banca_accounts:
name = acc.get('name', 'N/A')
balance = round(acc.get('balance', 0))
text += f" - {name}: {format_amount(balance)} RON\n"
return text
def format_clients_balance_response(
clients: List[Dict[str, Any]],
maturity_data: Dict[str, Any],