From 7953b1724361b62f7a3ee4424eca2ae5e6e01f00 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. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- circ/circulation.pl | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index e0a732f7bd..81e0f337ae 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.39.5