Skip to content

Instantly share code, notes, and snippets.

@jeff
Created February 10, 2015 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeff/6cb257edf299fb5b6810 to your computer and use it in GitHub Desktop.
Save jeff/6cb257edf299fb5b6810 to your computer and use it in GitHub Desktop.
-- Find transactions that are closed but have a non-zero balance
-- makes the (usually safe) assumption that the mmbxs materialized view data is correct
-- change the org unit id as needed to narrow your focus
SELECT COUNT(*)
FROM money.materialized_billable_xact_summary mmbxs
JOIN actor.usr au ON (au.id = mmbxs.usr)
WHERE xact_finish IS NOT NULL
AND balance_owed <> 0
AND au.home_ou IN (SELECT id FROM actor.org_unit_descendants(1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment