From 3c4677efc765979643315c238c405843fe9be654 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 8 Jan 2018 11:15:02 -0300 Subject: [PATCH] Bug 19935: Replace GetPendingIssues - Discharges We should actually use Koha::Patron->checkouts here to avoid the prefetch. Test plan: A patron with checkouts cannot get a discharge Signed-off-by: Benjamin Rokseth Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- Koha/Patron/Discharge.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm index a1f4942be1..2f3c4e4ed4 100644 --- a/Koha/Patron/Discharge.pm +++ b/Koha/Patron/Discharge.pm @@ -6,7 +6,6 @@ use File::Temp qw( :POSIX ); use Carp; use C4::Templates qw ( gettemplate ); -use C4::Members qw( GetPendingIssues ); use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); @@ -34,13 +33,11 @@ sub can_be_discharged { my ($params) = @_; return unless $params->{borrowernumber}; - my $issues = GetPendingIssues( $params->{borrowernumber} ); - if( @$issues ) { - return 0; - } - else { - return 1; - } + my $patron = Koha::Patrons->find( $params->{borrowernumber} ); + return unless $patron; + + my $has_pending_checkouts = $patron->pending_checkouts->count; + return $has_pending_checkouts ? 0 : 1; } sub is_discharged { -- 2.39.5