Bug 12063: [QA Follow-up] Adjustments to db revision
Replace use by require. Add require Koha::Calendar (seriously needed to prevent crashing). Base expirationdate on today not on waitingdate (just as in Reserves). Remove if ( waitingdate ) construction. Not needed anymore. Remove $cancel_on_holidays. Not used. Note that the if construction around the new pref is not strictly needed at upgrade time (pref still zero). Fill the dbrev description. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
a08b309c4f
commit
2144fecdf0
|
|
@ -1,8 +1,10 @@
|
|||
$DBversion = 'XXX';
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
use Koha::Holds;
|
||||
require Koha::Calendar;
|
||||
require Koha::Holds;
|
||||
|
||||
my $waiting_holds = Koha::Holds->search({ found => 'W', priority => 0 });
|
||||
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
|
||||
while ( my $hold = $waiting_holds->next ) {
|
||||
|
||||
my $requested_expiration;
|
||||
|
|
@ -10,23 +12,18 @@ if( CheckVersion( $DBversion ) ) {
|
|||
$requested_expiration = dt_from_string($hold->expirationdate);
|
||||
}
|
||||
|
||||
if ( my $waitingdate = dt_from_string($hold->waitingdate) ) {
|
||||
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
|
||||
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
|
||||
my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
|
||||
my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
|
||||
my $expirationdate = dt_from_string();
|
||||
$expirationdate->add(days => $max_pickup_delay);
|
||||
|
||||
my $expirationdate = $waitingdate->clone;
|
||||
$expirationdate->add(days => $max_pickup_delay);
|
||||
|
||||
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
|
||||
$expirationdate = $calendar->days_forward( dt_from_string($hold->waitingdate), $max_pickup_delay );
|
||||
}
|
||||
|
||||
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
|
||||
$hold->expirationdate($cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd)->store;
|
||||
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
|
||||
$expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
|
||||
}
|
||||
|
||||
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
|
||||
$hold->expirationdate($cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd)->store;
|
||||
}
|
||||
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
|
||||
}
|
||||
print "Upgrade to $DBversion done (Bug 12063 - Update reserves.expirationdate)\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue