From f23df9ea12aed7217f7d173d433f61393b222310 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 17 Dec 2018 12:34:14 -0500
Subject: [PATCH] Bug 22014: Add ability to send "00" in SIP CV field on
 checkin success

Some SIP devices ( in this particular case, bin sorting machines from RFID Library Solutions ) require a checkin success to return a CV field of the value "00" rather than no CV field at all. Koha should be able to support this behavior.

Test Plan:
1) Apply this patch
2) Enable the new option cv_send_00_on_success for a SIP2 account
3) Restart SIP
4) Check in an item successfully via SIP
5) Note the response contains a CV field with the value '00'

Sponsored-by: Pueblo City-County Library District

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 C4/SIP/Sip/MsgType.pm | 6 +++++-
 etc/SIPconfig.xml     | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm
index fbccc82645..c89b4569c7 100644
--- a/C4/SIP/Sip/MsgType.pm
+++ b/C4/SIP/Sip/MsgType.pm
@@ -688,7 +688,11 @@ sub handle_checkin {
         }
     }
 
-    $resp .= maybe_add( FID_ALERT_TYPE, $status->alert_type ) if $status->alert;
+    if ( $status->alert ) {
+        $resp .= maybe_add( FID_ALERT_TYPE, $status->alert_type );
+    } elsif ( $server->{account}->{cv_send_00_on_success} ) {
+        $resp .= add_field( FID_ALERT_TYPE, '00' );
+    }
     $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
     $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
 
diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml
index 5d9ee98bc2..49ff852698 100644
--- a/etc/SIPconfig.xml
+++ b/etc/SIPconfig.xml
@@ -51,6 +51,7 @@
       <login id="lpl-sc-beacock" password="xyzzy"
              delimiter="|" error-detect="enabled" institution="LPL"
              send_patron_home_library_in_af="1"
+             cv_send_00_on_success="1"
              ae_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
              da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
              av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >
-- 
2.17.2 (Apple Git-113)