Browse Source

Bug 14708: Skip AnonymousPatron in GetBorrowersToExpunge

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Kyle Hall 1 year ago
committed by Jonathan Druart
parent
commit
f18118f18f
  1. 5
      C4/Members.pm
  2. 12
      t/db_dependent/Members.t

5
C4/Members.pm

@ -437,6 +437,11 @@ sub GetBorrowersToExpunge {
push @query_params,$filterdate;
}
if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) {
$query .= q{ AND borrowernumber != ? };
push( @query_params, $anonymous_patron );
}
warn $query if $debug;
my $sth = $dbh->prepare($query);

12
t/db_dependent/Members.t

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 47;
use Test::More tests => 48;
use Test::MockModule;
use Test::Exception;
@ -248,11 +248,19 @@ $builder->build({
# IndependentBranches is off.
t::lib::Mocks::mock_preference('IndependentBranches', 0);
my $anonymous_patron = Koha::Patron->new({ categorycode => 'CIVILIAN', branchcode => $library2->{branchcode} })->store->borrowernumber;
t::lib::Mocks::mock_preference('AnonymousPatron', $anonymous_patron);
my $owner = Koha::Patron->new({ categorycode => 'STAFFER', branchcode => $library2->{branchcode} })->store->borrowernumber;
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } );
AddPatronsToList( { list => $list1, borrowernumbers => [$anonymous_patron] } );
my $patstodel = GetBorrowersToExpunge( { patron_list_id => $list1->patron_list_id() } );
is( scalar(@$patstodel), 0, 'Anonymous Patron not deleted from list' );
my @listpatrons = ($bor1inlist, $bor2inlist);
AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons });
my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } );
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } );
is( scalar(@$patstodel),0,'No staff deleted from list of all staff');
Koha::Patrons->find($bor2inlist)->set({ categorycode => 'CIVILIAN' })->store;
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );

Loading…
Cancel
Save