Bug 40058: Remove RevertWaitingStatus()

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a137c7a183)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Tomas Cohen Arazi 2025-06-03 10:31:42 -03:00 committed by Paul Derscheid
parent a14cccd575
commit 12e98336db
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
3 changed files with 11 additions and 68 deletions

View File

@ -27,7 +27,7 @@ use Try::Tiny;
use C4::Context;
use C4::Stats qw( UpdateStats );
use C4::Reserves
qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest );
qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority IsAvailableForItemLevelRequest );
use C4::Biblio qw( UpdateTotalIssues );
use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf );
use C4::Accounts;
@ -2563,9 +2563,12 @@ sub AddReturn {
my $lookahead = C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $item, $lookahead ) unless ( $item->withdrawn );
# FIXME: CheckReserves should return the Koha::Hold
my $hold = Koha::Holds->find( $resrec->{reserve_id} );
# if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly)
if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
$hold->revert_waiting();
$resfound = 'Reserved';
$resrec = $hold->unblessed;
}

View File

@ -137,8 +137,6 @@ BEGIN {
GetMaxPatronHoldsForRecord
MergeHolds
RevertWaitingStatus
);
}
@ -2085,10 +2083,10 @@ sub MoveReserve {
$hold->fill( { item_id => $item->id } );
}
if ( $cancelreserve eq 'revert' ) { ## Revert waiting reserve to priority 1
RevertWaitingStatus( { itemnumber => $item->id } );
$hold = Koha::Holds->find( $res->{reserve_id} );
if ( $cancelreserve eq 'revert' ) {
$hold->revert_waiting();
} elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item
my $hold = Koha::Holds->find( $res->{reserve_id} );
$hold->cancel;
}
}
@ -2135,65 +2133,6 @@ sub MergeHolds {
}
}
=head2 RevertWaitingStatus
RevertWaitingStatus({ itemnumber => $itemnumber });
Reverts a 'waiting' hold back to a regular hold with a priority of 1.
Caveat: Any waiting hold fixed with RevertWaitingStatus will be an
item level hold, even if it was only a bibliolevel hold to
begin with. This is because we can no longer know if a hold
was item-level or bib-level after a hold has been set to
waiting status.
=cut
sub RevertWaitingStatus {
my ($params) = @_;
my $itemnumber = $params->{'itemnumber'};
return unless ($itemnumber);
my $dbh = C4::Context->dbh;
## Get the waiting reserve we want to revert
my $hold = Koha::Holds->search(
{
itemnumber => $itemnumber,
found => { not => undef },
}
)->next;
my $original = C4::Context->preference('HoldsLog') ? $hold->unblessed : undef;
## Increment the priority of all other non-waiting
## reserves for this bib record
my $holds = Koha::Holds->search( { biblionumber => $hold->biblionumber, priority => { '>' => 0 } } )
->update( { priority => \'priority + 1' }, { no_triggers => 1 } );
## Fix up the currently waiting reserve
$hold->set(
{
priority => 1,
found => undef,
waitingdate => undef,
expirationdate => $hold->patron_expiration_date,
itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef,
}
)->store( { hold_reverted => 1 } );
logaction( 'HOLDS', 'MODIFY', $hold->id, $hold, undef, $original )
if C4::Context->preference('HoldsLog');
_FixPriority( { biblionumber => $hold->biblionumber } );
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $hold->biblionumber ] } )
if C4::Context->preference('RealTimeHoldsQueue');
return $hold;
}
=head2 ReserveSlip
ReserveSlip(

View File

@ -33,7 +33,7 @@ use Date::Calc qw( Date_to_Days );
use C4::Output qw( output_html_with_http_headers );
use C4::Auth qw( get_template_and_user );
use C4::Reserves
qw( RevertWaitingStatus AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest );
qw( AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest );
use C4::Items qw( get_hostitemnumbers_of );
use C4::Koha qw( getitemtypeimagelocation );
use C4::Serials qw( CountSubscriptionFromBiblionumber );
@ -102,7 +102,8 @@ if ( $op eq 'cud-move' ) {
my $last_priority = $input->param('last_priority');
my $hold_itemnumber = $input->param('itemnumber');
if ( $prev_priority == 0 && $next_priority == 1 ) {
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } );
my $hold = Koha::Holds->find($reserve_id);
$hold->revert_waiting();
} else {
AlterPriority(
$where, $reserve_id, $prev_priority,