Browse Source

Bug 15548: Move new patron related code to Patron*

The 'borrower' should not be used anymore, especially for new code.
This patch move files and rename variables newly pushed (i.e. in the Koha
namespace).

Test plan:
1/
  git grep Koha::Borrower
should not return code in use.

2/
Prove the different modified test files

3/ Do some clicks in the member^Wpatron module to be sure there is not
an obvious error.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as described. Tested with Circulation, Members/Patrons, Discharge,
Restrictions modules and the must common functionalities

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
new_12478_elasticsearch
Jonathan Druart 6 years ago
committed by Jesse Weaver
parent
commit
3691bd8419
  1. 12
      C4/Circulation.pm
  2. 4
      C4/Members.pm
  3. 6
      Koha/Hold.pm
  4. 6
      Koha/Item.pm
  5. 2
      Koha/Misc/Files.pm
  6. 8
      Koha/Patron.pm
  7. 8
      Koha/Patron/Debarments.pm
  8. 6
      Koha/Patron/Discharge.pm
  9. 12
      Koha/Patron/Files.pm
  10. 30
      Koha/Patron/Modifications.pm
  11. 8
      Koha/Patrons.pm
  12. 4
      Koha/REST/V1.pm
  13. 6
      Koha/REST/V1/Patrons.pm
  14. 4
      Koha/Template/Plugin/Borrowers.pm
  15. 4
      Koha/Virtualshelf.pm
  16. 6
      about.pl
  17. 4
      admin/categories.pl
  18. 2
      circ/circulation.pl
  19. 4
      circ/ysearch.pl
  20. 8
      mainpage.pl
  21. 12
      members/discharge.pl
  22. 6
      members/discharges.pl
  23. 6
      members/files.pl
  24. 2
      members/memberentry.pl
  25. 4
      members/members-home.pl
  26. 6
      members/members-update-do.pl
  27. 4
      members/members-update.pl
  28. 2
      members/mod_debarment.pl
  29. 3
      members/moremember.pl
  30. 4
      misc/cronjobs/cleanup_database.pl
  31. 4
      misc/cronjobs/longoverdue.pl
  32. 2
      misc/cronjobs/overdue_notices.pl
  33. 12
      opac/opac-discharge.pl
  34. 11
      opac/opac-memberentry.pl
  35. 4
      opac/opac-privacy.pl
  36. 8
      opac/opac-registration-verify.pl
  37. 2
      opac/opac-reserve.pl
  38. 2
      opac/opac-user.pl
  39. 2
      reserve/request.pl
  40. 343
      t/Borrower.t
  41. 343
      t/Patron.t
  42. 6
      t/db_dependent/Accounts.t
  43. 4
      t/db_dependent/BiblioObject.t
  44. 4
      t/db_dependent/Circulation/AnonymiseIssueHistory.t
  45. 2
      t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t
  46. 2
      t/db_dependent/Creators/Lib.t
  47. 4
      t/db_dependent/Hold.t
  48. 40
      t/db_dependent/Koha_borrower_modifications.t
  49. 12
      t/db_dependent/Patron.t
  50. 8
      t/db_dependent/Patron/Borrower_Debarments.t
  51. 60
      t/db_dependent/Patron/Borrower_Discharge.t
  52. 4
      t/db_dependent/Patron/Borrower_Files.t
  53. 42
      t/db_dependent/Patrons.t
  54. 8
      t/db_dependent/Review.t
  55. 2
      t/db_dependent/api/v1/patrons.t
  56. 2
      tools/import_borrowers.pl

12
C4/Circulation.pm

@ -48,8 +48,8 @@ use Data::Dumper;
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Items;
use Koha::Borrowers;
use Koha::Borrower::Debarments;
use Koha::Patrons;
use Koha::Patron::Debarments;
use Koha::Database;
use Koha::Libraries;
use Carp;
@ -2201,7 +2201,7 @@ sub MarkIssueReturned {
if ( C4::Context->preference('StoreLastBorrower') ) {
my $item = Koha::Items->find( $itemnumber );
my $patron = Koha::Borrowers->find( $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
$item->last_returned_by( $patron );
}
}
@ -2265,13 +2265,13 @@ sub _debar_user_on_return {
my $new_debar_dt =
$dt_today->clone()->add_duration( $suspension_days );
Koha::Borrower::Debarments::AddUniqueDebarment({
Koha::Patron::Debarments::AddUniqueDebarment({
borrowernumber => $borrower->{borrowernumber},
expiration => $new_debar_dt->ymd(),
type => 'SUSPENSION',
});
# if borrower was already debarred but does not get an extra debarment
if ( $borrower->{debarred} eq Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
if ( $borrower->{debarred} eq Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
return ($borrower->{debarred},1);
}
return $new_debar_dt->ymd();
@ -2834,7 +2834,7 @@ sub CanBookBeRenewed {
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
my $hasoverdues = C4::Members::HasOverdues($borrowernumber);
if ( $restricted and $restrictionblockrenewing ) {

4
C4/Members.pm

@ -36,7 +36,7 @@ use C4::NewsChannels; #get slip news
use DateTime;
use Koha::Database;
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Text::Unaccent qw( unac_string );
use Koha::AuthUtils qw(hash_password);
use Koha::Database;
@ -516,7 +516,7 @@ sub IsMemberBlocked {
my $borrowernumber = shift;
my $dbh = C4::Context->dbh;
my $blockeddate = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $blockeddate = Koha::Patron::Debarments::IsDebarred($borrowernumber);
return ( 1, $blockeddate ) if $blockeddate;

6
Koha/Hold.pm

@ -24,7 +24,7 @@ use Carp;
use C4::Context qw(preference);
use Koha::DateUtils qw(dt_from_string);
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Biblios;
use Koha::Items;
use Koha::Libraries;
@ -223,14 +223,14 @@ sub branch {
=head3 borrower
Returns the related Koha::Borrower object for this Hold
Returns the related Koha::Patron object for this Hold
=cut
sub borrower {
my ($self) = @_;
$self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() );
$self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
return $self->{_borrower};
}

6
Koha/Item.pm

@ -23,7 +23,7 @@ use Carp;
use Koha::Database;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Libraries;
use base qw(Koha::Object);
@ -78,7 +78,7 @@ sub holding_branch {
Gets and sets the last borrower to return an item.
Accepts and returns Koha::Borrower objects
Accepts and returns Koha::Patron objects
$item->last_returned_by( $borrowernumber );
@ -99,7 +99,7 @@ sub last_returned_by {
unless ( $self->{_last_returned_by} ) {
my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } );
if ($result) {
$self->{_last_returned_by} = Koha::Borrowers->find( $result->get_column('borrowernumber') );
$self->{_last_returned_by} = Koha::Patrons->find( $result->get_column('borrowernumber') );
}
}

2
Koha/Misc/Files.pm

@ -255,7 +255,7 @@ __END__
=head1 SEE ALSO
Koha::Borrower::Files
Koha::Patron::Files
=head1 AUTHOR

8
Koha/Borrower.pm → Koha/Patron.pm

@ -1,4 +1,4 @@
package Koha::Borrower;
package Koha::Patron;
# Copyright ByWater Solutions 2014
#
@ -27,7 +27,7 @@ use base qw(Koha::Object);
=head1 NAME
Koha::Borrower - Koha Borrower Object class
Koha::Patron - Koha Patron Object class
=head1 API
@ -37,14 +37,14 @@ Koha::Borrower - Koha Borrower Object class
=head3 guarantor
Returns a Koha::Borrower object for this borrower's guarantor
Returns a Koha::Patron object for this patron's guarantor
=cut
sub guarantor {
my ( $self ) = @_;
return Koha::Borrowers->find( $self->guarantorid() );
return Koha::Patrons->find( $self->guarantorid() );
}
=head3 type

8
Koha/Borrower/Debarments.pm → Koha/Patron/Debarments.pm

@ -1,4 +1,4 @@
package Koha::Borrower::Debarments;
package Koha::Patron::Debarments;
# This file is part of Koha.
#
@ -36,9 +36,9 @@ our @EXPORT = qw(
IsDebarred
);
=head1 Koha::Borrower::Debarments
=head1 Koha::Patron::Debarments
Koha::Borrower::Debarments - Module for managing borrower debarments
Koha::Patron::Debarments - Module for managing patron debarments
=cut
@ -174,7 +174,7 @@ sub ModDebarment {
my $debarment_expiration = IsDebarred( $borrowernumber );
Returns the date a borrowers debarment will expire, or
undef if the borrower is not debarred
undef if the patron is not debarred
=cut

6
Koha/Borrower/Discharge.pm → Koha/Patron/Discharge.pm

@ -1,4 +1,4 @@
package Koha::Borrower::Discharge;
package Koha::Patron::Discharge;
use Modern::Perl;
use CGI;
@ -51,7 +51,7 @@ sub is_discharged {
my $borrowernumber = $params->{borrowernumber};
my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
my $validated = get_validated({borrowernumber => $borrowernumber});
if ($restricted && $validated) {
@ -85,7 +85,7 @@ sub discharge {
}
# Debar the member
Koha::Borrower::Debarments::AddDebarment({
Koha::Patron::Debarments::AddDebarment({
borrowernumber => $borrowernumber,
type => 'DISCHARGE',
});

12
Koha/Borrower/Files.pm → Koha/Patron/Files.pm

@ -1,4 +1,4 @@
package Koha::Borrower::Files;
package Koha::Patron::Files;
# Copyright 2012 Kyle M Hall
#
@ -33,7 +33,7 @@ BEGIN {
=head1 NAME
Koha::Borrower::Files - Module for managing borrower files
Koha::Patron::Files - Module for managing patron files
=head1 METHODS
@ -52,7 +52,7 @@ sub new {
=item GetFilesInfo()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $files_hashref = $bf->GetFilesInfo
=cut
@ -79,7 +79,7 @@ sub GetFilesInfo {
=item AddFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
$bh->AddFile( name => $filename, type => $mimetype,
description => $description, content => $content );
@ -107,7 +107,7 @@ sub AddFile {
=item GetFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $file = $bh->GetFile( file_id => $file_id );
=cut
@ -128,7 +128,7 @@ sub GetFile {
=item DelFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
$bh->DelFile( file_id => $file_id );
=cut

30
Koha/Borrower/Modifications.pm → Koha/Patron/Modifications.pm

@ -1,4 +1,4 @@
package Koha::Borrower::Modifications;
package Koha::Patron::Modifications;
# Copyright 2012 ByWater Solutions
# This file is part of Koha.
@ -18,7 +18,7 @@ package Koha::Borrower::Modifications;
=head1 NAME
C4::Borrowers::Modifications
Koha::Patron::Modifications
=cut
@ -35,9 +35,9 @@ sub new {
=head2 AddModifications
Koha::Borrower::Modifications->AddModifications( $data );
Koha::Patron::Modifications->AddModifications( $data );
Adds or updates modifications for a borrower.
Adds or updates modifications for a patron
Requires either the key borrowernumber, or verification_token
to be part of the passed in hash.
@ -67,7 +67,7 @@ sub AddModifications {
=head2 Verify
$verified = Koha::Borrower::Modifications->Verify( $verification_token );
$verified = Koha::Patron::Modifications->Verify( $verification_token );
Returns true if the passed in token is valid.
@ -96,9 +96,9 @@ sub Verify {
=head2 GetPendingModificationsCount
$count = Koha::Borrower::Modifications->GetPendingModificationsCount();
$count = Koha::Patron::Modifications->GetPendingModificationsCount();
Returns the number of pending modifications for existing borrowers.
Returns the number of pending modifications for existing patron.
=cut
@ -128,9 +128,9 @@ sub GetPendingModificationsCount {
=head2 GetPendingModifications
$arrayref = Koha::Borrower::Modifications->GetPendingModifications();
$arrayref = Koha::Patron::Modifications->GetPendingModifications();
Returns an arrayref of hashrefs for all pending modifications for existing borrowers.
Returns an arrayref of hashrefs for all pending modifications for existing patrons.
=cut
@ -168,7 +168,7 @@ sub GetPendingModifications {
=head2 ApproveModifications
Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
Commits the pending modifications to the borrower record and removes
them from the modifications table.
@ -197,10 +197,10 @@ sub ApproveModifications {
=head2 DenyModifications
Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
Koha::Patron::Modifications->DenyModifications( $borrowernumber );
Removes the modifications from the table for the given borrower,
without commiting the changes to the borrower record.
Removes the modifications from the table for the given patron,
without committing the changes to the patron record.
=cut
@ -217,7 +217,7 @@ sub DenyModifications {
=head2 DelModifications
Koha::Borrower::Modifications->DelModifications({
Koha::Patron::Modifications->DelModifications({
[ borrowernumber => $borrowernumber ],
[ verification_token => $verification_token ]
});
@ -258,7 +258,7 @@ sub DelModifications {
=head2 GetModifications
$hashref = Koha::Borrower::Modifications->GetModifications({
$hashref = Koha::Patron::Modifications->GetModifications({
[ borrowernumber => $borrowernumber ],
[ verification_token => $verification_token ]
});

8
Koha/Borrowers.pm → Koha/Patrons.pm

@ -1,4 +1,4 @@
package Koha::Borrowers;
package Koha::Patrons;
# Copyright ByWater Solutions 2014
#
@ -23,13 +23,13 @@ use Carp;
use Koha::Database;
use Koha::Borrower;
use Koha::Patron;
use base qw(Koha::Objects);
=head1 NAME
Koha::Borrower - Koha Borrower Object class
Koha::Patron - Koha Patron Object class
=head1 API
@ -46,7 +46,7 @@ sub _type {
}
sub object_class {
return 'Koha::Borrower';
return 'Koha::Patron';
}
=head1 AUTHOR

4
Koha/REST/V1.pm

@ -20,7 +20,7 @@ use Mojo::Base 'Mojolicious';
use C4::Auth qw( check_cookie_auth get_session );
use C4::Context;
use Koha::Borrowers;
use Koha::Patrons;
sub startup {
my $self = shift;
@ -32,7 +32,7 @@ sub startup {
my ($status, $sessionID) = check_cookie_auth($c->cookie('CGISESSID'));
if ($status eq "ok") {
my $session = get_session($sessionID);
my $user = Koha::Borrowers->find($session->param('number'));
my $user = Koha::Patrons->find($session->param('number'));
$c->stash('koha.user' => $user);
}

6
Koha/REST/V1/Patrons.pm

@ -20,7 +20,7 @@ use Modern::Perl;
use Mojo::Base 'Mojolicious::Controller';
use C4::Auth qw( haspermission );
use Koha::Borrowers;
use Koha::Patrons;
sub list_patrons {
my ($c, $args, $cb) = @_;
@ -30,7 +30,7 @@ sub list_patrons {
return $c->$cb({error => "You don't have the required permission"}, 403);
}
my $patrons = Koha::Borrowers->search;
my $patrons = Koha::Patrons->search;
$c->$cb($patrons->unblessed, 200);
}
@ -47,7 +47,7 @@ sub get_patron {
return $c->$cb({error => "You don't have the required permission"}, 403);
}
my $patron = Koha::Borrowers->find($args->{borrowernumber});
my $patron = Koha::Patrons->find($args->{borrowernumber});
unless ($patron) {
return $c->$cb({error => "Patron not found"}, 404);
}

4
Koha/Template/Plugin/Borrowers.pm

@ -22,7 +22,7 @@ use Modern::Perl;
use base qw( Template::Plugin );
use Koha::Borrower::Debarments qw();
use Koha::Patron::Debarments qw();
use C4::Members qw();
=pod
@ -46,7 +46,7 @@ sub IsDebarred {
return unless $borrower;
return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
return Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber});
}
sub HasOverdues {

4
Koha/Virtualshelf.pm

@ -21,7 +21,7 @@ use Carp;
use C4::Auth;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Exceptions;
@ -238,7 +238,7 @@ sub can_be_deleted {
return 0 unless $borrowernumber;
return 1 if $self->owner == $borrowernumber;
my $patron = Koha::Borrowers->find( $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
return 1 if $self->category == $PUBLIC and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } );

6
about.pl

@ -35,7 +35,7 @@ use C4::Installer;
use Koha;
use Koha::Acquisition::Currencies;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Config::SysPrefs;
#use Smart::Comments '####';
@ -82,8 +82,8 @@ my $warnPrefAnonymousPatron = (
and not C4::Context->preference('AnonymousPatron')
);
my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();

4
admin/categories.pl

@ -26,7 +26,7 @@ use C4::Auth;
use C4::Branch;
use C4::Output;
use C4::Form::MessagingPreferences;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Database;
use Koha::DateUtils;
use Koha::Patron::Categories;
@ -162,7 +162,7 @@ elsif ( $op eq 'add_validate' ) {
}
elsif ( $op eq 'delete_confirm' ) {
my $count = Koha::Borrowers->search({
my $count = Koha::Patrons->search({
categorycode => $categorycode
})->count;

2
circ/circulation.pl

@ -43,7 +43,7 @@ use Koha::Holds;
use C4::Context;
use CGI::Session;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
use Koha::DateUtils;
use Koha::Database;
use Koha::Patron::Messages;

4
circ/ysearch.pl

@ -28,7 +28,7 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth qw/check_cookie_auth/;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::DateUtils qw/format_sqldatetime/;
use JSON qw( to_json );
@ -67,7 +67,7 @@ foreach my $p (@parts) {
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
my $borrowers_rs = Koha::Borrowers->search(
my $borrowers_rs = Koha::Patrons->search(
{ -and => \@params },
{
# Get the first 10 results

8
mainpage.pl

@ -28,8 +28,8 @@ use C4::NewsChannels; # GetNewsToDisplay
use C4::Review qw/numberofreviews/;
use C4::Suggestions qw/CountSuggestion/;
use C4::Tags qw/get_count_by_tag_status/;
use Koha::Borrower::Modifications;
use Koha::Borrower::Discharge;
use Koha::Patron::Modifications;
use Koha::Patron::Discharge;
my $query = new CGI;
@ -66,8 +66,8 @@ my $pendingcomments = numberofreviews(0);
my $pendingtags = get_count_by_tag_status(0);
my $pendingsuggestions = CountSuggestion("ASKED");
my $pending_borrower_modifications =
Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
my $pending_discharge_requests = Koha::Borrower::Discharge::count({ pending => 1 });
Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
$template->param(
pendingcomments => $pendingcomments,

12
members/discharge.pl

@ -36,7 +36,7 @@ use C4::Output;
use C4::Members;
use C4::Reserves;
use C4::Letters;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
use Koha::DateUtils;
@ -57,7 +57,7 @@ if ( $input->param('borrowernumber') ) {
# Getting member data
$data = GetMember( borrowernumber => $borrowernumber );
my $can_be_discharged = Koha::Borrower::Discharge::can_be_discharged({
my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
borrowernumber => $borrowernumber
});
@ -67,16 +67,16 @@ if ( $input->param('borrowernumber') ) {
# Generating discharge if needed
if ( $input->param('discharge') and $can_be_discharged ) {
my $is_discharged = Koha::Borrower::Discharge::is_discharged({
my $is_discharged = Koha::Patron::Discharge::is_discharged({
borrowernumber => $borrowernumber,
});
unless ($is_discharged) {
Koha::Borrower::Discharge::discharge({
Koha::Patron::Discharge::discharge({
borrowernumber => $borrowernumber
});
}
eval {
my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
{ borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
binmode(STDOUT);
@ -98,7 +98,7 @@ if ( $input->param('borrowernumber') ) {
}
# Already generated discharges
my $validated_discharges = Koha::Borrower::Discharge::get_validated({
my $validated_discharges = Koha::Patron::Discharge::get_validated({
borrowernumber => $borrowernumber,
});

6
members/discharges.pl

@ -23,7 +23,7 @@ use CGI;
use C4::Auth;
use C4::Output;
use C4::Context;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
my $input = new CGI;
my $op = $input->param('op') // 'list';
@ -44,12 +44,12 @@ my $branchcode =
if( $op eq 'allow' ) {
my $borrowernumber = $input->param('borrowernumber');
Koha::Borrower::Discharge::discharge({
Koha::Patron::Discharge::discharge({
borrowernumber => $borrowernumber
}) if $borrowernumber;
}
my $pending_discharges = Koha::Borrower::Discharge::get_pendings({
my $pending_discharges = Koha::Patron::Discharge::get_pendings({
branchcode => $branchcode
});

6
members/files.pl

@ -30,7 +30,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Debug;
use Koha::DateUtils;
use Koha::Borrower::Files;
use Koha::Patron::Files;
my $cgi = CGI->new;
@ -47,7 +47,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
$template->param( 'borrower_files' => 1 );
my $borrowernumber = $cgi->param('borrowernumber');
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $op = $cgi->param('op') || '';
@ -119,7 +119,7 @@ else {
$template->param( picture => 1 ) if $picture;
$template->param(
files => Koha::Borrower::Files->new( borrowernumber => $borrowernumber )
files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
->GetFilesInfo(),
errors => \%errors,

2
members/memberentry.pl

@ -39,7 +39,7 @@ use C4::Log;
use C4::Letters;
use C4::Branch; # GetBranches
use C4::Form::MessagingPreferences;
use Koha::Borrower::Debarments;
use Koha::Patron::Debarments;
use Koha::Cities;
use Koha::DateUtils;
use Email::Valid;

4
members/members-home.pl

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
use Koha::Libraries;
use Koha::List::Patron;
@ -89,7 +89,7 @@ else {
my $pending_borrower_modifications =
Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
$template->param(
no_add => $no_add,

6
members/members-update-do.pl

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $query = new CGI;
@ -50,10 +50,10 @@ foreach my $param (@params) {
my $action = $query->param($param);
if ( $action eq 'approve' ) {
Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
}
elsif ( $action eq 'deny' ) {
Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
Koha::Patron::Modifications->DenyModifications( $borrowernumber );
}
elsif ( $action eq 'ignore' ) {

4
members/members-update.pl

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $query = new CGI;
@ -49,7 +49,7 @@ my $branch =
: undef;
my $pending_modifications =
Koha::Borrower::Modifications->GetPendingModifications($branch);
Koha::Patron::Modifications->GetPendingModifications($branch);
my $borrowers;
foreach my $pm (@$pending_modifications) {

2
members/mod_debarment.pl

@ -23,7 +23,7 @@ use CGI qw ( -utf8 );
use C4::Auth;
use Koha::DateUtils;
use Koha::Borrower::Debarments;
use Koha::Patron::Debarments;
my $cgi = new CGI;

3
members/moremember.pl

@ -51,8 +51,7 @@ use C4::Branch; # GetBranchName
use C4::Form::MessagingPreferences;
use List::MoreUtils qw/uniq/;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Koha::Libraries;
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
use Module::Load;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );

4
misc/cronjobs/cleanup_database.pl

@ -364,7 +364,7 @@ sub PurgeZ3950 {
}
sub PurgeDebarments {
require Koha::Borrower::Debarments;
require Koha::Patron::Debarments;
my $days = shift;
$count = 0;
$sth = $dbh->prepare(
@ -376,7 +376,7 @@ sub PurgeDebarments {
);
$sth->execute($days) or die $dbh->errstr;
while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
Koha::Borrower::Debarments::DelDebarment($borrower_debarment_id);
Koha::Patron::Debarments::DelDebarment($borrower_debarment_id);
$count++;
}
return $count;

4
misc/cronjobs/longoverdue.pl

@ -39,7 +39,7 @@ use C4::Circulation qw/LostItem/;
use Getopt::Long;
use C4::Log;
use Pod::Usage;
use Koha::Borrowers;
use Koha::Patrons;
my $lost; # key=lost value, value=num days.
my ($charge, $verbose, $confirm, $quiet);
@ -302,7 +302,7 @@ foreach my $startrange (sort keys %$lost) {
$count=0;
ITEM: while (my $row=$sth_items->fetchrow_hashref) {
if( $filter_borrower_categories ) {
my $category = uc Koha::Borrowers->find( $row->{borrowernumber} )->categorycode();
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode();
next ITEM unless ( $category_to_process{ $category } );
}
printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);

2
misc/cronjobs/overdue_notices.pl

@ -38,7 +38,7 @@ use C4::Context;
use C4::Letters;
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
use C4::Log;
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
use Koha::Patron::Debarments qw(AddUniqueDebarment);
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Libraries;

12
opac/opac-discharge.pl

@ -28,7 +28,7 @@ use C4::Log;
use C4::Debug;
use C4::Branch;
use C4::Members;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
use Koha::DateUtils;
my $input = new CGI;
@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
});
if ( $op eq 'request' ) {
my $success = Koha::Borrower::Discharge::request({
my $success = Koha::Patron::Discharge::request({
borrowernumber => $loggedinuser,
});
@ -60,7 +60,7 @@ elsif ( $op eq 'get' ) {
# Getting member data
my $data = GetMember( borrowernumber => $loggedinuser );
my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
borrowernumber => $loggedinuser,
branchcode => $data->{'branchcode'},
});
@ -83,16 +83,16 @@ elsif ( $op eq 'get' ) {
}
}
else {
my $pending = Koha::Borrower::Discharge::count({
my $pending = Koha::Patron::Discharge::count({
borrowernumber => $loggedinuser,
pending => 1,
});
my $available = Koha::Borrower::Discharge::count({
my $available = Koha::Patron::Discharge::count({
borrowernumber => $loggedinuser,
validated => 1,
});
$template->param(
available => $available && Koha::Borrower::Discharge::is_discharged({borrowernumber => $loggedinuser}),
available => $available && Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser}),
pending => $pending,
);
}

11
opac/opac-memberentry.pl

@ -25,8 +25,8 @@ use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Form::MessagingPreferences;
use Koha::Borrowers;
use Koha::Borrower::Modifications;
use Koha::Patrons;
use Koha::Patron::Modifications;
use C4::Branch qw(GetBranchesLoop);
use C4::Scrubber;
use Email::Valid;
@ -126,7 +126,8 @@ if ( $action eq 'create' ) {
my $verification_token = md5_hex( \%borrower );
$borrower{'password'} = random_string("..........");
Koha::Borrower::Modifications->new(
Koha::Patron::Modifications->new(
verification_token => $verification_token )
->AddModifications(\%borrower);
@ -207,7 +208,7 @@ elsif ( $action eq 'update' ) {
);
my $m =
Koha::Borrower::Modifications->new(
Koha::Patron::Modifications->new(
borrowernumber => $borrowernumber );
$m->DelModifications;
@ -238,7 +239,7 @@ elsif ( $action eq 'edit' ) { #Display logged in borrower's data
$template->param(
borrower => $borrower,
guarantor => scalar Koha::Borrowers->find($borrowernumber)->guarantor(),
guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
hidden => GetHiddenFields( $mandatory, 'modification' ),
);

4
opac/opac-privacy.pl

@ -24,7 +24,7 @@ use C4::Context;
use C4::Circulation;
use C4::Members;
use C4::Output;
use Koha::Borrowers;
use Koha::Patrons;
my $query = new CGI;
@ -75,7 +75,7 @@ elsif ( $op eq "delete_record" ) {
}
# get borrower privacy ....
my $borrower = Koha::Borrowers->find( $borrowernumber );;
my $borrower = Koha::Patrons->find( $borrowernumber );;
$template->param(
'Ask_data' => 1,

8
opac/opac-registration-verify.pl

@ -23,7 +23,7 @@ use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Form::MessagingPreferences;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $cgi = new CGI;
my $dbh = C4::Context->dbh;
@ -34,7 +34,7 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) {
}
my $token = $cgi->param('token');
my $m = Koha::Borrower::Modifications->new( verification_token => $token );
my $m = Koha::Patron::Modifications->new( verification_token => $token );
my ( $template, $borrowernumber, $cookie );
if ( $m->Verify() ) {
@ -50,13 +50,13 @@ if ( $m->Verify() ) {
$template->param(
OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
my $borrower = Koha::Borrower::Modifications->GetModifications({ verification_token => $token });
my $borrower = Koha::Patron::Modifications->GetModifications({ verification_token => $token });
my $password;
( $borrowernumber, $password ) = AddMember_Opac(%$borrower);
if ($borrowernumber) {
Koha::Borrower::Modifications->DelModifications({ verification_token => $token });
Koha::Patron::Modifications->DelModifications({ verification_token => $token });
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
$template->param( password_cleartext => $password );

2
opac/opac-reserve.pl

@ -34,8 +34,8 @@ use C4::Branch; # GetBranches
use C4::Overdues;
use C4::Debug;
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Libraries;
use Koha::Patron::Debarments qw(IsDebarred);
use Date::Calc qw/Today Date_to_Days/;
my $maxreserves = C4::Context->preference("maxreserves");

2
opac/opac-user.pl

@ -35,7 +35,7 @@ use C4::Items;
use C4::Letters;
use C4::Branch; # GetBranches
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Koha::Holds;
use Koha::Database;
use Koha::Patron::Messages;

2
reserve/request.pl

@ -44,7 +44,7 @@ use C4::Utils::DataTables::Members;
use C4::Members;
use C4::Search; # enabled_staff_search_views
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Koha::Holds;
use Koha::Libraries;

343
t/Borrower.t

@ -1,343 +0,0 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 18;
use Test::Warn;
use t::lib::Mocks;
BEGIN {
t::lib::Mocks::mock_dbh;
use_ok('Koha::Object');
use_ok('Koha::Borrower');
}
my $object = Koha::Borrower->new( { surname => 'Test Borrower' } );
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
$object->surname('Test Borrower Surname');
is( $object->surname(), 'Test Borrower Surname', "Accessor returns correct value after set" );
my $object2 = Koha::Borrower->new( { surname => 'Test Borrower 2' } );
is( $object2->surname(), 'Test Borrower 2', "Accessor returns correct value" );
$object2->surname('Test Borrower Surname 2');
is( $object2->surname(), 'Test Borrower Surname 2', "Accessor returns correct value after set" );
my $ret;
$ret = $object2->set( { surname => "Test Borrower Surname 3", firstname => "Test Firstname" } );
ok( ref($ret) eq 'Koha::Borrower', "Set returns object on success" );
is( $object2->surname(), "Test Borrower Surname 3", "Set sets first field correctly" );
is( $object2->firstname(), "Test Firstname", "Set sets second field correctly" );
warning_is { $ret = $object->set({ surname => "Test Borrower Surname 4", bork => "bork" }) }
"No property bork!",
"Expected 'No property bork!' caught";
is( $object2->surname(), "Test Borrower Surname 3", "Bad Set does not set field" );
is( $ret, 0, "Set returns 0 when passed a bad property" );
warning_is { $ret = $object->bork() }
"No method bork!",
"Expected 'No method bork!' caught for getter.";
ok( ! defined $ret, 'Bad getter returns undef' );
warning_is { $ret = $object->bork('bork') }
"No method bork!",
"Expected 'No method bork!' caught for setter.";
ok( ! defined $ret, 'Bad setter returns undef' );
my $borrower = Koha::Borrower->new(
{
borrowernumber => '12345',
cardnumber => '1234567890',
surname => 'mySurname',
firstname => 'myFirstname',
title => 'Mr.',
othernames => 'myOthernames',
initials => 'MM',
streetnumber => '100',
streettype => 'Blvd',
address => 'my personnal address',
address2 => 'my adress2',
city => 'Marseille',
state => 'mystate',
zipcode => '13006',
country => 'France',
email => 'mySurname.myFirstname@email.com',
phone => '0402872934',
mobile => '0627884632',
fax => '0402872935',
emailpro => 'myEmailPro@email.com',
phonepro => '0402873334',
B_streetnumber => '101',
B_streettype => 'myB_streettype',
B_address => 'myB_address',
B_address2 => 'myB_address2',
B_city => 'myB_city',
B_state => 'myB_state',
B_zipcode => '23456',
B_country => 'myB_country',
B_email => 'myB_email',
B_phone => '0678353935',
dateofbirth => '1990-07-16',
branchcode => 'myBranCode',
categorycode => 'myCatCode',
dateenrolled => '2015-03-19',
dateexpiry => '2016-03-19',
gonenoaddress => '0',
lost => '0',
debarred => '2015-04-19',
debarredcomment => 'You are debarred',
contactname => 'myContactname',
contactfirstname => 'myContactfirstname',
contacttitle => 'myContacttitle',
guarantorid => '123454321',
borrowernotes => 'borrowernotes',
relationship => 'myRelationship',
sex => 'M',
password => 'hfkurhfe976634èj!',
flags => '55555',
userid => '87987',
opacnote => 'myOpacnote',
contactnote => 'myContactnote',
sort1 => 'mySort1',
sort2 => 'mySort2',
altcontactfirstname => 'myAltcontactfirstname',
altcontactsurname => 'myAltcontactsurname',
altcontactaddress1 => 'myAltcontactaddress1',
altcontactaddress2 => 'myAltcontactaddress2',
altcontactaddress3 => 'myAltcontactaddress3',
altcontactstate => 'myAltcontactstate',
altcontactzipcode => '465843',
altcontactcountry => 'myOtherCountry',
altcontactphone => 'myOtherphone',
smsalertnumber => '0683027346',
privacy => '667788',
}
);
#borrower Accessor tests
subtest 'Accessor tests' => sub {
plan tests => 65;
is( $borrower->borrowernumber, '12345', 'borrowernumber accessor returns correct value' );
is( $borrower->cardnumber, '1234567890', 'cardnumber accessor returns correct value' );
is( $borrower->surname, 'mySurname', 'surname accessor returns correct value' );
is( $borrower->firstname, 'myFirstname', 'firstname accessor returns correct value' );
is( $borrower->title, 'Mr.', 'title accessor returns correct value' );
is( $borrower->othernames, 'myOthernames', 'othernames accessor returns correct value' );
is( $borrower->initials, 'MM', 'initials accessor returns correct value' );
is( $borrower->streetnumber, '100', 'streetnumber accessor returns correct value' );
is( $borrower->streettype, 'Blvd', 'streettype accessor returns correct value' );
is( $borrower->address, 'my personnal address', 'address accessor returns correct value' );
is( $borrower->address2, 'my adress2', 'address2 accessor returns correct value' );
is( $borrower->city, 'Marseille', 'city accessor returns correct value' );
is( $borrower->state, 'mystate', 'state accessor returns correct value' );
is( $borrower->zipcode, '13006', 'zipcode accessor returns correct value' );
is( $borrower->country, 'France', 'country accessor returns correct value' );
is( $borrower->email, 'mySurname.myFirstname@email.com', 'email accessor returns correct value' );
is( $borrower->phone, '0402872934', 'phone accessor returns correct value' );
is( $borrower->mobile, '0627884632', 'mobile accessor returns correct value' );
is( $borrower->fax, '0402872935', 'fax accessor returns correct value' );
is( $borrower->emailpro, 'myEmailPro@email.com', 'emailpro accessor returns correct value' );
is( $borrower->phonepro, '0402873334', 'phonepro accessor returns correct value' );
is( $borrower->B_streetnumber, '101', 'B_streetnumber accessor returns correct value' );
is( $borrower->B_streettype, 'myB_streettype', 'B_streettype accessor returns correct value' );
is( $borrower->B_address, 'myB_address', 'B_address accessor returns correct value' );
is( $borrower->B_address2, 'myB_address2', 'B_address2 accessor returns correct value' );
is( $borrower->B_city, 'myB_city', 'B_city accessor returns correct value' );
is( $borrower->B_state, 'myB_state', 'B_state accessor returns correct value' );
is( $borrower->B_zipcode, '23456', 'B_zipcode accessor returns correct value' );
is( $borrower->B_country, 'myB_country', 'B_country accessor returns correct value' );
is( $borrower->B_email, 'myB_email', 'B_email accessor returns correct value' );
is( $borrower->B_phone, '0678353935', 'B_phone accessor returns correct value' );
is( $borrower->dateofbirth, '1990-07-16', 'dateofbirth accessor returns correct value' );
is( $borrower->branchcode, 'myBranCode', 'branchcode accessor returns correct value' );
is( $borrower->categorycode, 'myCatCode', 'categorycode accessor returns correct value' );
is( $borrower->dateenrolled, '2015-03-19', 'dateenrolled accessor returns correct value' );
is( $borrower->dateexpiry, '2016-03-19', 'dateexpiry accessor returns correct value' );
is( $borrower->gonenoaddress, '0', 'gonenoaddress accessor returns correct value' );
is( $borrower->lost, '0', 'lost accessor returns correct value' );
is( $borrower->debarred, '2015-04-19', 'debarred accessor returns correct value' );
is( $borrower->debarredcomment, 'You are debarred', 'debarredcomment accessor returns correct value' );
is( $borrower->contactname, 'myContactname', 'contactname accessor returns correct value' );
is( $borrower->contactfirstname, 'myContactfirstname', 'contactfirstname accessor returns correct value' );
is( $borrower->contacttitle, 'myContacttitle', 'contacttitle accessor returns correct value' );
is( $borrower->guarantorid, '123454321', 'guarantorid accessor returns correct value' );
is( $borrower->borrowernotes, 'borrowernotes', 'borrowernotes accessor returns correct value' );
is( $borrower->relationship, 'myRelationship', 'relationship accessor returns correct value' );
is( $borrower->sex, 'M', 'sex accessor returns correct value' );
is( $borrower->password, 'hfkurhfe976634èj!', 'password accessor returns correct value' );
is( $borrower->flags, '55555', 'flags accessor returns correct value' );
is( $borrower->userid, '87987', 'userid accessor returns correct value' );
is( $borrower->opacnote, 'myOpacnote', 'opacnote accessor returns correct value' );
is( $borrower->contactnote, 'myContactnote', 'contactnote accessor returns correct value' );
is( $borrower->sort1, 'mySort1', 'sort1 accessor returns correct value' );
is( $borrower->sort2, 'mySort2', 'sort2 accessor returns correct value' );
is( $borrower->altcontactfirstname, 'myAltcontactfirstname', 'altcontactfirstname accessor returns correct value' );
is( $borrower->altcontactsurname, 'myAltcontactsurname', 'altcontactsurname accessor returns correct value' );
is( $borrower->