[open-ils-commits] r10411 - trunk/Open-ILS/src/sql/Pg

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Aug 21 21:33:49 EDT 2008


Author: miker
Date: 2008-08-21 21:33:48 -0400 (Thu, 21 Aug 2008)
New Revision: 10411

Modified:
   trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql
Log:
add renewal-specific rule flag

Modified: trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql	2008-08-21 21:20:36 UTC (rev 10410)
+++ trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql	2008-08-22 01:33:48 UTC (rev 10411)
@@ -100,20 +100,21 @@
 	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 @@
 	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 @@
 				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 @@
 		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



More information about the open-ils-commits mailing list