From 7d76898b674441d989d096442861831c9adb4ba3 Mon Sep 17 00:00:00 2001
From: Jason Stephenson <jason@sigio.com>
Date: Fri, 2 Nov 2018 09:03:07 -0400
Subject: [PATCH] Lp 1799272: Option to Limit Hold Items in SIP2 msg 64 to
 Available

This commit adds an implementation option to the oils_sip.xml that,
when enabled, will limit the hold items list and hold items counts in
the patron information response (response 64) to only the holds
available for pickup by the patron.  When the setting is not enabled,
the full list of the patron's holds continues to be used.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
---
 Open-ILS/examples/oils_sip.xml.example                   | 11 ++++++++---
 Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm          | 16 ++++++++++------
 .../SIP/hold_items_available_option.adoc                 | 11 +++++++++++
 3 files changed, 29 insertions(+), 9 deletions(-)
 create mode 100644 docs/RELEASE_NOTES_NEXT/SIP/hold_items_available_option.adoc

diff --git a/Open-ILS/examples/oils_sip.xml.example b/Open-ILS/examples/oils_sip.xml.example
index 2146775f19..06da91bec7 100644
--- a/Open-ILS/examples/oils_sip.xml.example
+++ b/Open-ILS/examples/oils_sip.xml.example
@@ -118,6 +118,13 @@
                     <option name='msg64_hold_datatype' value='barcode' />
                     -->
 
+                    <!--
+                        When set, hold items details will return only available holds to the SIP client.
+                    -->
+                    <!--
+                    <option name='msg64_hold_items_available' value='true' />
+                    -->
+
 					<!--
 						If enabled, the PC field in patron-info requests will return the non-translated profile name
 					<option name='patron_type_uses_code' value='true' />
@@ -164,6 +171,4 @@
 	</institutions>
 </acsconfig>
 
-<!--
-    vim:noet:ts=4:sw=4:
--->
+<!-- vim:noet:ts=4:sw=4: -->
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
index 9de94b82e3..98a594da84 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
@@ -520,13 +520,17 @@ sub hold_items {
     my ($self, $start, $end, $ids_only) = @_;
     syslog('LOG_DEBUG', 'OILS: Patron->hold_items()');
 
-
     # all of my open holds
-    my $holds = $self->{editor}->search_action_hold_request({
-        usr => $self->{user}->id, 
-        fulfillment_time => undef, 
-        cancel_time => undef 
-    });
+    my $holds_query = {
+        usr => $self->{user}->id,
+        fulfillment_time => undef,
+        cancel_time => undef
+    };
+    if (OpenILS::SIP->get_option_value('msg64_hold_items_available')) {
+        # Limit to available holds.
+        $holds_query->{current_shelf_lib} = {'=' => {'+ahr' => 'pickup_lib'}};
+    }
+    my $holds = $self->{editor}->search_action_hold_request($holds_query);
 
     return $holds if $ids_only;
     return $self->__format_holds($holds, $start, $end);
diff --git a/docs/RELEASE_NOTES_NEXT/SIP/hold_items_available_option.adoc b/docs/RELEASE_NOTES_NEXT/SIP/hold_items_available_option.adoc
new file mode 100644
index 0000000000..515d7e3711
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/SIP/hold_items_available_option.adoc
@@ -0,0 +1,11 @@
+Option to Limit Hold Items to Available
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A new option has been added to the SIP2 implementation configuration,
+`msg64_hold_items_available`.  When set, this option will limit the
+count and list of hold items in the SIP2 patron information response
+message (64) to only those holds that are available for pickup.  When
+not set, the full list of the patron's holds will continue to be sent.
+This option is useful because some self checks expect to receive only
+the list of available holds in the hold items and have few settings to
+control the display of holds.
-- 
2.11.0