Bug 19626: Calculate expiration date for existing holds based on waitingdate
authorNick Clemens <nick@bywatersolutions.com>
Wed, 15 Nov 2017 13:03:57 +0000 (13:03 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 26 Nov 2017 15:59:58 +0000 (12:59 -0300)
To test:
1 - Have/create a 16.11 instance with some waiting holds
2 - Those holds should not have an expirationdate
3 - Make sure some of the holds are waiting longer than
ReservesMaxPickupDelay
BACKUP THE DB
4 - Upgrade to 17.05 (or later)
5 - Check the expirationdate for the holds
6 - The date wil be in the future (curdate + delay)
7 - Restore DB
8 - Apply patch
9 - Run the upgrade again
10 - expirationdate should now be based on waitingdate

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/updatedatabase.pl

index ec4eee4..f12d8d0 100755 (executable)
@@ -14371,11 +14371,11 @@ if( CheckVersion( $DBversion ) ) {
         }
 
         my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
-        my $expirationdate = dt_from_string();
+        my $expirationdate = dt_from_string($hold->waitingdate);
         $expirationdate->add(days => $max_pickup_delay);
 
         if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
-            $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
+            $expirationdate = $calendar->days_forward( dt_from_string($hold->waitingdate), $max_pickup_delay );
         }
 
         my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;