MJ-Prod commited on
Commit
6450c68
·
1 Parent(s): 22086a0

JWT-update_8

Browse files
Files changed (1) hide show
  1. plaid_client.py +11 -8
plaid_client.py CHANGED
@@ -37,29 +37,32 @@ plaid_client = _make_client()
37
  # ---------- Balances ----------
38
 
39
  def get_balances(access_token: str) -> str:
40
- """Returns formatted balance snapshot for the LLM prompt."""
41
  request = AccountsBalanceGetRequest(access_token=access_token)
42
  response = plaid_client.accounts_balance_get(request)
43
 
44
  lines = ["USER'S CURRENT ACCOUNT BALANCES:"]
45
  for account in response['accounts']:
46
- name = account['name']
47
- subtype = account['subtype'] # 'checking', 'credit card', etc.
48
- current = account['balances']['current']
49
-
 
 
 
50
  if subtype == 'credit card':
51
  limit = account['balances']['limit'] or 0
52
  available = account['balances']['available'] or (limit - current)
53
  lines.append(
54
- f"- {name} (Visa/Credit): "
55
  f"${current:.2f} owing, ${available:.2f} available"
56
  )
 
 
57
  else:
58
- lines.append(f"- {name} (Chequing): ${current:.2f}")
59
 
60
  return "\n".join(lines)
61
 
62
-
63
  # ---------- Transactions ----------
64
 
65
  def get_transactions(access_token: str, days: int = 30) -> str:
 
37
  # ---------- Balances ----------
38
 
39
  def get_balances(access_token: str) -> str:
 
40
  request = AccountsBalanceGetRequest(access_token=access_token)
41
  response = plaid_client.accounts_balance_get(request)
42
 
43
  lines = ["USER'S CURRENT ACCOUNT BALANCES:"]
44
  for account in response['accounts']:
45
+ name = account['name']
46
+ subtype = account['subtype']
47
+ current = account['balances']['current']
48
+
49
+ if current is None:
50
+ continue
51
+
52
  if subtype == 'credit card':
53
  limit = account['balances']['limit'] or 0
54
  available = account['balances']['available'] or (limit - current)
55
  lines.append(
56
+ f"- {name} (Credit Card): "
57
  f"${current:.2f} owing, ${available:.2f} available"
58
  )
59
+ elif subtype in ['mortgage', 'line of credit']:
60
+ lines.append(f"- {name} ({subtype}): ${current:.2f} outstanding")
61
  else:
62
+ lines.append(f"- {name} ({subtype}): ${current:.2f}")
63
 
64
  return "\n".join(lines)
65
 
 
66
  # ---------- Transactions ----------
67
 
68
  def get_transactions(access_token: str, days: int = 30) -> str: