From dc61af3f1237b0c54694904ae79260eeef7298fa 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 --- C4/SIP/ILS/Transaction/Checkout.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index d9056f1c824..d8bd50481e1 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,7 +145,13 @@ sub do_checkout { }); } else { # can issue - my $issue = AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0 ); + my $recall_id; + foreach (keys %{$messages}) { + if ( $_ eq "RECALLED" ) { + $recall_id = $messages->{RECALLED}; + } + } + my $issue = AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0, undef, undef, { recall_id => $recall_id } ); $self->{due} = $self->duedatefromissue($issue, $itemnumber); } @@ -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.30.2