From: Bill Erickson Date: Mon, 15 Apr 2013 15:44:26 +0000 (-0400) Subject: LP 1169193 long-overdue SQL seed data X-Git-Tag: sprint4-merge-nov22~2875 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=feb1c3f2044add1cf6a262824f7e2082a372253c;p=working%2FEvergreen.git LP 1169193 long-overdue SQL seed data Seed data for managing long-overdue circulations. * new copy status * new billing types * new org settings * new permissions * sample action/trigger event definitions Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index dad8658234..dd9405db1e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -315,6 +315,10 @@ INSERT INTO config.copy_status (id,name,opac_visible,copy_active) VALUES (12,oil INSERT INTO config.copy_status (id,name) VALUES (13,oils_i18n_gettext(13, 'Discard/Weed', 'ccs', 'name')); INSERT INTO config.copy_status (id,name) VALUES (14,oils_i18n_gettext(14, 'Damaged', 'ccs', 'name')); INSERT INTO config.copy_status (id,name,copy_active) VALUES (15,oils_i18n_gettext(15, 'On reservation shelf', 'ccs', 'name'),'t'); +INSERT INTO config.copy_status + (id, name, holdable, opac_visible, copy_active, restrict_copy_delete) + VALUES (16, oils_i18n_gettext(16, 'Long Overdue', 'ccs', 'name'), 'f', 'f', 'f', 't'); + SELECT SETVAL('config.copy_status_id_seq'::TEXT, 100); @@ -491,6 +495,11 @@ INSERT INTO config.billing_type (id, name, owner) VALUES ( 8, oils_i18n_gettext(8, 'Damaged Item Processing Fee', 'cbt', 'name'), 1); INSERT INTO config.billing_type (id, name, owner) VALUES ( 9, oils_i18n_gettext(9, 'Notification Fee', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, owner, name) VALUES + (10, 1, oils_i18n_gettext(10, 'Long-Overdue Materials', 'cbt', 'name')); +INSERT INTO config.billing_type (id, owner, name) VALUES + (11, 1, oils_i18n_gettext(11, 'Long-Overdue Materials Processing Fee', 'cbt', 'name')); + INSERT INTO config.billing_type (id, name, owner) VALUES ( 101, oils_i18n_gettext(101, 'Misc', 'cbt', 'name'), 1); @@ -1593,7 +1602,12 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 547, 'ACQ_ADD_LINEITEM_IDENTIFIER', oils_i18n_gettext(547, 'When granted, newly added lineitem identifiers will propagate to linked bib records', 'ppl', 'description')), ( 548, 'ACQ_SET_LINEITEM_IDENTIFIER', oils_i18n_gettext(548, - 'Allows staff to change the lineitem identifier', 'ppl', 'description')) + 'Allows staff to change the lineitem identifier', 'ppl', 'description')), + ( 549, 'COPY_STATUS_LONGOVERDUE.override', oils_i18n_gettext(549, + 'Allows the user to check-in long-overdue items, prompting ' || + 'long-overdue check-in processing', 'ppl', 'code')), + ( 550, 'SET_CIRC_LONG_OVERDUE', oils_i18n_gettext(550, + 'Allows the user to mark a circulation as long-overdue', 'ppl', 'code')) ; @@ -12872,3 +12886,236 @@ INSERT INTO config.org_unit_setting_type 'integer' ); +-- long overdue stuff... + +INSERT INTO config.org_unit_setting_type + (name, grp, datatype, label, description) VALUES +( + 'circ.longoverdue_immediately_available', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.longoverdue_immediately_available', + 'Long-Overdue Items Usable on Checkin', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue_immediately_available', + 'Long-overdue items are usable on checkin instead of going "home" first', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue_materials_processing_fee', + 'finance', 'currency', + oils_i18n_gettext( + 'circ.longoverdue_materials_processing_fee', + 'Long-Overdue Materials Processing Fee', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue_materials_processing_fee', + 'Long-Overdue Materials Processing Fee', + 'coust', + 'description' + ) +), ( + 'circ.max_accept_return_of_longoverdue', + 'circ', 'interval', + oils_i18n_gettext( + 'circ.max_accept_return_of_longoverdue', + 'Long-Overdue Max Return Interval', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.max_accept_return_of_longoverdue', + 'Long-overdue check-in processing (voiding fees, re-instating ' || + 'overdues, etc.) will not take place for items that have been ' || + 'overdue for (or have last activity older than) this amount of time', + 'coust', + 'description' + ) +), ( + 'circ.restore_overdue_on_longoverdue_return', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.restore_overdue_on_longoverdue_return', + 'Restore Overdues on Long-Overdue Item Return', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.restore_overdue_on_longoverdue_return', + 'Restore Overdues on Long-Overdue Item Return', + 'coust', + 'description' + ) +), ( + 'circ.void_longoverdue_on_checkin', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.void_longoverdue_on_checkin', + 'Void Long-Overdue Item Billing When Returned', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_longoverdue_on_checkin', + 'Void Long-Overdue Item Billing When Returned', + 'coust', + 'description' + ) +), ( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'Void Processing Fee on Long-Overdue Item Return', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'Void Processing Fee on Long-Overdue Item Return', + 'coust', + 'description' + ) +), ( + 'circ.void_overdue_on_longoverdue', + 'finance', 'bool', + oils_i18n_gettext( + 'circ.void_overdue_on_longoverdue', + 'Void Overdue Fines When Items are Marked Long-Overdue', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_overdue_on_longoverdue', + 'Void Overdue Fines When Items are Marked Long-Overdue', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue.xact_open_on_zero', + 'finance', 'bool', + oils_i18n_gettext( + 'circ.longoverdue.xact_open_on_zero', + 'Leave transaction open when long overdue balance equals zero', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue.xact_open_on_zero', + 'Leave transaction open when long-overdue balance equals zero. ' || + 'This leaves the lost copy on the patron record when it is paid', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue.use_last_activity_date_on_return', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.longoverdue.use_last_activity_date_on_return', + 'Long-Overdue Check-In Interval Uses Last Activity Date', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue.use_last_activity_date_on_return', + 'Use the long-overdue last-activity date instead of the due_date to ' || + 'determine whether the item has been checked out too long to ' || + 'perform long-overdue check-in processing. If set, the system ' || + 'will first check the last payment time, followed by the last ' || + 'billing time, followed by the due date. See also ' || + 'circ.max_accept_return_of_longoverdue', + 'coust', + 'description' + ) +); + +-- mark long-overdue reactor + +INSERT INTO action_trigger.reactor (module, description) VALUES +( 'MarkItemLongOverdue', + oils_i18n_gettext( + 'MarkItemLongOverdue', + 'Marks a circulating item as long-overdue and applies configured ' || + 'penalties. Also creates events for the longoverdue.auto hook', + 'atreact', + 'description' + ) +); + +INSERT INTO action_trigger.validator (module, description) VALUES ( + 'PatronNotInCollections', + 'Event is valid if the linked patron is not in collections processing ' || + 'at the context org unit' +); + +INSERT INTO action_trigger.event_definition + (id, active, owner, name, hook, validator, reactor, delay, delay_field) +VALUES ( + 49, FALSE, 1, '6 Month Overdue Mark Long-Overdue', + 'checkout.due', 'PatronNotInCollections', + 'MarkItemLongOverdue', '6 months', 'due_date' +); + +INSERT INTO action_trigger.event_params (event_def, param, value) VALUES + (49, 'editor', '''1'''); + +-- new longoverdue and longervdue.auto hook. + +INSERT INTO action_trigger.hook (key,core_type,description) VALUES ( + 'longoverdue', + 'circ', + 'Circulating Item marked long-overdue' +); + +INSERT INTO action_trigger.hook (key,core_type,description) VALUES ( + 'longoverdue.auto', + 'circ', + 'Circulating Item automatically marked long-overdue' +); + +-- sample longoverdue.auto notification reactor + +INSERT INTO action_trigger.event_definition + (id, active, owner, name, hook, validator, reactor, group_field, template) + VALUES ( + 50, FALSE, 1, '6 Month Long Overdue Notice', + 'longoverdue.auto', 'NOOP_True', 'SendEmail', 'usr', +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Overdue Items Marked Long Overdue + +Dear [% user.family_name %], [% user.first_given_name %] +The following items are 6 months overdue and have been marked Long Overdue. + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %], by [% copy_details.author %] + Call Number: [% circ.target_copy.call_number.label %] + Shelving Location: [% circ.target_copy.location.name %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Item Cost: [% helpers.get_copy_price(circ.target_copy) %] + Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %] + Library: [% circ.circ_lib.name %] + +[% END %] +$$); + +-- ENV for above + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (50, 'target_copy.call_number'), + (50, 'usr'), + (50, 'billable_transaction.summary'), + (50, 'circ_lib.billing_address'), + (50, 'target_copy.location'); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.long-overdue.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.long-overdue.sql new file mode 100644 index 0000000000..d66bf50c96 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.long-overdue.sql @@ -0,0 +1,283 @@ +BEGIN; + +-- NOTE: very IDs are still correct for perms and event_def data at merge. + +-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +-- copy status + +INSERT INTO config.copy_status + (id, name, holdable, opac_visible, copy_active, restrict_copy_delete) + VALUES (16, oils_i18n_gettext(16, 'Long Overdue', 'ccs', 'name'), 'f', 'f', 'f', 't'); + +-- checkin override perm + +INSERT INTO permission.perm_list (id, code, description) VALUES ( + 549, -- VERIFY + 'COPY_STATUS_LONGOVERDUE.override', + oils_i18n_gettext( + 549, -- VERIFY + 'Allows the user to check-in long-overdue items, prompting ' || + 'long-overdue check-in processing', + 'ppl', + 'code' + ) +), ( + 550, -- VERIFY + 'SET_CIRC_LONG_OVERDUE', + oils_i18n_gettext( + 550, -- VERIFY + 'Allows the user to mark a circulation as long-overdue', + 'ppl', + 'code' + ) +); + +-- billing types + +INSERT INTO config.billing_type (id, owner, name) VALUES + (10, 1, oils_i18n_gettext( + 10, 'Long-Overdue Materials', 'cbt', 'name')), + (11, 1, oils_i18n_gettext( + 11, 'Long-Overdue Materials Processing Fee', 'cbt', 'name')); + +-- org settings + +INSERT INTO config.org_unit_setting_type + (name, grp, datatype, label, description) VALUES +( + 'circ.longoverdue_immediately_available', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.longoverdue_immediately_available', + 'Long-Overdue Items Usable on Checkin', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue_immediately_available', + 'Long-overdue items are usable on checkin instead of going "home" first', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue_materials_processing_fee', + 'finance', 'currency', + oils_i18n_gettext( + 'circ.longoverdue_materials_processing_fee', + 'Long-Overdue Materials Processing Fee', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue_materials_processing_fee', + 'Long-Overdue Materials Processing Fee', + 'coust', + 'description' + ) +), ( + 'circ.max_accept_return_of_longoverdue', + 'circ', 'interval', + oils_i18n_gettext( + 'circ.max_accept_return_of_longoverdue', + 'Long-Overdue Max Return Interval', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.max_accept_return_of_longoverdue', + 'Long-overdue check-in processing (voiding fees, re-instating ' || + 'overdues, etc.) will not take place for items that have been ' || + 'overdue for (or have last activity older than) this amount of time', + 'coust', + 'description' + ) +), ( + 'circ.restore_overdue_on_longoverdue_return', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.restore_overdue_on_longoverdue_return', + 'Restore Overdues on Long-Overdue Item Return', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.restore_overdue_on_longoverdue_return', + 'Restore Overdues on Long-Overdue Item Return', + 'coust', + 'description' + ) +), ( + 'circ.void_longoverdue_on_checkin', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.void_longoverdue_on_checkin', + 'Void Long-Overdue Item Billing When Returned', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_longoverdue_on_checkin', + 'Void Long-Overdue Item Billing When Returned', + 'coust', + 'description' + ) +), ( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'Void Processing Fee on Long-Overdue Item Return', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_longoverdue_proc_fee_on_checkin', + 'Void Processing Fee on Long-Overdue Item Return', + 'coust', + 'description' + ) +), ( + 'circ.void_overdue_on_longoverdue', + 'finance', 'bool', + oils_i18n_gettext( + 'circ.void_overdue_on_longoverdue', + 'Void Overdue Fines When Items are Marked Long-Overdue', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.void_overdue_on_longoverdue', + 'Void Overdue Fines When Items are Marked Long-Overdue', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue.xact_open_on_zero', + 'finance', 'bool', + oils_i18n_gettext( + 'circ.longoverdue.xact_open_on_zero', + 'Leave transaction open when long overdue balance equals zero', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue.xact_open_on_zero', + 'Leave transaction open when long-overdue balance equals zero. ' || + 'This leaves the lost copy on the patron record when it is paid', + 'coust', + 'description' + ) +), ( + 'circ.longoverdue.use_last_activity_date_on_return', + 'circ', 'bool', + oils_i18n_gettext( + 'circ.longoverdue.use_last_activity_date_on_return', + 'Long-Overdue Check-In Interval Uses Last Activity Date', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.longoverdue.use_last_activity_date_on_return', + 'Use the long-overdue last-activity date instead of the due_date to ' || + 'determine whether the item has been checked out too long to ' || + 'perform long-overdue check-in processing. If set, the system ' || + 'will first check the last payment time, followed by the last ' || + 'billing time, followed by the due date. See also ' || + 'circ.max_accept_return_of_longoverdue', + 'coust', + 'description' + ) +); + +-- mark long-overdue reactor + +INSERT INTO action_trigger.reactor (module, description) VALUES +( 'MarkItemLongOverdue', + oils_i18n_gettext( + 'MarkItemLongOverdue', + 'Marks a circulating item as long-overdue and applies configured ' || + 'penalties. Also creates events for the longoverdue.auto hook', + 'atreact', + 'description' + ) +); + +INSERT INTO action_trigger.validator (module, description) VALUES ( + 'PatronNotInCollections', + 'Event is valid if the linked patron is not in collections processing ' || + 'at the context org unit' +); + +-- VERIFY ID +INSERT INTO action_trigger.event_definition + (id, active, owner, name, hook, validator, reactor, delay, delay_field) +VALUES ( + 49, FALSE, 1, '6 Month Overdue Mark Long-Overdue', + 'checkout.due', 'PatronNotInCollections', + 'MarkItemLongOverdue', '6 months', 'due_date' +); + +-- VERIFY ID +INSERT INTO action_trigger.event_params (event_def, param, value) VALUES + (49, 'editor', '''1'''); + +-- new longoverdue and longervdue.auto hook. + +INSERT INTO action_trigger.hook (key,core_type,description) VALUES ( + 'longoverdue', + 'circ', + 'Circulating Item marked long-overdue' +); + +INSERT INTO action_trigger.hook (key,core_type,description) VALUES ( + 'longoverdue.auto', + 'circ', + 'Circulating Item automatically marked long-overdue' +); + +-- sample longoverdue.auto notification reactor + +-- VERIFY ID +INSERT INTO action_trigger.event_definition + (id, active, owner, name, hook, validator, reactor, group_field, template) + VALUES ( + 50, FALSE, 1, '6 Month Long Overdue Notice', + 'longoverdue.auto', 'NOOP_True', 'SendEmail', 'usr', +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Overdue Items Marked Long Overdue + +Dear [% user.family_name %], [% user.first_given_name %] +The following items are 6 months overdue and have been marked Long Overdue. + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %], by [% copy_details.author %] + Call Number: [% circ.target_copy.call_number.label %] + Shelving Location: [% circ.target_copy.location.name %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Item Cost: [% helpers.get_copy_price(circ.target_copy) %] + Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %] + Library: [% circ.circ_lib.name %] + +[% END %] +$$); + +-- ENV for above + +-- VERIFY IDs +INSERT INTO action_trigger.environment (event_def, path) VALUES + (50, 'target_copy.call_number'), + (50, 'usr'), + (50, 'billable_transaction.summary'), + (50, 'circ_lib.billing_address'), + (50, 'target_copy.location'); + + +--ROLLBACK; +COMMIT;