From 7a8bed557618e26f867a74f53c1391c12acfb77a Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 23 Jun 2011 14:11:48 +0100 Subject: [PATCH] Bug 5549 : Daily loans should be due at 23:59 This was failing in one patch through CalcDueDate --- C4/Circulation.pm | 4 ++++ t/db_dependent/rollingloans.t | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index bbff8ae862..49bd7b2e82 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2838,6 +2838,10 @@ sub CalcDateDue { } my $calendar = Koha::Calendar->new( branchcode => $branch ); $datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); + if ($loanlength->{lengthunit} eq 'days') { + $datedue->set_hour(23); + $datedue->set_minute(59); + } } } diff --git a/t/db_dependent/rollingloans.t b/t/db_dependent/rollingloans.t index 9535ff5c16..af9e454267 100644 --- a/t/db_dependent/rollingloans.t +++ b/t/db_dependent/rollingloans.t @@ -6,7 +6,7 @@ use C4::Context; use C4::Circulation; use C4::Members; -use Test::More tests => 6; +use Test::More tests => 8; C4::Context->_new_userenv(1234567); C4::Context->set_userenv(91, 'CLIstaff', '23529001223661', 'CPL', 'CPL', 'CPL', '', 'cc@cscnet.co.uk'); @@ -20,6 +20,10 @@ my $test_item_48 = '502326000403'; for my $item_barcode ( $test_item_fic, $test_item_24, $test_item_48) { my $duedate = try_issue($test_patron, $item_barcode); isa_ok($duedate, 'DateTime'); + if ($item_barcode eq $test_item_fic) { + is($duedate->hour(), 23, "daily loan hours = 23"); + is($duedate->minute(), 59, "daily loan mins = 59"); + } my $ret_ok = try_return($item_barcode); is($ret_ok, 1, 'Return succeeded'); } -- 2.20.1