Buckets:

download
raw
2.92 kB
import click
from leggen.api_client import LeggenAPIClient
from leggen.main import cli
from leggen.utils.text import datefmt, info, print_table
@cli.command()
@click.option("-a", "--account", type=str, help="Account ID")
@click.option(
"-l", "--limit", type=int, default=50, help="Number of transactions to show"
)
@click.option("--full", is_flag=True, help="Show full transaction details")
@click.pass_context
def transactions(ctx: click.Context, account: str, limit: int, full: bool):
"""
List transactions
By default, this command lists all transactions for all accounts.
If the --account option is used, it will only list transactions for that account.
"""
api_client = LeggenAPIClient.from_context(ctx)
if account:
# Get account details for display
accounts = api_client.get_accounts()
account_details = next((a for a in accounts if a["id"] == account), None)
if account_details:
info(f"Bank: {account_details['institution_id']}")
info(f"IBAN: {account_details.get('iban', 'N/A')}")
# Get transactions (with optional account filter)
transactions_data = api_client.get_all_transactions(
limit=limit, summary_only=not full, account_id=account
)
# Format transactions for display
if full:
# Full transaction details
formatted_transactions = []
for txn in transactions_data:
# Handle optional internal_transaction_id
txn_id = txn.get("internal_transaction_id")
txn_id_display = txn_id[:12] + "..." if txn_id else "N/A"
formatted_transactions.append(
{
"ID": txn_id_display,
"Date": datefmt(txn["transaction_date"]),
"Description": txn["description"][:50] + "..."
if len(txn["description"]) > 50
else txn["description"],
"Amount": f"{txn['transaction_value']:.2f} {txn['transaction_currency']}",
"Status": txn["transaction_status"].upper(),
"Account": txn["account_id"][:8] + "...",
}
)
else:
# Summary view
formatted_transactions = []
for txn in transactions_data:
formatted_transactions.append(
{
"Date": datefmt(txn["date"]),
"Description": txn["description"][:60] + "..."
if len(txn["description"]) > 60
else txn["description"],
"Amount": f"{txn['amount']:.2f} {txn['currency']}",
"Status": txn["status"].upper(),
}
)
if formatted_transactions:
print_table(formatted_transactions)
info(f"Showing {len(formatted_transactions)} transactions")
else:
info("No transactions found")

Xet Storage Details

Size:
2.92 kB
·
Xet hash:
7d813c1548c79aa065457c771421e9be7204da0638bf548ee179be98166c827c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.