From 2ddd46d3d24ad8e90dfe0aca35b8033a7db86a28 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Wed, 13 Dec 2023 17:09:35 +0200 Subject: [PATCH] Bug 35559 - Allow the change of expiration date on the last day of expiration The result of this comparison will almost never be 0 as it requires the dates to be same down to a second: DateTime->compare( dt_from_string( $res->expirationdate ), dt_from_string() ) == -1 This patch fixes it. To reproduce: 1) Create or use existing hold that is awaiting pickup. 2) Set it's expiration date to today. (if you can't do it through koha interface, edit it in the database or wait for tomorrow to come) 3) Check that you can't change the expiration date anymore as it says "Expired: %date%" 4) Apply the patch 5) Check that you can change the expiration date --- reserve/request.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reserve/request.pl b/reserve/request.pl index 186b3faff5..8415b2a4a9 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -621,8 +621,12 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) } } $reserve{'expirationdate'} = $res->expirationdate; + + my $today = dt_from_string()->truncate(to => 'day'); + my $expirationdate = dt_from_string( $res->expirationdate )->truncate(to => 'day'); $reserve{'expired'} = 1 - if ( DateTime->compare( dt_from_string( $res->expirationdate ), dt_from_string() ) == -1 ); + if ( DateTime->compare( $expirationdate, $today ) == -1 ); + $reserve{'date'} = $res->reservedate; $reserve{'borrowernumber'} = $res->borrowernumber(); $reserve{'biblionumber'} = $res->biblionumber(); -- 2.42.0