From 560aa83f9420b055831d83b659090185eeefafd5 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 22 Aug 2008 01:33:48 +0000 Subject: [PATCH] add renewal-specific rule flag git-svn-id: svn://svn.open-ils.org/ILS/trunk@10411 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/100.circ_matrix.sql | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/sql/Pg/100.circ_matrix.sql b/Open-ILS/src/sql/Pg/100.circ_matrix.sql index c65507a752..1aa7d69f81 100644 --- a/Open-ILS/src/sql/Pg/100.circ_matrix.sql +++ b/Open-ILS/src/sql/Pg/100.circ_matrix.sql @@ -100,20 +100,21 @@ CREATE TABLE config.circ_matrix_matchpoint ( 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, - 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) + 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) ); -- Tests to determine if circ can occur for this item at this location for this patron CREATE TABLE config.circ_matrix_test ( - matchpoint INT PRIMARY KEY NOT NULL REFERENCES config.circ_matrix_matchpoint (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - circulate BOOL NOT NULL DEFAULT TRUE, -- Hard "can't circ" flag requiring an override - max_items_out INT, -- Total current active circulations must be less than this, NULL means skip (always pass) - max_overdue INT, -- Total overdue active circulations must be less than this, NULL means skip (always pass) - max_fines NUMERIC(8,2), -- Total fines owed must be less than this, NULL means skip (always pass) - script_test TEXT -- filename or javascript source ?? + matchpoint INT PRIMARY KEY NOT NULL REFERENCES config.circ_matrix_matchpoint (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + circulate BOOL NOT NULL DEFAULT TRUE, -- Hard "can't circ" flag requiring an override + max_items_out INT, -- Total current active circulations must be less than this, NULL means skip (always pass) + max_overdue INT, -- Total overdue active circulations must be less than this, NULL means skip (always pass) + max_fines NUMERIC(8,2), -- Total fines owed must be less than this, NULL means skip (always pass) + script_test TEXT -- filename or javascript source ?? ); -- Tests for max items out by circ_modifier @@ -133,7 +134,7 @@ CREATE TABLE config.circ_matrix_ruleset ( max_fine_rule INT NOT NULL REFERENCES config.rule_max_fine (id) DEFERRABLE INITIALLY DEFERRED ); -CREATE OR REPLACE FUNCTION action.find_circ_matrix_matchpoint( context_ou INT, match_item BIGINT, match_user INT ) RETURNS INT AS $func$ +CREATE OR REPLACE FUNCTION action.find_circ_matrix_matchpoint( context_ou INT, match_item BIGINT, match_user INT, renewal BOOL ) RETURNS INT AS $func$ DECLARE current_group permission.grp_tree%ROWTYPE; user_object actor.usr%ROWTYPE; @@ -156,6 +157,7 @@ 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.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 + @@ -283,7 +285,7 @@ BEGIN RETURN NEXT result; END IF; - SELECT INTO matchpoint_id action.find_circ_matrix_matchpoint(circ_ou, match_item, match_user); + SELECT INTO matchpoint_id action.find_circ_matrix_matchpoint(circ_ou, match_item, match_user, renewal); result.matchpoint := matchpoint_id; -- Fail if we couldn't find a set of tests -- 2.43.2