Bug 31095: Remove GetDebarments from Circulation.pm
This patch removes GetDebarments from Circulation.pm replacing them with
calls to $patron->restrictions and filtering using a chained search
call.
Test plan
1. Confirm that t/db_dependant/Circulation.t continues to pass
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0f15a74853)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
49664013b1
commit
500cc50a8d
|
|
@ -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;
|
||||
|
|
@ -2558,10 +2558,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' });
|
||||
}
|
||||
|
|
@ -2650,9 +2651,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -3189,10 +3191,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' });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue