lp870029: add YAOUS for strict holdability checking collab/gmcharlt/fix_indb_hold_permit
authorGalen Charlton <gmc@esilibrary.com>
Tue, 25 Oct 2011 21:33:57 +0000 (17:33 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 25 Oct 2011 21:33:57 +0000 (17:33 -0400)
Add circ.holds.strict_holdability_check to control whether the
copy, copy status, and copy location holdable flags are checked
when seeing if a hold can be placed or a copy can be targetted to fill
a hold.  Also set the default value of this OUS to true to
retain legacy behavior.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/sql/Pg/110.hold_matrix.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.fix_indb_hold_permit.sql

index 5131afb..5a02995 100644 (file)
@@ -227,6 +227,7 @@ DECLARE
     item_status_object  config.copy_status%ROWTYPE;
     item_location_object    asset.copy_location%ROWTYPE;
     ou_skip              actor.org_unit_setting%ROWTYPE;
+    check_holdability_strictly  actor.org_unit_setting%ROWTYPE;
     result            action.matrix_test_result;
     hold_test        config.hold_matrix_matchpoint%ROWTYPE;
     use_active_date   TEXT;
@@ -307,25 +308,31 @@ BEGIN
         RETURN NEXT result;
     END IF;
 
-    IF item_object.holdable IS FALSE THEN
-        result.fail_part := 'item.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
-    END IF;
+    SELECT INTO check_holdability_strictly * 
+        FROM actor.org_unit_setting 
+        WHERE name = 'circ.holds.strict_holdability_check' AND org_unit = item_object.circ_lib;
 
-    IF item_status_object.holdable IS FALSE THEN
-        result.fail_part := 'status.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
-    END IF;
+    IF check_holdability_strictly.id IS NOT NULL AND check_holdability_strictly.value = 'true' THEN
+        IF item_object.holdable IS FALSE THEN
+            result.fail_part := 'item.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
 
-    IF item_location_object.holdable IS FALSE THEN
-        result.fail_part := 'location.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
+        IF item_status_object.holdable IS FALSE THEN
+            result.fail_part := 'status.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
+
+        IF item_location_object.holdable IS FALSE THEN
+            result.fail_part := 'location.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
     END IF;
 
     IF hold_test.transit_range IS NOT NULL THEN
index 09466eb..ce89100 100644 (file)
@@ -4447,6 +4447,15 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'bool', null)
 
+,( 'circ.holds.strict_holdability_check', 'holds',
+    oils_i18n_gettext('circ.strict_holdability_check',
+        'Strict holdability check',
+        'coust', 'label'),
+    oils_i18n_gettext('circ.holds.strict_holdability_check',
+        'Allow hold to be placed only if at least one holdable copy is present',
+        'coust', 'description'),
+    'bool', null)
+
 ;
 
 UPDATE config.org_unit_setting_type
@@ -4477,6 +4486,9 @@ INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (
     ,(1, 'cat.label.font.weight', '"normal"')
 ;
 
+INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (
+    1, 'circ.holds.strict_holdability_check', 'true'
+);
 
 -- Staged Search (for default matchpoints)
 INSERT INTO search.relevance_adjustment (field, bump_type, multiplier) VALUES(1, 'first_word', 1.5);
index 35d2ba4..1f4d013 100644 (file)
@@ -11,6 +11,7 @@ DECLARE
     item_status_object  config.copy_status%ROWTYPE;
     item_location_object    asset.copy_location%ROWTYPE;
     ou_skip              actor.org_unit_setting%ROWTYPE;
+    check_holdability_strictly  actor.org_unit_setting%ROWTYPE;
     result            action.matrix_test_result;
     hold_test        config.hold_matrix_matchpoint%ROWTYPE;
     use_active_date   TEXT;
@@ -91,25 +92,31 @@ BEGIN
         RETURN NEXT result;
     END IF;
 
-    IF item_object.holdable IS FALSE THEN
-        result.fail_part := 'item.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
-    END IF;
+    SELECT INTO check_holdability_strictly * 
+        FROM actor.org_unit_setting 
+        WHERE name = 'circ.holds.strict_holdability_check' AND org_unit = item_object.circ_lib;
 
-    IF item_status_object.holdable IS FALSE THEN
-        result.fail_part := 'status.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
-    END IF;
+    IF check_holdability_strictly.id IS NOT NULL AND check_holdability_strictly.value = 'true' THEN
+        IF item_object.holdable IS FALSE THEN
+            result.fail_part := 'item.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
 
-    IF item_location_object.holdable IS FALSE THEN
-        result.fail_part := 'location.holdable';
-        result.success := FALSE;
-        done := TRUE;
-        RETURN NEXT result;
+        IF item_status_object.holdable IS FALSE THEN
+            result.fail_part := 'status.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
+
+        IF item_location_object.holdable IS FALSE THEN
+            result.fail_part := 'location.holdable';
+            result.success := FALSE;
+            done := TRUE;
+            RETURN NEXT result;
+        END IF;
     END IF;
 
     IF hold_test.transit_range IS NOT NULL THEN
@@ -213,4 +220,22 @@ BEGIN
 
     RETURN;
 END;
+
 $func$ LANGUAGE plpgsql;
+INSERT into config.org_unit_setting_type
+( name, grp, label, description, datatype ) VALUES
+( 'circ.holds.strict_holdability_check', 'holds',
+    oils_i18n_gettext('circ.strict_holdability_check',
+        'Strict holdability check',
+        'coust', 'label'),
+    oils_i18n_gettext('circ.holds.strict_holdability_check',
+        'Allow hold to be placed only if at least one holdable copy is present',
+        'coust', 'description'),
+    'bool');
+
+INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (
+    1, 'circ.holds.strict_holdability_check', 'true'
+);
+
+