As a side effect of discovering that users with no cards were being retrieved
as part of the Collections API calls, those users ended up being mostly
made up of deleted users (merged with an actual lead record, etc.)
This patch contribued by Bill Ott changes the retrieval so that it skips
over those deleted users.
Signed-off-by: Bill Ott <bott@grpl.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
group by 1,2
) full_list
left join money.payment p on (full_list.id = p.xact)
+ left join actor.usr au on (au.id = usr)
+ where au.deleted is false
group by 1
having SUM(total_billing) - SUM(COALESCE(p.amount,0)) > ?
;