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 <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-05-01 09:57:49 +01:00 committed by Katrin Fischer
parent 2e42bc5584
commit 7953b17243
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 26 additions and 26 deletions

View File

@ -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'},