LP#1772955: Only include xacts with balance in summary
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.schema.open_with_balance_usr_summary.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
4
5 CREATE OR REPLACE VIEW money.open_with_balance_usr_summary AS
6     SELECT
7         usr,
8         sum(total_paid) AS total_paid,
9         sum(total_owed) AS total_owed,
10         sum(balance_owed) AS balance_owed
11     FROM money.materialized_billable_xact_summary
12     WHERE xact_finish IS NULL AND balance_owed <> 0.0
13     GROUP BY usr;
14
15 COMMIT;