]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.data.conditional_negative_balance.sql
1d03ec9881c665903f9da009a254bc616043cd80
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.data.conditional_negative_balance.sql
1 BEGIN;
2
3 -- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
4
5 CREATE TABLE money.adjustment_payment (
6     billing BIGINT REFERENCES money.billing (id) ON DELETE SET NULL
7 ) INHERITS (money.bnm_payment);
8 ALTER TABLE money.adjustment_payment ADD PRIMARY KEY (id);
9 CREATE INDEX money_adjustment_id_idx ON money.adjustment_payment (id);
10 CREATE INDEX money_adjustment_payment_xact_idx ON money.adjustment_payment (xact);
11 CREATE INDEX money_adjustment_payment_bill_idx ON money.adjustment_payment (billing);
12 CREATE INDEX money_adjustment_payment_payment_ts_idx ON money.adjustment_payment (payment_ts);
13 CREATE INDEX money_adjustment_payment_accepting_usr_idx ON money.adjustment_payment (accepting_usr);
14
15 CREATE TRIGGER mat_summary_add_tgr AFTER INSERT ON money.adjustment_payment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_add ('adjustment_payment');
16 CREATE TRIGGER mat_summary_upd_tgr AFTER UPDATE ON money.adjustment_payment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_update ('adjustment_payment');
17 CREATE TRIGGER mat_summary_del_tgr BEFORE DELETE ON money.adjustment_payment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_del ('adjustment_payment');
18
19 -- Insert new org. unit settings.
20 INSERT INTO config.org_unit_setting_type 
21        (name, grp, datatype, label, description)
22 VALUES
23        ('bill.prohibit_negative_balance_default',
24         'finance', 'bool',
25         oils_i18n_gettext(
26             'bill.prohibit_negative_balance_default',
27             'Prohibit negative balance on bills (DEFAULT)',
28             'coust', 'label'),
29         oils_i18n_gettext(
30             'bill.prohibit_negative_balance_default',
31             'Default setting to prevent credits on circulation related bills',
32             'coust', 'description')
33        ),
34        ('bill.prohibit_negative_balance_on_overdues',
35         'finance', 'bool',
36         oils_i18n_gettext(
37             'bill.prohibit_negative_balance_on_overdues',
38             'Prohibit negative balance on bills for overdue materials',
39             'coust', 'label'),
40         oils_i18n_gettext(
41             'bill.prohibit_negative_balance_on_overdues',
42             'Prevent credits on bills for overdue materials',
43             'coust', 'description')
44        ),
45        ('bill.prohibit_negative_balance_on_lost',
46         'finance', 'bool',
47         oils_i18n_gettext(
48             'bill.prohibit_negative_balance_on_lost',
49             'Prohibit negative balance on bills for lost materials',
50             'coust', 'label'),
51         oils_i18n_gettext(
52             'bill.prohibit_negative_balance_on_lost',
53             'Prevent credits on bills for lost/long-overde materials',
54             'coust', 'description')
55        ),
56        ('bill.negative_balance_interval_default',
57         'finance', 'interval',
58         oils_i18n_gettext(
59             'bill.negative_balance_interval_default',
60             'Negative Balance Interval (DEFAULT)',
61             'coust', 'label'),
62         oils_i18n_gettext(
63             'bill.negative_balance_interval_default',
64             'Amount of time after which no negative balances or credits are allowed on circulation bills',
65             'coust', 'description')
66        ),
67        ('bill.negative_balance_interval_on_overdues',
68         'finance', 'interval',
69         oils_i18n_gettext(
70             'bill.negative_balance_interval_on_overdues',
71             'Negative Balance Interval for Overdues',
72             'coust', 'label'),
73         oils_i18n_gettext(
74             'bill.negative_balance_interval_on_overdues',
75             'Amount of time after which no negative balances or credits are allowed on bills for overdue materials',
76             'coust', 'description')
77        ),
78        ('bill.negative_balance_interval_on_lost',
79         'finance', 'interval',
80         oils_i18n_gettext(
81             'bill.negative_balance_interval_on_lost',
82             'Negative Balance Interval for Lost',
83             'coust', 'label'),
84         oils_i18n_gettext(
85             'bill.negative_balance_interval_on_lost',
86             'Amount of time after which no negative balances or credits are allowed on bills for lost/long overdue materials',
87             'coust', 'description')
88        );
89
90 COMMIT;