From 4eec4020fa66f789f77637234aab81c46c3e6972 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 --- 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 99cee0c87b..de416ff7a7 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; @@ -298,16 +299,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; @@ -354,7 +366,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 3388e387a5..c472d66ac4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -517,6 +517,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