From 93952c53339a82c3eac7bf338d061603a1f3f854 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 15 Jun 2020 12:26:14 -0400
Subject: [PATCH] Bug 25761: Implementation of too_many_overdue has unintended
 consequences

Bug 24449 implemented the too_many_overdue SIP flag ( position 6 of the
patron status flags ). This has had unintended consequences as
many library use SIP2 for validation to eresource vendors ( Overdrive,
Hoopla, etc ), but do not want overdue checkouts to block the
use of these resources.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Find a patron with overdue items
4) Run a SIP2 patron information request
5) Note the "too many overdue" flag is set
6) Set the new SIP config option "disable_too_many_overdue" for the
account you used for testing
7) Restart the SIP server
8) Run the same patron information request
9) Notice the "too many overdue" flag is no longer set!
---
 C4/SIP/Sip/MsgType.pm | 6 ++++--
 etc/SIPconfig.xml     | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm
index d9f8901c06..bde652b3a0 100644
--- a/C4/SIP/Sip/MsgType.pm
+++ b/C4/SIP/Sip/MsgType.pm
@@ -433,7 +433,7 @@ sub build_patron_status {
             $password_rc = $patron->check_password($patron_pwd);
         }
 
-        $resp .= patron_status_string($patron);
+        $resp .= patron_status_string( $patron, $server );
         $resp .= $lang . timestamp();
         if ( defined $server->{account}->{ae_field_template} ) {
             $resp .= add_field( FID_PERSONAL_NAME, $patron->format( $server->{account}->{ae_field_template}, $server ) );
@@ -1652,6 +1652,8 @@ sub send_acs_status {
 #
 sub patron_status_string {
     my $patron = shift;
+    my $server = shift;
+
     my $patron_status;
 
     siplog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
@@ -1663,7 +1665,7 @@ sub patron_status_string {
         denied( $patron->hold_ok ),
         boolspace( $patron->card_lost ),
         boolspace( $patron->too_many_charged ),
-        boolspace( $patron->too_many_overdue ),
+        $server->{account}->{disable_too_many_overdue} ? boolspace( $patron->too_many_overdue ) : q{ },
         boolspace( $patron->too_many_renewal ),
         boolspace( $patron->too_many_claim_return ),
         boolspace( $patron->too_many_lost ),
diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml
index e61289f2de..24b46581ff 100644
--- a/etc/SIPconfig.xml
+++ b/etc/SIPconfig.xml
@@ -59,6 +59,7 @@
              da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
              av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"
              hide_fields="BD,BE,BF,PB"
+             disable_too_many_overdue="1"
              register_id=''
              holds_block_checkin="0">
           <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
-- 
2.24.1 (Apple Git-126)