From 26fae4e339e6b1a1205f55b2895e30127936d96d Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Thu, 20 Jul 2023 16:59:20 +0200 Subject: [PATCH] Bug 34326: Add forbidden notforloan status option Test plan: 1) Add on your sip account an option called "forbidden_notforloan_status" and specify values separated by commas like "1,4,6" related to your notforloan statuses. 2) Restart your SIP server after that 3) Launch your SIP command on checkin with some items with these statuses. See the normal output 4) Apply this patch 5) Do step 3 again and see the new output with forbidden status and lib related to --- C4/SIP/ILS.pm | 9 +++++++++ C4/SIP/ILS/Transaction/Checkin.pm | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 0c58b07f15..8a0bc631c5 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -237,6 +237,15 @@ sub checkin { return $circ; } + if ( $data->{messages}->{ForbiddenNotForLoanStatus} ) { + my $f_status = $data->{messages}->{ForbiddenNotForLoanStatus}; + $circ->ok(0); + $circ->screen_msg( + "Return not allowed, notforloan status (" . $f_status . ")" ); + siplog( "LOG_WARNING", "C4::SIP::ILS::Checkin - forbidden return status" ); + return $circ; + } + if ( !$circ->ok && $circ->alert_type && $circ->alert_type == 98 ) { # data corruption $circ->screen_msg("Checkin failed: data problem"); siplog( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" ); diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index e512350be8..5c51d0b748 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -54,6 +54,7 @@ sub do_checkin { my $cv_triggers_alert = $account->{cv_triggers_alert}; my $holds_block_checkin = $account->{holds_block_checkin}; my $holds_get_captured = $account->{holds_get_captured} // 1; + my @forbidden_notforloan_status = split(",",$account->{forbidden_notforloan_status}); if (!$branch) { $branch = 'SIP2'; @@ -108,6 +109,22 @@ sub do_checkin { $return = 1 unless keys %$messages; } + if (@forbidden_notforloan_status) { + my @results = grep { $_ == $item->notforloan } @forbidden_notforloan_status; + if (@results) { + my $notforloan_desc = + Koha::AuthorisedValues->get_description_by_koha_field( + { + kohafield => 'items.notforloan', + authorised_value => $item->notforloan + } + ); + my $f_status = $item->notforloan; + $f_status .= "-$notforloan_desc->{lib}" if $notforloan_desc->{lib}; + $messages->{ForbiddenNotForLoanStatus} = $f_status; + } + } + # biblionumber, biblioitemnumber, itemnumber # borrowernumber, reservedate, branchcode # cancellationdate, found, reservenotes, priority, timestamp @@ -142,6 +159,9 @@ sub do_checkin { $self->{item}->destination_loc($item->homebranch); $self->alert_type('04'); # send to other branch } + if ( $messages->{ForbiddenNotForLoanStatus} ) { + $self->alert_type('99'); + } if ($messages->{ResFound} || $checkin_blocked_by_holds ) { if ($checkin_blocked_by_holds) { $self->alert_type('99'); -- 2.30.2