From 120d3c83013774862aa6dbb5495f18846576fb7b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 1 May 2024 09:57:49 +0100 Subject: [PATCH] Bug 27753: (QA follow-up) Check that item exists before using it We're actioning the change of claim status outside of any block that checks the $item exists. As such we'll want to add that check in here. I did consider that this should live inside AddIssue, but on reflection the librarian may want to not proceed with the issue given other return values from the CanBookBeIssued call, but you still want the AutoClaimReturn to fire regardless as you've now found the item. --- circ/circulation.pl | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index e0a732f7bd0..81e0f337aec 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -438,6 +438,32 @@ if (@$barcodes && $op eq 'cud-checkout') { delete $needsconfirmation->{'DEBT'} if ($debt_confirmed); + if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) { + my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); + + my $claims = Koha::Checkouts::ReturnClaims->search( + { + itemnumber => $item->id, + } + ); + if ( $claims->count ) { + if ($autoClaimReturnCheckout) { + my $claim = $claims->next; + + my $patron_id = $patron->borrowernumber; + my $resolution = $autoClaimReturnCheckout; + + $claim->resolve( + { + resolution => $resolution, + resolved_by => $patron_id, + } + ); + $template_params->{CLAIM_RESOLUTION} = $claim; + } + } + } + if( $item and ( !$blocker or $force_allow_issue ) ){ my $confirm_required = 0; unless($issueconfirmed){ @@ -497,32 +523,6 @@ if (@$barcodes && $op eq 'cud-checkout') { } } - if ( C4::Context->preference('ClaimReturnedLostValue') ) { - my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); - - my $claims = Koha::Checkouts::ReturnClaims->search( - { - itemnumber => $item->id, - } - ); - if ( $claims->count ) { - if ($autoClaimReturnCheckout) { - my $claim = $claims->next; - - my $patron_id = $patron->borrowernumber; - my $resolution = $autoClaimReturnCheckout; - - $claim->resolve( - { - resolution => $resolution, - resolved_by => $patron_id, - } - ); - $template_params->{CLAIM_RESOLUTION} = $claim; - } - } - } - if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){ $template->param( reserveborrowernumber => $needsconfirmation->{'resborrowernumber'}, -- 2.44.0