Bug 19260: Holds marked as problems being seen as expired ones and deleted wrongly
authorJosef Moravec <josef.moravec@gmail.com>
Thu, 5 Oct 2017 20:37:25 +0000 (20:37 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 6 Oct 2017 13:59:41 +0000 (10:59 -0300)
Test plan:
0) Apply just the first patch - the one with test
1) Run t/db_dependent/Reserves.t - test for CancelExpiredReserves should
fail
2) Apply the second patch
3) t/db_dependent/Reserves.t should pass now

Followed test plan, patch worked as described. Passes QA test tool

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Reserves.pm

index fbf03fb..3d011a6 100644 (file)
@@ -799,16 +799,18 @@ sub CancelExpiredReserves {
 
     my $today = dt_from_string();
     my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
+    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
 
     my $dbh = C4::Context->dbh;
 
     my $dtf = Koha::Database->new->schema->storage->datetime_parser;
+
+    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
+
+    $params->{found} = undef unless $expireWaiting;
+
     # FIXME To move to Koha::Holds->search_expired (?)
-    my $holds = Koha::Holds->search(
-        {
-            expirationdate => { '<', $dtf->format_date($today) }
-        }
-    );
+    my $holds = Koha::Holds->search( $params );
 
     while ( my $hold = $holds->next ) {
         my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );