From 1bd3f2cc1bb0dac9c524e96b97dec3cd7145b3ca Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 15 Jun 2023 17:21:37 +1200 Subject: [PATCH] Bug 34016: Manage recalls via SIP This enhancement allows SIP to better handle recalled items - preventing the check-out of recalled items if they have been allocated to another patron, or fulfilling recalls if the item was recalled and allocated to this patron. To test: 1. Run test `prove t/db_dependent/SIP/Transaction.t` 2. Confirm the test fails when trying to fulfill the recall 3. Apply the patch and restart services 4. Run test again `prove t/db_dependent/SIP/Transaction.t` 5. Confirm tests pass Sponsored-by: Auckland University of Technology Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- C4/SIP/ILS/Transaction/Checkout.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index 990545a02e..f2b6007908 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -48,7 +48,7 @@ sub do_checkout { my $patron = Koha::Patrons->find($self->{patron}->{borrowernumber}); my $overridden_duedate; # usually passed as undef to AddIssue my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; - my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode, 0); + my ($issuingimpossible, $needsconfirmation, $messages) = _can_we_issue($patron, $barcode, 0); if ( $no_block_due_date ) { my $year = substr($no_block_due_date,0,4); @@ -108,6 +108,10 @@ sub do_checkout { $self->screen_msg('Item must be checked out at a circulation desk'); $noerror = 0; last; + } elsif ( $confirmation eq 'RECALLED' ) { + $self->screen_msg('Item has been recalled for another patron'); + $noerror = 0; + last; } else { # We've been returned a case other than those above $self->screen_msg("Item cannot be issued: $confirmation"); @@ -141,8 +145,14 @@ sub do_checkout { }); } else { # can issue - my $issue = AddIssue( $patron, $barcode, $overridden_duedate, 0 ); - $self->{due} = $self->duedatefromissue($issue, $itemnumber); + my $recall_id; + foreach ( keys %{$messages} ) { + if ( $_ eq "RECALLED" ) { + $recall_id = $messages->{RECALLED}; + } + } + my $issue = AddIssue( $patron, $barcode, $overridden_duedate, 0, undef, undef, { recall_id => $recall_id } ); + $self->{due} = $self->duedatefromissue( $issue, $itemnumber ); } $self->ok(1); @@ -152,7 +162,7 @@ sub do_checkout { sub _can_we_issue { my ( $patron, $barcode, $pref ) = @_; - my ( $issuingimpossible, $needsconfirmation, $alerts ) = + my ( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( $patron, $barcode, undef, 0, $pref ); for my $href ( $issuingimpossible, $needsconfirmation ) { @@ -163,7 +173,7 @@ sub _can_we_issue { } } } - return ( $issuingimpossible, $needsconfirmation ); + return ( $issuingimpossible, $needsconfirmation, $messages ); } 1; -- 2.39.5