From 5935132dd9342fdaccdc49cc81deebbea4d4a4d5 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 29 Aug 2014 09:40:09 -0400 Subject: [PATCH] Bug 12847 - Date comparisons in C4::Members::IssueSlip are broken Test Plan: 1) Ensure you have the default Koha issue slip 2) Check out an item 3) Print the issue slip for that patron 4) Even though the item is not overdue, it will show in the 'Overdues' section 5) Apply this patch 6) Re-print the issue slip 7) The item should no longer be in the overdues section --- C4/Members.pm | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 326344d..2c388fe 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -2346,20 +2346,28 @@ sub DeleteMessage { sub IssueSlip { my ($branch, $borrowernumber, $quickslip) = @_; -# return unless ( C4::Context->boolean_preference('printcirculationslips') ); - - my $now = POSIX::strftime("%Y-%m-%d", localtime); + my $now = dt_from_string(); + $now->truncate( to => 'day' ); my $issueslist = GetPendingIssues($borrowernumber); - foreach my $it (@$issueslist){ - if ((substr $it->{'issuedate'}, 0, 10) eq $now || (substr $it->{'lastreneweddate'}, 0, 10) eq $now) { + foreach my $it (@$issueslist) { + + my $dt_issuedate = dt_from_string( $it->{'issuedate'} ); + $dt_issuedate->truncate( to => 'day' ); + my $dt_lastreneweddate = dt_from_string( $it->{'lastreneweddate'} ); + $dt_lastreneweddate->truncate( to => 'day' ); + my $dt_date_due = dt_from_string( $it->{'date_due'} ); + $dt_date_due->truncate( to => 'day' ); + + if ( $dt_issuedate == $now || $dt_lastreneweddate == $now ) { $it->{'now'} = 1; } - elsif ((substr $it->{'date_due'}, 0, 10) le $now) { + elsif ( $dt_date_due < $now ) { $it->{'overdue'} = 1; } - my $dt = dt_from_string( $it->{'date_due'} ); - $it->{'date_due'} = output_pref( $dt );; + + # Recreate date_due as DateTime because we truncated the hours + $it->{'date_due'} = output_pref( dt_from_string( $it->{'date_due'} ) ); } my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist; -- 1.7.2.5