From 91e4ab6053d081841bd2fb3ac3a95a894386e303 Mon Sep 17 00:00:00 2001 From: Marion Durand Date: Wed, 9 Apr 2025 13:09:14 +0000 Subject: [PATCH] Bug 34326: (follow-up) Add forbidden notforloan status option Add a SIP option to prevent the checkin of items if they have a special status. The follow-up fixes a bug where SIP reported a failed checkin even if the checkin was correctly done by Koha. Test plan (assuming ktd) 1- checkout 4 items to a single patron In the following example I used barcode 3999900000017, 3999900000018, 3999900000019 and 3999900000020 and the patron cardnumber 23529000035676 2- Update these items notforloan value ($7 in marc21, $o in unimarc) with 3 different not for loan status and an empty not for loan status In the following example I used 3999900000017 notforloan = 1 "Not for loan" 3999900000018 notforloan = 2 "Staff collection" 3999900000019 notforloan = 3 "Added to bundle" 3999900000020 notforloan is empty 3- Edit file /etc/koha/sites/kohadev/SIPconfig.xml Add to one of the login the parameter "forbidden_notforloan_status"" with two different notforloan status previously used In the following example I used 4- restart sip (in KTD "sudo koha-sip --stop kohadev" then "sudo koha-sip --start kohadev") 5- checkin the first two items with sip_cli_emulator (the ones with the forbidden notforloan status). The checkin should fail (response starts with 100), a screen message (AF field) is added to explain and these items should still be checked out to the patron in the interface /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000017 /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000018 6- checkin the last two items with sip_cli_emulator (the one with the allowed notforloan status and the one without any notforloan status). The checkin should succeed (response starts with 101) and these items should not appear in the checked out items to the patron in the interface. /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000019 /kohadevbox/koha/misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su=term1 -sp=term1 -l=CPL -m=checkin --patron=23529000035676 --item=3999900000020 --- C4/SIP/ILS/Transaction/Checkin.pm | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index 05e730e2f2..2de2b9f4bc 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -51,11 +51,11 @@ sub do_checkin { my $return_date = shift; my $account = shift; - my $checked_in_ok = $account->{checked_in_ok}; - 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}); + my $checked_in_ok = $account->{checked_in_ok}; + 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'; @@ -95,32 +95,33 @@ sub do_checkin { my $checkin_blocked_by_holds = $holds_block_checkin && $reserved; - ( $return, $messages, $issue, $borrower ) = AddReturn( $barcode, $branch, undef, $return_date ) - unless $human_required || $checkin_blocked_by_holds; - - if ($checked_in_ok) { - delete $messages->{ItemLocationUpdated}; - delete $messages->{NotIssued}; - delete $messages->{LocalUse}; - $return = 1 unless keys %$messages; - } - - if (@forbidden_notforloan_status) { + my $checkin_blocked_by_notforloan_status = 0; + if (@forbidden_notforloan_status) { my @results = grep { $_ == $item->notforloan } @forbidden_notforloan_status; if (@results) { - my $notforloan_desc = - Koha::AuthorisedValues->get_description_by_koha_field( + $checkin_blocked_by_notforloan_status = 1; + 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; } } + ( $return, $messages, $issue, $borrower ) = AddReturn( $barcode, $branch, undef, $return_date ) + unless $human_required || $checkin_blocked_by_holds || $checkin_blocked_by_notforloan_status; + + if ($checked_in_ok) { + delete $messages->{ItemLocationUpdated}; + delete $messages->{NotIssued}; + delete $messages->{LocalUse}; + $return = 1 unless keys %$messages; + } + # biblionumber, biblioitemnumber, itemnumber # borrowernumber, reservedate, branchcode # cancellationdate, found, reservenotes, priority, timestamp -- 2.39.5