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
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;
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 +
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