Bug 5549 : Daily loans should be due at 23:59
authorColin Campbell <colin.campbell@ptfs-europe.com>
Thu, 23 Jun 2011 13:11:48 +0000 (14:11 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 20 Mar 2012 00:25:41 +0000 (13:25 +1300)
This was failing in one patch through CalcDueDate

C4/Circulation.pm
t/db_dependent/rollingloans.t

index bbff8ae..49bd7b2 100644 (file)
@@ -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);
+            }
         }
     }
 
index 9535ff5..af9e454 100644 (file)
@@ -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');
 }