Documentation

api.users.spending_accounts

Fetch the spending accounts available to a user at the current site by their user_id. Includes site accounts, shared accounts linked through user groups, and portal accounts for portals linked to the site.

Arguments:

def api.users.spending_accounts(
  user_id: str, # Required User ID
):

Returns a list of dict in the form:

[
  {
    'account_id': <str>,
    'balance': <dec>,       # Balance in currency units, e.g. 42.50
    'balance_int': <dec>,   # Balance in cents, e.g. 4250
    'portal_id': <None | str>,
    'site_id': <None | str>,
  },
  ...
]

Both balance fields are decimals and can be compared directly with Sneq number literals. Site accounts have a site_id; portal accounts have a portal_id.

Returns an empty list when no eligible accounts are found, the user is unknown or blocked, or the user has never belonged to the site. Former site members are included. Closed accounts and accounts outside their active period are excluded.

Balances currently reflect the cached total for the active account period, including future-dated transactions. They may therefore differ from the amount available for immediate payment.

Example:

accounts = api.users.spending_accounts(user_id="foo") # accounts = [ <dict> ]