Bug 31540: Exclude expired holds from the reminder job

Some libraries don't want to auto-cancel holds, but we should not remind
a patron about a hold which has expired.

To test:
1 - Place a hold for a patron
2 - Set it waiting
3 - Run the holds reminder script in the future
    perl misc/cronjobs/holds/holds_reminder.pl -day 1 --date '2023-09-12' -v
4 - Note the holds would be reminded
5 - Set expirationdate for the hold less than today
    UPDATE reserves SET expirationdate = DATE_SUB(CURDATE(), INTERVAL 1 DAY);
6 - Run the remidner cron again
7 - No holds trigger!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 4c3d18091d)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 6e3ff69730)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
(cherry picked from commit fce44867ac)
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit fce44867ac)
This commit is contained in:
Nick Clemens 2022-09-12 14:35:24 +00:00 committed by Wainui Witika-Park
parent 48f09bbc6b
commit 154af0fae7
1 changed files with 1 additions and 0 deletions

View File

@ -256,6 +256,7 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
my $reserves = Koha::Holds->search({
waitingdate => {$comparator => $waiting_since },
'me.branchcode' => $branchcode,
'-or' => [ expirationdate => undef, expirationdate => { '>' => \'CURDATE()' } ]
},{ prefetch => 'patron' });
$verbose and warn "No reserves found for $branchcode\n" unless $reserves->count;