roam/aweber/20220329103252-identifying_active_accounts.org
2022-03-30 09:52:04 -04:00

1.1 KiB

Identifying active accounts

A query to identify active accounts in AppDB

Per coreapi_account.get_account_status:

    CREATE FUNCTION coreapi_account.get_account_status(in_account_id integer) RETURNS coreapi_account.account_status
        LANGUAGE sql STRICT
        AS $_$

          SELECT accounts.status_id,
                 accounts.status_id = 7,
                 CASE accounts.status_id
                   WHEN 1 THEN 'New Order'
                   WHEN 4 THEN 'Unpaid - Un-notified'
                   WHEN 5 THEN 'Paid'
                   WHEN 6 THEN 'Unpaid - Notified'
                   WHEN 7 THEN 'Cancelled'
                   WHEN 8 THEN 'Unpaid - Overdue'
                   WHEN 9 THEN 'Place Holder'
                   ELSE 'Unknown'
                 END
            FROM public.accounts
           WHERE accounts.a_id = $1;