#!/usr/bin/env bash
# List the sandbox bank accounts (id + label) so a payment can pick its account_id.
# Read-only; needs the ai_agent_sandbox user to hold `banque lire` (rights id 111).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
W="${DOL_WRITE:-${SCRIPT_DIR}/dol-write.sh}"
"${W}" GET "/bankaccounts" | python3 -c "import json,sys
d = json.load(sys.stdin); rows = d if isinstance(d, list) else []
if not rows:
    print('(no bank accounts defined)'); sys.exit(0)
print('%-4s %-34s %-10s %s' % ('id', 'label', 'bank', 'currency'))
for a in rows:
    print('%-4s %-34s %-10s %s' % (a.get('id'), (a.get('label') or '')[:34],
          a.get('bank') or '', a.get('currency_code') or ''))"
