From cfe350a3d77f3546649c4806c6f7fc3b6c7ca378 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 24 Aug 2023 09:27:28 +0200 Subject: [PATCH] Bug 27249: Catch NoOpenDays exception while checking out an item Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 4eec4020fa66f789f77637234aab81c46c3e6972) Signed-off-by: Fridolin Somers (cherry picked from commit b1feff4228b68260221fdad1d9fb2bee3904378a) Signed-off-by: Matt Blenkinsop --- circ/circulation.pl | 34 +++++++++++++------ .../prog/en/modules/circ/circulation.tt | 4 +++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index a9c357a513..328f9016ac 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -29,7 +29,8 @@ use CGI qw ( -utf8 ); use URI::Escape qw( uri_escape_utf8 ); use DateTime; use DateTime::Duration; -use Scalar::Util qw( looks_like_number ); +use Scalar::Util qw( blessed looks_like_number ); +use Try::Tiny; use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); use C4::Auth qw( get_session get_template_and_user ); use C4::Koha; @@ -297,16 +298,27 @@ if (@$barcodes) { }; # always check for blockers on issuing - my ( $error, $question, $alerts, $messages ) = CanBookBeIssued( - $patron, - $barcode, $datedue, - $inprocess, - undef, - { - onsite_checkout => $onsite_checkout, - override_high_holds => $override_high_holds || $override_high_holds_tmp || 0, + my ( $error, $question, $alerts, $messages ); + try { + ( $error, $question, $alerts, $messages ) = CanBookBeIssued( + $patron, + $barcode, $datedue, + $inprocess, + undef, + { + onsite_checkout => $onsite_checkout, + override_high_holds => $override_high_holds || $override_high_holds_tmp || 0, + } + ); + } catch { + die $_ unless blessed $_ && $_->can('rethrow'); + + if ($_->isa('Koha::Exceptions::Calendar::NoOpenDays')) { + $error = { NO_OPEN_DAYS => 1 }; + } else { + $_->rethrow; } - ); + }; my $blocker = $invalidduedate ? 1 : 0; @@ -353,7 +365,7 @@ if (@$barcodes) { # Only some errors will block when performing forced onsite checkout, # for other cases all errors will block my @blocking_error_codes = ($onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce")) ? - qw( UNKNOWN_BARCODE ) : (keys %$error); + qw( UNKNOWN_BARCODE NO_OPEN_DAYS ) : (keys %$error); foreach my $code ( @blocking_error_codes ) { if ($error->{$code}) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 60fc0015f2..278278d8d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -515,6 +515,10 @@ [% IF ( RECALLED_INTRANSIT ) %]
  • Item has been recalled and is in transit for pickup at [% Branches.GetName( RECALLED_INTRANSIT ) | html %].
  • [% END %] + + [% IF NO_OPEN_DAYS %] +
  • No open days found while calculating the due date. Check the library calendar.
  • + [% END %] [% IF (forceallow) %] -- 2.39.5