From: miker Date: Sat, 6 Dec 2008 03:54:15 +0000 (+0000) Subject: adding actor.usr.juvenile as a circ/hold matrix matchpoint criterium X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6c3488314e6a1de6887ffc582d29c1993b51255e;p=Evergreen.git adding actor.usr.juvenile as a circ/hold matrix matchpoint criterium git-svn-id: svn://svn.open-ils.org/ILS/trunk@11434 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/100.circ_matrix.sql b/Open-ILS/src/sql/Pg/100.circ_matrix.sql index 90db335ee4..f32d74a781 100644 --- a/Open-ILS/src/sql/Pg/100.circ_matrix.sql +++ b/Open-ILS/src/sql/Pg/100.circ_matrix.sql @@ -96,24 +96,25 @@ INSERT INTO config.videorecording_format_map VALUES ('z','Other'); -- CREATE TABLE config.circ_matrix_matchpoint ( - id SERIAL PRIMARY KEY, - active BOOL NOT NULL DEFAULT TRUE, - org_unit INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best" - grp INT NOT NULL REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering + id SERIAL PRIMARY KEY, + active BOOL NOT NULL DEFAULT TRUE, + org_unit INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best" + grp INT NOT NULL REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering circ_modifier TEXT REFERENCES config.circ_modifier (code) DEFERRABLE INITIALLY DEFERRED, marc_type TEXT REFERENCES config.item_type_map (code) DEFERRABLE INITIALLY DEFERRED, marc_form TEXT REFERENCES config.item_form_map (code) DEFERRABLE INITIALLY DEFERRED, - marc_vr_format TEXT REFERENCES config.videorecording_format_map (code) DEFERRABLE INITIALLY DEFERRED, - ref_flag BOOL, - is_renewal BOOL, - usr_age_lower_bound INTERVAL, - usr_age_upper_bound INTERVAL, - circulate BOOL NOT NULL DEFAULT TRUE, -- Hard "can't circ" flag requiring an override + marc_vr_format TEXT REFERENCES config.videorecording_format_map (code) DEFERRABLE INITIALLY DEFERRED, + ref_flag BOOL, + juvenile_flag BOOL, + is_renewal BOOL, + usr_age_lower_bound INTERVAL, + usr_age_upper_bound INTERVAL, + circulate BOOL NOT NULL DEFAULT TRUE, -- Hard "can't circ" flag requiring an override duration_rule INT NOT NULL REFERENCES config.rule_circ_duration (id) DEFERRABLE INITIALLY DEFERRED, - recurring_fine_rule INT NOT NULL REFERENCES config.rule_recuring_fine (id) DEFERRABLE INITIALLY DEFERRED, + recurring_fine_rule INT NOT NULL REFERENCES config.rule_recuring_fine (id) DEFERRABLE INITIALLY DEFERRED, max_fine_rule INT NOT NULL REFERENCES config.rule_max_fine (id) DEFERRABLE INITIALLY DEFERRED, - script_test TEXT, -- javascript source - CONSTRAINT ep_once_per_grp_loc_mod_marc UNIQUE (grp, org_unit, circ_modifier, marc_type, marc_form, marc_vr_format, ref_flag, usr_age_lower_bound, usr_age_upper_bound, is_renewal) + script_test TEXT, -- javascript source + CONSTRAINT ep_once_per_grp_loc_mod_marc UNIQUE (grp, org_unit, circ_modifier, marc_type, marc_form, marc_vr_format, ref_flag, juvenile_flag, usr_age_lower_bound, usr_age_upper_bound, is_renewal) ); @@ -149,7 +150,8 @@ BEGIN LEFT JOIN actor.org_unit_proximity p ON (p.from_org = context_ou AND p.to_org = d.id) WHERE m.grp = current_group.id AND m.active ORDER BY CASE WHEN p.prox IS NULL THEN 999 ELSE p.prox END, - CASE WHEN m.is_renewal = renewal THEN 64 ELSE 0 END + + CASE WHEN m.is_renewal = renewal THEN 128 ELSE 0 END + + CASE WHEN m.juvenile_flag IS NOT NULL THEN 64 ELSE 0 END + CASE WHEN m.circ_modifier IS NOT NULL THEN 32 ELSE 0 END + CASE WHEN m.marc_type IS NOT NULL THEN 16 ELSE 0 END + CASE WHEN m.marc_form IS NOT NULL THEN 8 ELSE 0 END + @@ -182,6 +184,10 @@ BEGIN CONTINUE WHEN current_mp.ref_flag <> item_object.ref; END IF; + IF current_mp.juvenile_flag IS NOT NULL THEN + CONTINUE WHEN current_mp.juvenile_flag <> user_object.juvenile; + END IF; + IF current_mp.usr_age_lower_bound IS NOT NULL THEN CONTINUE WHEN user_object.dob IS NULL OR current_mp.usr_age_lower_bound < age(user_object.dob); END IF; diff --git a/Open-ILS/src/sql/Pg/110.hold_matrix.sql b/Open-ILS/src/sql/Pg/110.hold_matrix.sql index 92bb990ae3..39aa4137e0 100644 --- a/Open-ILS/src/sql/Pg/110.hold_matrix.sql +++ b/Open-ILS/src/sql/Pg/110.hold_matrix.sql @@ -42,6 +42,7 @@ CREATE TABLE config.hold_matrix_matchpoint ( marc_type TEXT REFERENCES config.item_type_map (code) DEFERRABLE INITIALLY DEFERRED, marc_form TEXT REFERENCES config.item_form_map (code) DEFERRABLE INITIALLY DEFERRED, marc_vr_format TEXT REFERENCES config.videorecording_format_map (code) DEFERRABLE INITIALLY DEFERRED, + juvenile_flag BOOL, ref_flag BOOL, holdable BOOL NOT NULL DEFAULT TRUE, -- Hard "can't hold" flag requiring an override distance_is_from_owner BOOL NOT NULL DEFAULT FALSE, -- How to calculate transit_range. True means owning lib, false means copy circ lib @@ -50,7 +51,7 @@ CREATE TABLE config.hold_matrix_matchpoint ( include_frozen_holds BOOL NOT NULL DEFAULT TRUE, -- Include frozen hold requests in the count for max_holds test stop_blocked_user BOOL NOT NULL DEFAULT FALSE, -- Stop users who cannot check out items from placing holds age_hold_protect_rule INT REFERENCES config.rule_age_hold_protect (id) DEFERRABLE INITIALLY DEFERRED, -- still not sure we want to move this off the copy - CONSTRAINT hous_once_per_grp_loc_mod_marc UNIQUE (user_home_ou, request_ou, pickup_ou, item_owning_ou, item_circ_ou, requestor_grp, usr_grp, circ_modifier, marc_type, marc_form, marc_vr_format) + CONSTRAINT hous_once_per_grp_loc_mod_marc UNIQUE (user_home_ou, request_ou, pickup_ou, item_owning_ou, item_circ_ou, requestor_grp, usr_grp, circ_modifier, marc_type, marc_form, marc_vr_format, ref_flag, juvenile_flag) ); CREATE OR REPLACE FUNCTION action.find_hold_matrix_matchpoint( pickup_ou INT, request_ou INT, match_item BIGINT, match_user INT, match_requestor INT ) RETURNS INT AS $func$ @@ -83,6 +84,7 @@ BEGIN FROM config.hold_matrix_matchpoint m WHERE m.requestor_grp = current_requestor_group.id AND m.active ORDER BY CASE WHEN m.circ_modifier IS NOT NULL THEN 16 ELSE 0 END + + CASE WHEN m.juvenile_flag IS NOT NULL THEN 16 ELSE 0 END + CASE WHEN m.marc_type IS NOT NULL THEN 8 ELSE 0 END + CASE WHEN m.marc_form IS NOT NULL THEN 4 ELSE 0 END + CASE WHEN m.marc_vr_format IS NOT NULL THEN 2 ELSE 0 END + @@ -110,6 +112,10 @@ BEGIN CONTINUE WHEN current_mp.marc_vr_format <> rec_descriptor.vr_format; END IF; + IF current_mp.juvenile_flag IS NOT NULL THEN + CONTINUE WHEN current_mp.juvenile_flag <> user_object.juvenile; + END IF; + IF current_mp.ref_flag IS NOT NULL THEN CONTINUE WHEN current_mp.ref_flag <> item_object.ref; END IF;