AnonymousSpottedToad/securityPatternsRecovery / codebase /repos /python /elisiariocouto_leggen /leggen /commands /balances.py
| import click | |
| from leggen.api_client import LeggenAPIClient | |
| from leggen.main import cli | |
| from leggen.utils.text import datefmt, print_table | |
| def balances(ctx: click.Context): | |
| """ | |
| List balances of all connected accounts | |
| """ | |
| api_client = LeggenAPIClient.from_context(ctx) | |
| accounts = api_client.get_accounts() | |
| all_balances = [] | |
| for account in accounts: | |
| for balance in account.get("balances", []): | |
| amount = round(float(balance["amount"]), 2) | |
| symbol = "€" if balance["currency"] == "EUR" else f" {balance['currency']}" | |
| amount_str = f"{amount}{symbol}" | |
| date = ( | |
| datefmt(balance.get("last_change_date")) | |
| if balance.get("last_change_date") | |
| else "" | |
| ) | |
| all_balances.append( | |
| { | |
| "Account": account["id"], | |
| "Amount": amount_str, | |
| "Type": balance["balance_type"], | |
| "Last change at": date, | |
| } | |
| ) | |
| print_table(all_balances) | |
Xet Storage Details
- Size:
- 1.12 kB
- Xet hash:
- 99f3cbce87f2ea75888abda6a3a5fad8d3b4738384643755f574ddc0be5a1b24
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.