]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.data.long-overdue.sql
LP 1169193 long-overdue SQL seed data
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.data.long-overdue.sql
1 BEGIN;
2
3 -- NOTE: very IDs are still correct for perms and event_def data at merge.
4
5 -- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
6
7 -- copy status
8
9 INSERT INTO config.copy_status
10     (id, name, holdable, opac_visible, copy_active, restrict_copy_delete)
11     VALUES (16, oils_i18n_gettext(16, 'Long Overdue', 'ccs', 'name'), 'f', 'f', 'f', 't');
12
13 -- checkin override perm
14
15 INSERT INTO permission.perm_list (id, code, description) VALUES (
16     549, -- VERIFY
17     'COPY_STATUS_LONGOVERDUE.override',
18     oils_i18n_gettext(
19         549, -- VERIFY
20         'Allows the user to check-in long-overdue items, prompting ' ||
21             'long-overdue check-in processing',
22         'ppl',
23         'code'
24     )
25 ), (
26     550, -- VERIFY
27     'SET_CIRC_LONG_OVERDUE',
28     oils_i18n_gettext(
29         550, -- VERIFY
30         'Allows the user to mark a circulation as long-overdue',
31         'ppl',
32         'code'
33     )
34 );
35
36 -- billing types
37
38 INSERT INTO config.billing_type (id, owner, name) VALUES
39     (10, 1, oils_i18n_gettext(
40         10, 'Long-Overdue Materials', 'cbt', 'name')),
41     (11, 1, oils_i18n_gettext(
42         11, 'Long-Overdue Materials Processing Fee', 'cbt', 'name'));
43
44 -- org settings
45
46 INSERT INTO config.org_unit_setting_type 
47     (name, grp, datatype, label, description) VALUES 
48 (
49     'circ.longoverdue_immediately_available',
50     'circ', 'bool',
51     oils_i18n_gettext(
52         'circ.longoverdue_immediately_available',
53         'Long-Overdue Items Usable on Checkin',
54         'coust',
55         'label'
56     ),
57     oils_i18n_gettext(
58         'circ.longoverdue_immediately_available',
59         'Long-overdue items are usable on checkin instead of going "home" first',
60         'coust',
61         'description'
62     )
63 ), (
64     'circ.longoverdue_materials_processing_fee',
65     'finance', 'currency',
66     oils_i18n_gettext(
67         'circ.longoverdue_materials_processing_fee',
68         'Long-Overdue Materials Processing Fee',
69         'coust',
70         'label'
71     ),
72     oils_i18n_gettext(
73         'circ.longoverdue_materials_processing_fee',
74         'Long-Overdue Materials Processing Fee',
75         'coust',
76         'description'
77     )
78 ), (
79     'circ.max_accept_return_of_longoverdue',
80     'circ', 'interval',
81     oils_i18n_gettext(
82         'circ.max_accept_return_of_longoverdue',
83         'Long-Overdue Max Return Interval',
84         'coust',
85         'label'
86     ),
87     oils_i18n_gettext(
88         'circ.max_accept_return_of_longoverdue',
89         'Long-overdue check-in processing (voiding fees, re-instating ' ||
90             'overdues, etc.) will not take place for items that have been ' ||
91             'overdue for (or have last activity older than) this amount of time',
92         'coust',
93         'description'
94     )
95 ), (
96     'circ.restore_overdue_on_longoverdue_return',
97     'circ', 'bool',
98     oils_i18n_gettext(
99         'circ.restore_overdue_on_longoverdue_return',
100         'Restore Overdues on Long-Overdue Item Return',
101         'coust',
102         'label'
103     ),
104     oils_i18n_gettext(
105         'circ.restore_overdue_on_longoverdue_return',
106         'Restore Overdues on Long-Overdue Item Return',
107         'coust',
108         'description'
109     )
110 ), (
111     'circ.void_longoverdue_on_checkin',
112     'circ', 'bool',
113     oils_i18n_gettext(
114         'circ.void_longoverdue_on_checkin',
115         'Void Long-Overdue Item Billing When Returned',
116         'coust',
117         'label'
118     ),
119     oils_i18n_gettext(
120         'circ.void_longoverdue_on_checkin',
121         'Void Long-Overdue Item Billing When Returned',
122         'coust',
123         'description'
124     )
125 ), (
126     'circ.void_longoverdue_proc_fee_on_checkin',
127     'circ', 'bool',
128     oils_i18n_gettext(
129         'circ.void_longoverdue_proc_fee_on_checkin',
130         'Void Processing Fee on Long-Overdue Item Return',
131         'coust',
132         'label'
133     ),
134     oils_i18n_gettext(
135         'circ.void_longoverdue_proc_fee_on_checkin',
136         'Void Processing Fee on Long-Overdue Item Return',
137         'coust',
138         'description'
139     )
140 ), (
141     'circ.void_overdue_on_longoverdue',
142     'finance', 'bool',
143     oils_i18n_gettext(
144         'circ.void_overdue_on_longoverdue',
145         'Void Overdue Fines When Items are Marked Long-Overdue',
146         'coust',
147         'label'
148     ),
149     oils_i18n_gettext(
150         'circ.void_overdue_on_longoverdue',
151         'Void Overdue Fines When Items are Marked Long-Overdue',
152         'coust',
153         'description'
154     )
155 ), (
156     'circ.longoverdue.xact_open_on_zero',
157     'finance', 'bool',
158     oils_i18n_gettext(
159         'circ.longoverdue.xact_open_on_zero',
160         'Leave transaction open when long overdue balance equals zero',
161         'coust',
162         'label'
163     ),
164     oils_i18n_gettext(
165         'circ.longoverdue.xact_open_on_zero',
166         'Leave transaction open when long-overdue balance equals zero.  ' ||
167             'This leaves the lost copy on the patron record when it is paid',
168         'coust',
169         'description'
170     )
171 ), (
172     'circ.longoverdue.use_last_activity_date_on_return',
173     'circ', 'bool',
174     oils_i18n_gettext(
175         'circ.longoverdue.use_last_activity_date_on_return',
176         'Long-Overdue Check-In Interval Uses Last Activity Date',
177         'coust',
178         'label'
179     ),
180     oils_i18n_gettext(
181         'circ.longoverdue.use_last_activity_date_on_return',
182         'Use the long-overdue last-activity date instead of the due_date to ' ||
183             'determine whether the item has been checked out too long to ' ||
184             'perform long-overdue check-in processing.  If set, the system ' ||
185             'will first check the last payment time, followed by the last ' ||
186             'billing time, followed by the due date.  See also ' ||
187             'circ.max_accept_return_of_longoverdue',
188         'coust',
189         'description'
190     )
191 );
192
193 -- mark long-overdue reactor
194
195 INSERT INTO action_trigger.reactor (module, description) VALUES
196 (   'MarkItemLongOverdue',
197     oils_i18n_gettext(
198         'MarkItemLongOverdue',
199         'Marks a circulating item as long-overdue and applies configured ' ||
200         'penalties.  Also creates events for the longoverdue.auto hook',
201         'atreact',
202         'description'
203     )
204 );
205
206 INSERT INTO action_trigger.validator (module, description) VALUES (
207     'PatronNotInCollections', 
208     'Event is valid if the linked patron is not in collections processing ' ||
209         'at the context org unit'
210 );
211
212 -- VERIFY ID
213 INSERT INTO action_trigger.event_definition 
214     (id, active, owner, name, hook, validator, reactor, delay, delay_field) 
215 VALUES ( 
216     49, FALSE, 1, '6 Month Overdue Mark Long-Overdue', 
217     'checkout.due', 'PatronNotInCollections', 
218     'MarkItemLongOverdue', '6 months', 'due_date'
219 );
220
221 -- VERIFY ID
222 INSERT INTO action_trigger.event_params (event_def, param, value) VALUES
223     (49, 'editor', '''1'''); 
224
225 -- new longoverdue and longervdue.auto hook.
226
227 INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
228     'longoverdue',
229     'circ',
230     'Circulating Item marked long-overdue'
231 );
232
233 INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
234     'longoverdue.auto',
235     'circ',
236     'Circulating Item automatically marked long-overdue'
237 );
238
239 -- sample longoverdue.auto notification reactor
240
241 -- VERIFY ID
242 INSERT INTO action_trigger.event_definition 
243     (id, active, owner, name, hook, validator, reactor, group_field, template) 
244     VALUES ( 
245         50, FALSE, 1, '6 Month Long Overdue Notice', 
246         'longoverdue.auto', 'NOOP_True', 'SendEmail', 'usr',
247 $$
248 [%- USE date -%]
249 [%- user = target.0.usr -%]
250 To: [%- params.recipient_email || user.email %]
251 From: [%- params.sender_email || default_sender %]
252 Subject: Overdue Items Marked Long Overdue
253
254 Dear [% user.family_name %], [% user.first_given_name %]
255 The following items are 6 months overdue and have been marked Long Overdue.
256
257 [% FOR circ IN target %]
258     [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%]
259     Title: [% copy_details.title %], by [% copy_details.author %]
260     Call Number: [% circ.target_copy.call_number.label %]
261     Shelving Location: [% circ.target_copy.location.name %]
262     Barcode: [% circ.target_copy.barcode %]
263     Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
264     Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
265     Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %]
266     Library: [% circ.circ_lib.name %]
267
268 [% END %]
269 $$);
270
271 -- ENV for above
272
273 -- VERIFY IDs
274 INSERT INTO action_trigger.environment (event_def, path) VALUES 
275     (50, 'target_copy.call_number'),
276     (50, 'usr'),
277     (50, 'billable_transaction.summary'),
278     (50, 'circ_lib.billing_address'),
279     (50, 'target_copy.location');
280
281
282 --ROLLBACK;
283 COMMIT;