Bug 22043: (QA follow-up) Add parameter to control behavior
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 28 Feb 2019 21:13:11 +0000 (16:13 -0500)
committerroot <root@f1ebe1bec408>
Fri, 15 Mar 2019 12:10:46 +0000 (12:10 +0000)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/SIP/ILS.pm
C4/SIP/ILS/Transaction/Checkin.pm
C4/SIP/Sip/MsgType.pm
etc/SIPconfig.xml
t/db_dependent/SIP/Message.t

index 1bd23c6..b115dcd 100644 (file)
@@ -197,7 +197,7 @@ sub test_cardnumber_compare {
 }
 
 sub checkin {
-    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $checked_in_ok ) = @_;
+    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $checked_in_ok, $cv_triggers_alert ) = @_;
     my ( $patron, $item, $circ );
 
     $circ = C4::SIP::ILS::Transaction::Checkin->new();
@@ -206,7 +206,7 @@ sub checkin {
     $circ->item( $item = C4::SIP::ILS::Item->new($item_id) );
 
     if ($item) {
-        $circ->do_checkin( $current_loc, $return_date );
+        $circ->do_checkin( $current_loc, $return_date, $cv_triggers_alert );
     }
     else {
         $circ->alert(1);
index 77eb361..40dda06 100644 (file)
@@ -47,6 +47,8 @@ sub do_checkin {
     my $self = shift;
     my $branch = shift;
     my $return_date = shift;
+    my $cv_triggers_alert = shift;
+
     if (!$branch) {
         $branch = 'SIP2';
     }
@@ -66,6 +68,8 @@ sub do_checkin {
 
     $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
     my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
+    $self->alert(!$return);
+    # ignoring messages: NotIssued, WasLost, WasTransfered
 
     # biblionumber, biblioitemnumber, itemnumber
     # borrowernumber, reservedate, branchcode
@@ -115,7 +119,14 @@ sub do_checkin {
         $self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} );
         $self->{item}->destination_loc( $messages->{ResFound}->{branchcode} );
     }
-    $self->alert(defined $self->alert_type);  # alert_type could be "00", hypothetically
+
+    my $alert = defined $self->alert_type;
+    if ( $cv_triggers_alert ) {
+        $self->alert($alert); # Overwrites existing alert value, should set to 0 if there is no alert type
+    } else {
+        $self->alert($alert) if $alert; # Doesn't affect alert value unless an alert type is set
+    }
+
     $self->ok($return);
 }
 
index 061a255..6c2e4fc 100644 (file)
@@ -637,7 +637,7 @@ sub handle_checkin {
         syslog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
         $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
     } else {
-        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok} );
+        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok}, $account->{cv_triggers_alert} );
     }
 
     $patron = $status->patron;
index 7a2fd65..1e17ef0 100644 (file)
@@ -53,6 +53,7 @@
              send_patron_home_library_in_af="1"
              cv_send_00_on_success="1"
              ct_always_send="1"
+             cv_triggers_alert="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') %]" >
index 7bf745a..dbab48e 100755 (executable)
@@ -67,7 +67,7 @@ subtest 'Testing Patron Info Request V2' => sub {
 subtest 'Checkin V2' => sub {
     my $schema = Koha::Database->new->schema;
     $schema->storage->txn_begin;
-    plan tests => 25;
+    plan tests => 27;
     $C4::SIP::Sip::protocol_version = 2;
     test_checkin_v2();
     $schema->storage->txn_rollback;
@@ -378,6 +378,25 @@ sub test_checkin_v2 {
     $server->{account}->{checked_in_ok} = 0;
     $server->{account}->{cv_send_00_on_success} = 0;
 
+    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', '1' );
+    $server->{account}->{checked_in_ok} = 1;
+    $server->{account}->{cv_triggers_alert} = 0;
+    undef $response;
+    $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
+    $msg->handle_checkin( $server );
+    $respcode = substr( $response, 0, 2 );
+    is( substr( $response, 5, 1 ), 'Y', 'Checkin without CV triggers alert flag when cv_triggers_alert is off' );
+    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', '0' );
+    $server->{account}->{cv_triggers_alert} = 1;
+    undef $response;
+    $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
+    $msg->handle_checkin( $server );
+    $respcode = substr( $response, 0, 2 );
+    is( substr( $response, 5, 1 ), 'N', 'Checkin without CV does not trigger alert flag when cv_triggers_alert is on' );
+    $server->{account}->{checked_in_ok} = 0;
+    $server->{account}->{cv_triggers_alert} = 0;
+    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', '1' );
+
     $server->{account}->{checked_in_ok} = 1;
     $server->{account}->{ct_always_send} = 0;
     undef $response;