1 -- Copyright 2015, Equinox Software, Inc.
2 -- Author: Galen Charlton <gmc@esilibrary.com>
4 -- This program is free software; you can redistribute it and/or
5 -- modify it under the terms of the GNU General Public License
6 -- as published by the Free Software Foundation; either version 2
7 -- of the License, or (at your option) any later version.
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program; if not, write to the Free Software
16 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 \set ou_to_del ''''EXAMPLE''''
22 ALTER TABLE money.cash_payment DISABLE TRIGGER mat_summary_del_tgr;
23 ALTER TABLE money.goods_payment DISABLE TRIGGER mat_summary_del_tgr;
24 ALTER TABLE money.credit_payment DISABLE TRIGGER mat_summary_del_tgr;
25 ALTER TABLE money.check_payment DISABLE TRIGGER mat_summary_del_tgr;
26 ALTER TABLE money.credit_card_payment DISABLE TRIGGER mat_summary_del_tgr;
27 ALTER TABLE money.forgive_payment DISABLE TRIGGER mat_summary_del_tgr;
28 ALTER TABLE money.payment DISABLE TRIGGER mat_summary_del_tgr;
29 ALTER TABLE money.billing DISABLE TRIGGER mat_summary_del_tgr;
30 ALTER TABLE money.grocery DISABLE TRIGGER mat_summary_remove_tgr;
34 DELETE FROM money.credit_payment
36 SELECT usr FROM money.billable_xact WHERE usr IN
37 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
40 DELETE FROM money.credit_card_payment
42 SELECT usr FROM money.billable_xact WHERE usr IN
43 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
46 DELETE FROM money.check_payment
48 SELECT usr FROM money.billable_xact WHERE usr IN
49 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
52 DELETE FROM money.cash_payment
54 SELECT usr FROM money.billable_xact WHERE usr IN
55 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
58 DELETE FROM money.goods_payment
60 SELECT usr FROM money.billable_xact WHERE usr IN
61 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
64 DELETE FROM money.work_payment
66 SELECT usr FROM money.billable_xact WHERE usr IN
67 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
70 DELETE FROM money.forgive_payment
72 SELECT usr FROM money.billable_xact WHERE usr IN
73 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
76 DELETE FROM money.bnm_desk_payment
78 SELECT usr FROM money.billable_xact WHERE usr IN
79 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
82 DELETE FROM money.payment
84 SELECT usr FROM money.billable_xact WHERE usr IN
85 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
88 DELETE FROM money.billing
90 SELECT usr FROM money.billable_xact WHERE usr IN
91 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del))
94 DELETE FROM money.grocery WHERE usr IN
95 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del));
97 DELETE FROM money.billable_xact WHERE usr IN
98 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del));
100 DELETE FROM money.materialized_billable_xact_summary WHERE usr IN
101 (SELECT id FROM actor.usr WHERE home_ou IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del));
104 ALTER TABLE money.cash_payment ENABLE TRIGGER mat_summary_del_tgr;
105 ALTER TABLE money.goods_payment ENABLE TRIGGER mat_summary_del_tgr;
106 ALTER TABLE money.credit_payment ENABLE TRIGGER mat_summary_del_tgr;
107 ALTER TABLE money.check_payment ENABLE TRIGGER mat_summary_del_tgr;
108 ALTER TABLE money.credit_card_payment ENABLE TRIGGER mat_summary_del_tgr;
109 ALTER TABLE money.forgive_payment ENABLE TRIGGER mat_summary_del_tgr;
110 ALTER TABLE money.payment ENABLE TRIGGER mat_summary_del_tgr;
111 ALTER TABLE money.billing ENABLE TRIGGER mat_summary_del_tgr;
112 ALTER TABLE money.grocery ENABLE TRIGGER mat_summary_remove_tgr;