From 27360a6ed0848ca35b28d02338a95abb9b827287 Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Tue, 22 May 2018 14:36:39 -0400 Subject: [PATCH] Bug 17015: Improve stability for very old loans This patch fixes a crash when calculating fines for hourly loans created before the earliest date in the 'discrete_calendar' table. The SQL call has been altered to find the closest day (using DATEDIFF). QA Green. --- Koha/DiscreteCalendar.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm index 1ea5b12..c8c1e31 100644 --- a/Koha/DiscreteCalendar.pm +++ b/Koha/DiscreteCalendar.pm @@ -1143,7 +1143,8 @@ sub open_hours_between { branchcode => $branchcode, }, { - where => \['date = DATE(?)', $start_date], + order_by => \[ 'ABS(DATEDIFF(date, ?))', $start_date ], + rows => 1, } ); @@ -1152,7 +1153,8 @@ sub open_hours_between { branchcode => $branchcode, }, { - where => \['date = DATE(?)', $end_date], + order_by => \[ 'ABS(DATEDIFF(date, ?))', $end_date ], + rows => 1, } ); -- 2.7.4