From bcd643f96fa3b59b031e0ee51d2dc5d4d5e362c7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 24 Aug 2022 16:47:54 +0100 Subject: [PATCH] Bug 31095: Remove GetDebarments from Circulation.pm --- C4/Circulation.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 7b028bed0f..70bb935afb 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -48,7 +48,7 @@ use Koha::Checkouts; use Koha::Illrequests; use Koha::Items; use Koha::Patrons; -use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments AddUniqueDebarment ); +use Koha::Patron::Debarments qw( DelUniqueDebarment AddUniqueDebarment ); use Koha::Database; use Koha::Libraries; use Koha::Account::Lines; @@ -2529,10 +2529,11 @@ sub MarkIssueReturned { } # Remove any OVERDUES related debarment if the borrower has no overdues + my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' }); if ( C4::Context->preference('AutoRemoveOverduesRestrictions') && $patron->debarred && !$patron->has_overdues - && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) } + && $overdue_restrictions->count ) { DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); } @@ -2621,9 +2622,10 @@ sub _calculate_new_debar_dt { my ( $has_been_extended ); if ( C4::Context->preference('CumulativeRestrictionPeriods') and $borrower->{debarred} ) { - my $debarment = @{ GetDebarments( { borrowernumber => $borrower->{borrowernumber}, type => 'SUSPENSION' } ) }[0]; + my $patron = Koha::Patrons->find($borrower->{borrowernumber}); + my $debarment = $patron->restrictions->search({type => 'SUSPENSION' },{rows => 1})->single; if ( $debarment ) { - $return_date = dt_from_string( $debarment->{expiration}, 'sql' ); + $return_date = dt_from_string( $debarment->expiration, 'sql' ); $has_been_extended = 1; } } @@ -3210,10 +3212,11 @@ sub AddRenewal { } # Remove any OVERDUES related debarment if the borrower has no overdues + my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' }); if ( $patron && $patron->is_debarred && ! $patron->has_overdues - && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) } + && $overdue_restrictions->count ) { DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); } -- 2.20.1