Bug 14918: [QA Follow-up] Correct enddate and use constant

Corrected enddate (subtraction in the revised code must be an addition).
Replaced hardcoded 2 days by a constant.
Renamed the constant TWO_DAYS to PULL_INTERVAL.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested all three date formats.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2015-10-23 08:47:58 +02:00 committed by Tomas Cohen Arazi
parent c43e10f06e
commit 304dd2b051

View file

@ -1,6 +1,5 @@
#!/usr/bin/perl
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@ -26,7 +25,7 @@
use strict;
#use warnings; FIXME - Bug 2505
use constant TWO_DAYS => 2;
use constant PULL_INTERVAL => 2;
use C4::Context;
use C4::Output;
@ -79,7 +78,7 @@ if ( $startdate ) {
unless ( $startdate ){
# changed from delivered range of 10 years-yesterday to 2 days ago-today
# Find two days ago for the default shelf pull start date, unless HoldsToPullStartDate sys pref is set.
$startdate = $today - DateTime::Duration->new( days => C4::Context->preference('HoldsToPullStartDate') || 2 );
$startdate = $today - DateTime::Duration->new( days => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL );
}
if ( $enddate ) {
@ -87,7 +86,7 @@ if ( $enddate ) {
}
unless ( $enddate ) {
#similarly: calculate end date with ConfirmFutureHolds (days)
$enddate = $today - DateTime::Duration->new( days => C4::Context->preference('ConfirmFutureHolds') || 0 );
$enddate = $today + DateTime::Duration->new( days => C4::Context->preference('ConfirmFutureHolds') || 0 );
}
my @reservedata;
@ -206,8 +205,8 @@ $template->param(
run_report => $run_report,
reserveloop => \@reservedata,
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
HoldsToPullStartDate=> C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS,
HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds')||0,
HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL,
HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds') || 0,
);
output_html_with_http_headers $input, $cookie, $template->output;