View | Details | Raw Unified | Return to bug 15548
Collapse All | Expand All

(-)a/C4/Circulation.pm (-6 / +6 lines)
Lines 48-55 use Data::Dumper; Link Here
48
use Koha::DateUtils;
48
use Koha::DateUtils;
49
use Koha::Calendar;
49
use Koha::Calendar;
50
use Koha::Items;
50
use Koha::Items;
51
use Koha::Borrowers;
51
use Koha::Patrons;
52
use Koha::Borrower::Debarments;
52
use Koha::Patron::Debarments;
53
use Koha::Database;
53
use Koha::Database;
54
use Carp;
54
use Carp;
55
use List::MoreUtils qw( uniq );
55
use List::MoreUtils qw( uniq );
Lines 2183-2189 sub MarkIssueReturned { Link Here
2183
2183
2184
    if ( C4::Context->preference('StoreLastBorrower') ) {
2184
    if ( C4::Context->preference('StoreLastBorrower') ) {
2185
        my $item = Koha::Items->find( $itemnumber );
2185
        my $item = Koha::Items->find( $itemnumber );
2186
        my $patron = Koha::Borrowers->find( $borrowernumber );
2186
        my $patron = Koha::Patrons->find( $borrowernumber );
2187
        $item->last_returned_by( $patron );
2187
        $item->last_returned_by( $patron );
2188
    }
2188
    }
2189
}
2189
}
Lines 2247-2259 sub _debar_user_on_return { Link Here
2247
            my $new_debar_dt =
2247
            my $new_debar_dt =
2248
              $dt_today->clone()->add_duration( $suspension_days );
2248
              $dt_today->clone()->add_duration( $suspension_days );
2249
2249
2250
            Koha::Borrower::Debarments::AddUniqueDebarment({
2250
            Koha::Patron::Debarments::AddUniqueDebarment({
2251
                borrowernumber => $borrower->{borrowernumber},
2251
                borrowernumber => $borrower->{borrowernumber},
2252
                expiration     => $new_debar_dt->ymd(),
2252
                expiration     => $new_debar_dt->ymd(),
2253
                type           => 'SUSPENSION',
2253
                type           => 'SUSPENSION',
2254
            });
2254
            });
2255
            # if borrower was already debarred but does not get an extra debarment
2255
            # if borrower was already debarred but does not get an extra debarment
2256
            if ( $borrower->{debarred} eq Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
2256
            if ( $borrower->{debarred} eq Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
2257
                    return ($borrower->{debarred},1);
2257
                    return ($borrower->{debarred},1);
2258
            }
2258
            }
2259
            return $new_debar_dt->ymd();
2259
            return $new_debar_dt->ymd();
Lines 2816-2822 sub CanBookBeRenewed { Link Here
2816
2816
2817
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2817
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2818
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2818
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2819
    my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
2819
    my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
2820
    my $hasoverdues = C4::Members::HasOverdues($borrowernumber);
2820
    my $hasoverdues = C4::Members::HasOverdues($borrowernumber);
2821
2821
2822
    if ( $restricted and $restrictionblockrenewing ) {
2822
    if ( $restricted and $restrictionblockrenewing ) {
(-)a/C4/Members.pm (-2 / +2 lines)
Lines 36-42 use C4::NewsChannels; #get slip news Link Here
36
use DateTime;
36
use DateTime;
37
use Koha::Database;
37
use Koha::Database;
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::Borrower::Debarments qw(IsDebarred);
39
use Koha::Patron::Debarments qw(IsDebarred);
40
use Text::Unaccent qw( unac_string );
40
use Text::Unaccent qw( unac_string );
41
use Koha::AuthUtils qw(hash_password);
41
use Koha::AuthUtils qw(hash_password);
42
use Koha::Database;
42
use Koha::Database;
Lines 524-530 sub IsMemberBlocked { Link Here
524
    my $borrowernumber = shift;
524
    my $borrowernumber = shift;
525
    my $dbh            = C4::Context->dbh;
525
    my $dbh            = C4::Context->dbh;
526
526
527
    my $blockeddate = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
527
    my $blockeddate = Koha::Patron::Debarments::IsDebarred($borrowernumber);
528
528
529
    return ( 1, $blockeddate ) if $blockeddate;
529
    return ( 1, $blockeddate ) if $blockeddate;
530
530
(-)a/Koha/Hold.pm (-3 / +3 lines)
Lines 24-30 use Carp; Link Here
24
use C4::Context qw(preference);
24
use C4::Context qw(preference);
25
use Koha::DateUtils qw(dt_from_string);
25
use Koha::DateUtils qw(dt_from_string);
26
26
27
use Koha::Borrowers;
27
use Koha::Patrons;
28
use Koha::Biblios;
28
use Koha::Biblios;
29
use Koha::Branches;
29
use Koha::Branches;
30
use Koha::Items;
30
use Koha::Items;
Lines 182-195 sub branch { Link Here
182
182
183
=head3 borrower
183
=head3 borrower
184
184
185
Returns the related Koha::Borrower object for this Hold
185
Returns the related Koha::Patron object for this Hold
186
186
187
=cut
187
=cut
188
188
189
sub borrower {
189
sub borrower {
190
    my ($self) = @_;
190
    my ($self) = @_;
191
191
192
    $self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() );
192
    $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
193
193
194
    return $self->{_borrower};
194
    return $self->{_borrower};
195
}
195
}
(-)a/Koha/Item.pm (-3 / +3 lines)
Lines 24-30 use Carp; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Koha::Branches;
26
use Koha::Branches;
27
use Koha::Borrowers;
27
use Koha::Patrons;
28
28
29
use base qw(Koha::Object);
29
use base qw(Koha::Object);
30
30
Lines 78-84 sub holding_branch { Link Here
78
78
79
Gets and sets the last borrower to return an item.
79
Gets and sets the last borrower to return an item.
80
80
81
Accepts and returns Koha::Borrower objects
81
Accepts and returns Koha::Patron objects
82
82
83
$item->last_returned_by( $borrowernumber );
83
$item->last_returned_by( $borrowernumber );
84
84
Lines 99-105 sub last_returned_by { Link Here
99
        unless ( $self->{_last_returned_by} ) {
99
        unless ( $self->{_last_returned_by} ) {
100
            my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } );
100
            my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } );
101
            if ($result) {
101
            if ($result) {
102
                $self->{_last_returned_by} = Koha::Borrowers->find( $result->get_column('borrowernumber') );
102
                $self->{_last_returned_by} = Koha::Patrons->find( $result->get_column('borrowernumber') );
103
            }
103
            }
104
        }
104
        }
105
105
(-)a/Koha/Misc/Files.pm (-1 / +1 lines)
Lines 255-261 __END__ Link Here
255
255
256
=head1 SEE ALSO
256
=head1 SEE ALSO
257
257
258
Koha::Borrower::Files
258
Koha::Patron::Files
259
259
260
=head1 AUTHOR
260
=head1 AUTHOR
261
261
(-)a/Koha/Borrower.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Borrower;
1
package Koha::Patron;
2
2
3
# Copyright ByWater Solutions 2014
3
# Copyright ByWater Solutions 2014
4
#
4
#
Lines 27-33 use base qw(Koha::Object); Link Here
27
27
28
=head1 NAME
28
=head1 NAME
29
29
30
Koha::Borrower - Koha Borrower Object class
30
Koha::Patron - Koha Patron Object class
31
31
32
=head1 API
32
=head1 API
33
33
Lines 37-50 Koha::Borrower - Koha Borrower Object class Link Here
37
37
38
=head3 guarantor
38
=head3 guarantor
39
39
40
Returns a Koha::Borrower object for this borrower's guarantor
40
Returns a Koha::Patron object for this patron's guarantor
41
41
42
=cut
42
=cut
43
43
44
sub guarantor {
44
sub guarantor {
45
    my ( $self ) = @_;
45
    my ( $self ) = @_;
46
46
47
    return Koha::Borrowers->find( $self->guarantorid() );
47
    return Koha::Patrons->find( $self->guarantorid() );
48
}
48
}
49
49
50
=head3 type
50
=head3 type
(-)a/Koha/Borrower/Debarments.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Borrower::Debarments;
1
package Koha::Patron::Debarments;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 36-44 our @EXPORT = qw( Link Here
36
  IsDebarred
36
  IsDebarred
37
);
37
);
38
38
39
=head1 Koha::Borrower::Debarments
39
=head1 Koha::Patron::Debarments
40
40
41
Koha::Borrower::Debarments - Module for managing borrower debarments
41
Koha::Patron::Debarments - Module for managing patron debarments
42
42
43
=cut
43
=cut
44
44
Lines 174-180 sub ModDebarment { Link Here
174
my $debarment_expiration = IsDebarred( $borrowernumber );
174
my $debarment_expiration = IsDebarred( $borrowernumber );
175
175
176
Returns the date a borrowers debarment will expire, or
176
Returns the date a borrowers debarment will expire, or
177
undef if the borrower is not debarred
177
undef if the patron is not debarred
178
178
179
=cut
179
=cut
180
180
(-)a/Koha/Borrower/Discharge.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Borrower::Discharge;
1
package Koha::Patron::Discharge;
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use CGI;
4
use CGI;
Lines 51-57 sub is_discharged { Link Here
51
    my $borrowernumber = $params->{borrowernumber};
51
    my $borrowernumber = $params->{borrowernumber};
52
52
53
53
54
    my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
54
    my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
55
    my $validated = get_validated({borrowernumber => $borrowernumber});
55
    my $validated = get_validated({borrowernumber => $borrowernumber});
56
56
57
    if ($restricted && $validated) {
57
    if ($restricted && $validated) {
Lines 85-91 sub discharge { Link Here
85
    }
85
    }
86
86
87
    # Debar the member
87
    # Debar the member
88
    Koha::Borrower::Debarments::AddDebarment({
88
    Koha::Patron::Debarments::AddDebarment({
89
        borrowernumber => $borrowernumber,
89
        borrowernumber => $borrowernumber,
90
        type           => 'DISCHARGE',
90
        type           => 'DISCHARGE',
91
    });
91
    });
(-)a/Koha/Borrower/Files.pm (-6 / +6 lines)
Lines 1-4 Link Here
1
package Koha::Borrower::Files;
1
package Koha::Patron::Files;
2
2
3
# Copyright 2012 Kyle M Hall
3
# Copyright 2012 Kyle M Hall
4
#
4
#
Lines 33-39 BEGIN { Link Here
33
33
34
=head1 NAME
34
=head1 NAME
35
35
36
Koha::Borrower::Files - Module for managing borrower files
36
Koha::Patron::Files - Module for managing patron files
37
37
38
=head1 METHODS
38
=head1 METHODS
39
39
Lines 52-58 sub new { Link Here
52
52
53
=item GetFilesInfo()
53
=item GetFilesInfo()
54
54
55
    my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
55
    my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
56
    my $files_hashref = $bf->GetFilesInfo
56
    my $files_hashref = $bf->GetFilesInfo
57
57
58
=cut
58
=cut
Lines 79-85 sub GetFilesInfo { Link Here
79
79
80
=item AddFile()
80
=item AddFile()
81
81
82
    my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
82
    my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
83
    $bh->AddFile( name => $filename, type => $mimetype,
83
    $bh->AddFile( name => $filename, type => $mimetype,
84
                  description => $description, content => $content );
84
                  description => $description, content => $content );
85
85
Lines 107-113 sub AddFile { Link Here
107
107
108
=item GetFile()
108
=item GetFile()
109
109
110
    my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
110
    my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
111
    my $file = $bh->GetFile( file_id => $file_id );
111
    my $file = $bh->GetFile( file_id => $file_id );
112
112
113
=cut
113
=cut
Lines 128-134 sub GetFile { Link Here
128
128
129
=item DelFile()
129
=item DelFile()
130
130
131
    my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
131
    my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
132
    $bh->DelFile( file_id => $file_id );
132
    $bh->DelFile( file_id => $file_id );
133
133
134
=cut
134
=cut
(-)a/Koha/Borrower/Modifications.pm (-15 / +15 lines)
Lines 1-4 Link Here
1
package Koha::Borrower::Modifications;
1
package Koha::Patron::Modifications;
2
2
3
# Copyright 2012 ByWater Solutions
3
# Copyright 2012 ByWater Solutions
4
# This file is part of Koha.
4
# This file is part of Koha.
Lines 18-24 package Koha::Borrower::Modifications; Link Here
18
18
19
=head1 NAME
19
=head1 NAME
20
20
21
C4::Borrowers::Modifications
21
Koha::Patron::Modifications
22
22
23
=cut
23
=cut
24
24
Lines 35-43 sub new { Link Here
35
35
36
=head2 AddModifications
36
=head2 AddModifications
37
37
38
Koha::Borrower::Modifications->AddModifications( $data );
38
Koha::Patron::Modifications->AddModifications( $data );
39
39
40
Adds or updates modifications for a borrower.
40
Adds or updates modifications for a patron
41
41
42
Requires either the key borrowernumber, or verification_token
42
Requires either the key borrowernumber, or verification_token
43
to be part of the passed in hash.
43
to be part of the passed in hash.
Lines 67-73 sub AddModifications { Link Here
67
67
68
=head2 Verify
68
=head2 Verify
69
69
70
$verified = Koha::Borrower::Modifications->Verify( $verification_token );
70
$verified = Koha::Patron::Modifications->Verify( $verification_token );
71
71
72
Returns true if the passed in token is valid.
72
Returns true if the passed in token is valid.
73
73
Lines 96-104 sub Verify { Link Here
96
96
97
=head2 GetPendingModificationsCount
97
=head2 GetPendingModificationsCount
98
98
99
$count = Koha::Borrower::Modifications->GetPendingModificationsCount();
99
$count = Koha::Patron::Modifications->GetPendingModificationsCount();
100
100
101
Returns the number of pending modifications for existing borrowers.
101
Returns the number of pending modifications for existing patron.
102
102
103
=cut
103
=cut
104
104
Lines 128-136 sub GetPendingModificationsCount { Link Here
128
128
129
=head2 GetPendingModifications
129
=head2 GetPendingModifications
130
130
131
$arrayref = Koha::Borrower::Modifications->GetPendingModifications();
131
$arrayref = Koha::Patron::Modifications->GetPendingModifications();
132
132
133
Returns an arrayref of hashrefs for all pending modifications for existing borrowers.
133
Returns an arrayref of hashrefs for all pending modifications for existing patrons.
134
134
135
=cut
135
=cut
136
136
Lines 168-174 sub GetPendingModifications { Link Here
168
168
169
=head2 ApproveModifications
169
=head2 ApproveModifications
170
170
171
Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
171
Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
172
172
173
Commits the pending modifications to the borrower record and removes
173
Commits the pending modifications to the borrower record and removes
174
them from the modifications table.
174
them from the modifications table.
Lines 197-206 sub ApproveModifications { Link Here
197
197
198
=head2 DenyModifications
198
=head2 DenyModifications
199
199
200
Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
200
Koha::Patron::Modifications->DenyModifications( $borrowernumber );
201
201
202
Removes the modifications from the table for the given borrower,
202
Removes the modifications from the table for the given patron,
203
without commiting the changes to the borrower record.
203
without commiting the changes to the patron record.
204
204
205
=cut
205
=cut
206
206
Lines 217-223 sub DenyModifications { Link Here
217
217
218
=head2 DelModifications
218
=head2 DelModifications
219
219
220
Koha::Borrower::Modifications->DelModifications({
220
Koha::Patron::Modifications->DelModifications({
221
  [ borrowernumber => $borrowernumber ],
221
  [ borrowernumber => $borrowernumber ],
222
  [ verification_token => $verification_token ]
222
  [ verification_token => $verification_token ]
223
});
223
});
Lines 258-264 sub DelModifications { Link Here
258
258
259
=head2 GetModifications
259
=head2 GetModifications
260
260
261
$hashref = Koha::Borrower::Modifications->GetModifications({
261
$hashref = Koha::Patron::Modifications->GetModifications({
262
  [ borrowernumber => $borrowernumber ],
262
  [ borrowernumber => $borrowernumber ],
263
  [ verification_token => $verification_token ]
263
  [ verification_token => $verification_token ]
264
});
264
});
(-)a/Koha/Borrowers.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Borrowers;
1
package Koha::Patrons;
2
2
3
# Copyright ByWater Solutions 2014
3
# Copyright ByWater Solutions 2014
4
#
4
#
Lines 23-35 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Koha::Borrower;
26
use Koha::Patron;
27
27
28
use base qw(Koha::Objects);
28
use base qw(Koha::Objects);
29
29
30
=head1 NAME
30
=head1 NAME
31
31
32
Koha::Borrower - Koha Borrower Object class
32
Koha::Patron - Koha Patron Object class
33
33
34
=head1 API
34
=head1 API
35
35
Lines 46-52 sub type { Link Here
46
}
46
}
47
47
48
sub object_class {
48
sub object_class {
49
    return 'Koha::Borrower';
49
    return 'Koha::Patron';
50
}
50
}
51
51
52
=head1 AUTHOR
52
=head1 AUTHOR
(-)a/Koha/REST/V1.pm (-2 / +2 lines)
Lines 20-26 use Mojo::Base 'Mojolicious'; Link Here
20
20
21
use C4::Auth qw( check_cookie_auth get_session );
21
use C4::Auth qw( check_cookie_auth get_session );
22
use C4::Context;
22
use C4::Context;
23
use Koha::Borrowers;
23
use Koha::Patrons;
24
24
25
sub startup {
25
sub startup {
26
    my $self = shift;
26
    my $self = shift;
Lines 32-38 sub startup { Link Here
32
            my ($status, $sessionID) = check_cookie_auth($c->cookie('CGISESSID'));
32
            my ($status, $sessionID) = check_cookie_auth($c->cookie('CGISESSID'));
33
            if ($status eq "ok") {
33
            if ($status eq "ok") {
34
                my $session = get_session($sessionID);
34
                my $session = get_session($sessionID);
35
                my $user = Koha::Borrowers->find($session->param('number'));
35
                my $user = Koha::Patrons->find($session->param('number'));
36
                $c->stash('koha.user' => $user);
36
                $c->stash('koha.user' => $user);
37
            }
37
            }
38
38
(-)a/Koha/REST/V1/Patrons.pm (-3 / +3 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use C4::Auth qw( haspermission );
22
use C4::Auth qw( haspermission );
23
use Koha::Borrowers;
23
use Koha::Patrons;
24
24
25
sub list_patrons {
25
sub list_patrons {
26
    my ($c, $args, $cb) = @_;
26
    my ($c, $args, $cb) = @_;
Lines 30-36 sub list_patrons { Link Here
30
        return $c->$cb({error => "You don't have the required permission"}, 403);
30
        return $c->$cb({error => "You don't have the required permission"}, 403);
31
    }
31
    }
32
32
33
    my $patrons = Koha::Borrowers->search;
33
    my $patrons = Koha::Patrons->search;
34
34
35
    $c->$cb($patrons->unblessed, 200);
35
    $c->$cb($patrons->unblessed, 200);
36
}
36
}
Lines 47-53 sub get_patron { Link Here
47
        return $c->$cb({error => "You don't have the required permission"}, 403);
47
        return $c->$cb({error => "You don't have the required permission"}, 403);
48
    }
48
    }
49
49
50
    my $patron = Koha::Borrowers->find($args->{borrowernumber});
50
    my $patron = Koha::Patrons->find($args->{borrowernumber});
51
    unless ($patron) {
51
    unless ($patron) {
52
        return $c->$cb({error => "Patron not found"}, 404);
52
        return $c->$cb({error => "Patron not found"}, 404);
53
    }
53
    }
(-)a/Koha/Template/Plugin/Borrowers.pm (-2 / +2 lines)
Lines 22-28 use Modern::Perl; Link Here
22
22
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use Koha::Borrower::Debarments qw();
25
use Koha::Patron::Debarments qw();
26
use C4::Members qw(HasOverdues);
26
use C4::Members qw(HasOverdues);
27
27
28
=pod
28
=pod
Lines 46-52 sub IsDebarred { Link Here
46
46
47
    return unless $borrower;
47
    return unless $borrower;
48
48
49
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
    return Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber});
50
}
50
}
51
51
52
sub HasOverdues {
52
sub HasOverdues {
(-)a/Koha/Virtualshelf.pm (-2 / +2 lines)
Lines 21-27 use Carp; Link Here
21
21
22
use C4::Auth;
22
use C4::Auth;
23
23
24
use Koha::Borrowers;
24
use Koha::Patrons;
25
use Koha::Database;
25
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::Exceptions;
27
use Koha::Exceptions;
Lines 238-244 sub can_be_deleted { Link Here
238
    return 0 unless $borrowernumber;
238
    return 0 unless $borrowernumber;
239
    return 1 if $self->owner == $borrowernumber;
239
    return 1 if $self->owner == $borrowernumber;
240
240
241
    my $patron = Koha::Borrowers->find( $borrowernumber );
241
    my $patron = Koha::Patrons->find( $borrowernumber );
242
242
243
    return 1 if $self->category == $PUBLIC and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } );
243
    return 1 if $self->category == $PUBLIC and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } );
244
244
(-)a/about.pl (-3 / +3 lines)
Lines 34-40 use C4::Context; Link Here
34
use C4::Installer;
34
use C4::Installer;
35
35
36
use Koha;
36
use Koha;
37
use Koha::Borrowers;
37
use Koha::Patrons;
38
use Koha::Config::SysPrefs;
38
use Koha::Config::SysPrefs;
39
39
40
#use Smart::Comments '####';
40
#use Smart::Comments '####';
Lines 88-95 my $warnPrefAnonymousPatron = ( Link Here
88
        and not C4::Context->preference('AnonymousPatron')
88
        and not C4::Context->preference('AnonymousPatron')
89
);
89
);
90
90
91
my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
91
my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
92
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
92
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
93
93
94
my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
94
my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
95
95
(-)a/admin/categories.pl (-2 / +2 lines)
Lines 26-32 use C4::Auth; Link Here
26
use C4::Branch;
26
use C4::Branch;
27
use C4::Output;
27
use C4::Output;
28
use C4::Form::MessagingPreferences;
28
use C4::Form::MessagingPreferences;
29
use Koha::Borrowers;
29
use Koha::Patrons;
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Patron::Categories;
32
use Koha::Patron::Categories;
Lines 162-168 elsif ( $op eq 'add_validate' ) { Link Here
162
}
162
}
163
elsif ( $op eq 'delete_confirm' ) {
163
elsif ( $op eq 'delete_confirm' ) {
164
164
165
    my $count = Koha::Borrowers->search({
165
    my $count = Koha::Patrons->search({
166
        categorycode => $categorycode
166
        categorycode => $categorycode
167
    })->count;
167
    })->count;
168
168
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 43-49 use Koha::Holds; Link Here
43
use C4::Context;
43
use C4::Context;
44
use CGI::Session;
44
use CGI::Session;
45
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use C4::Members::Attributes qw(GetBorrowerAttributes);
46
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
46
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
47
use Koha::DateUtils;
47
use Koha::DateUtils;
48
use Koha::Database;
48
use Koha::Database;
49
49
(-)a/circ/ysearch.pl (-2 / +2 lines)
Lines 28-34 use Modern::Perl; Link Here
28
use CGI qw ( -utf8 );
28
use CGI qw ( -utf8 );
29
use C4::Context;
29
use C4::Context;
30
use C4::Auth qw/check_cookie_auth/;
30
use C4::Auth qw/check_cookie_auth/;
31
use Koha::Borrowers;
31
use Koha::Patrons;
32
use Koha::DateUtils qw/format_sqldatetime/;
32
use Koha::DateUtils qw/format_sqldatetime/;
33
33
34
use JSON qw( to_json );
34
use JSON qw( to_json );
Lines 67-73 foreach my $p (@parts) { Link Here
67
67
68
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
68
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
69
69
70
my $borrowers_rs = Koha::Borrowers->search(
70
my $borrowers_rs = Koha::Patrons->search(
71
    { -and => \@params },
71
    { -and => \@params },
72
    {
72
    {
73
        # Get the first 10 results
73
        # Get the first 10 results
(-)a/mainpage.pl (-4 / +4 lines)
Lines 28-35 use C4::NewsChannels; # GetNewsToDisplay Link Here
28
use C4::Review qw/numberofreviews/;
28
use C4::Review qw/numberofreviews/;
29
use C4::Suggestions qw/CountSuggestion/;
29
use C4::Suggestions qw/CountSuggestion/;
30
use C4::Tags qw/get_count_by_tag_status/;
30
use C4::Tags qw/get_count_by_tag_status/;
31
use Koha::Borrower::Modifications;
31
use Koha::Patron::Modifications;
32
use Koha::Borrower::Discharge;
32
use Koha::Patron::Discharge;
33
33
34
my $query = new CGI;
34
my $query = new CGI;
35
35
Lines 66-73 my $pendingcomments = numberofreviews(0); Link Here
66
my $pendingtags        = get_count_by_tag_status(0);
66
my $pendingtags        = get_count_by_tag_status(0);
67
my $pendingsuggestions = CountSuggestion("ASKED");
67
my $pendingsuggestions = CountSuggestion("ASKED");
68
my $pending_borrower_modifications =
68
my $pending_borrower_modifications =
69
  Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
69
  Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
70
my $pending_discharge_requests = Koha::Borrower::Discharge::count({ pending => 1 });
70
my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
71
71
72
$template->param(
72
$template->param(
73
    pendingcomments                => $pendingcomments,
73
    pendingcomments                => $pendingcomments,
(-)a/members/discharge.pl (-6 / +6 lines)
Lines 36-42 use C4::Output; Link Here
36
use C4::Members;
36
use C4::Members;
37
use C4::Reserves;
37
use C4::Reserves;
38
use C4::Letters;
38
use C4::Letters;
39
use Koha::Borrower::Discharge;
39
use Koha::Patron::Discharge;
40
40
41
use Koha::DateUtils;
41
use Koha::DateUtils;
42
42
Lines 57-63 if ( $input->param('borrowernumber') ) { Link Here
57
    # Getting member data
57
    # Getting member data
58
    $data = GetMember( borrowernumber => $borrowernumber );
58
    $data = GetMember( borrowernumber => $borrowernumber );
59
59
60
    my $can_be_discharged = Koha::Borrower::Discharge::can_be_discharged({
60
    my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
61
        borrowernumber => $borrowernumber
61
        borrowernumber => $borrowernumber
62
    });
62
    });
63
63
Lines 67-82 if ( $input->param('borrowernumber') ) { Link Here
67
67
68
    # Generating discharge if needed
68
    # Generating discharge if needed
69
    if ( $input->param('discharge') and $can_be_discharged ) {
69
    if ( $input->param('discharge') and $can_be_discharged ) {
70
        my $is_discharged = Koha::Borrower::Discharge::is_discharged({
70
        my $is_discharged = Koha::Patron::Discharge::is_discharged({
71
            borrowernumber => $borrowernumber,
71
            borrowernumber => $borrowernumber,
72
        });
72
        });
73
        unless ($is_discharged) {
73
        unless ($is_discharged) {
74
            Koha::Borrower::Discharge::discharge({
74
            Koha::Patron::Discharge::discharge({
75
                borrowernumber => $borrowernumber
75
                borrowernumber => $borrowernumber
76
            });
76
            });
77
        }
77
        }
78
        eval {
78
        eval {
79
            my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
79
            my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
80
                { borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
80
                { borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
81
81
82
            binmode(STDOUT);
82
            binmode(STDOUT);
Lines 98-104 if ( $input->param('borrowernumber') ) { Link Here
98
    }
98
    }
99
99
100
    # Already generated discharges
100
    # Already generated discharges
101
    my $validated_discharges = Koha::Borrower::Discharge::get_validated({
101
    my $validated_discharges = Koha::Patron::Discharge::get_validated({
102
        borrowernumber => $borrowernumber,
102
        borrowernumber => $borrowernumber,
103
    });
103
    });
104
104
(-)a/members/discharges.pl (-3 / +3 lines)
Lines 23-29 use CGI; Link Here
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Output;
24
use C4::Output;
25
use C4::Context;
25
use C4::Context;
26
use Koha::Borrower::Discharge;
26
use Koha::Patron::Discharge;
27
27
28
my $input = new CGI;
28
my $input = new CGI;
29
my $op = $input->param('op') // 'list';
29
my $op = $input->param('op') // 'list';
Lines 44-55 my $branchcode = Link Here
44
44
45
if( $op eq 'allow' ) {
45
if( $op eq 'allow' ) {
46
    my $borrowernumber = $input->param('borrowernumber');
46
    my $borrowernumber = $input->param('borrowernumber');
47
    Koha::Borrower::Discharge::discharge({
47
    Koha::Patron::Discharge::discharge({
48
        borrowernumber => $borrowernumber
48
        borrowernumber => $borrowernumber
49
    }) if $borrowernumber;
49
    }) if $borrowernumber;
50
}
50
}
51
51
52
my $pending_discharges = Koha::Borrower::Discharge::get_pendings({
52
my $pending_discharges = Koha::Patron::Discharge::get_pendings({
53
    branchcode => $branchcode
53
    branchcode => $branchcode
54
});
54
});
55
55
(-)a/members/files.pl (-3 / +3 lines)
Lines 30-36 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
30
use C4::Debug;
30
use C4::Debug;
31
31
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
use Koha::Borrower::Files;
33
use Koha::Patron::Files;
34
34
35
my $cgi = CGI->new;
35
my $cgi = CGI->new;
36
36
Lines 47-53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
$template->param( 'borrower_files' => 1 );
47
$template->param( 'borrower_files' => 1 );
48
48
49
my $borrowernumber = $cgi->param('borrowernumber');
49
my $borrowernumber = $cgi->param('borrowernumber');
50
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
50
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
51
51
52
my $op = $cgi->param('op') || '';
52
my $op = $cgi->param('op') || '';
53
53
Lines 123-129 else { Link Here
123
    my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
123
    my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
124
124
125
    $template->param(
125
    $template->param(
126
        files => Koha::Borrower::Files->new( borrowernumber => $borrowernumber )
126
        files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
127
          ->GetFilesInfo(),
127
          ->GetFilesInfo(),
128
128
129
        errors => \%errors,
129
        errors => \%errors,
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 39-45 use C4::Log; Link Here
39
use C4::Letters;
39
use C4::Letters;
40
use C4::Branch; # GetBranches
40
use C4::Branch; # GetBranches
41
use C4::Form::MessagingPreferences;
41
use C4::Form::MessagingPreferences;
42
use Koha::Borrower::Debarments;
42
use Koha::Patron::Debarments;
43
use Koha::DateUtils;
43
use Koha::DateUtils;
44
use Email::Valid;
44
use Email::Valid;
45
use Module::Load;
45
use Module::Load;
(-)a/members/members-home.pl (-2 / +2 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Members;
26
use C4::Members;
27
use C4::Branch;
27
use C4::Branch;
28
use C4::Category;
28
use C4::Category;
29
use Koha::Borrower::Modifications;
29
use Koha::Patron::Modifications;
30
use Koha::List::Patron;
30
use Koha::List::Patron;
31
31
32
my $query = new CGI;
32
my $query = new CGI;
Lines 88-94 else { Link Here
88
88
89
89
90
my $pending_borrower_modifications =
90
my $pending_borrower_modifications =
91
  Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
91
  Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
92
92
93
$template->param( 
93
$template->param( 
94
        no_add => $no_add,
94
        no_add => $no_add,
(-)a/members/members-update-do.pl (-3 / +3 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Members;
26
use C4::Members;
27
use C4::Branch;
27
use C4::Branch;
28
use C4::Category;
28
use C4::Category;
29
use Koha::Borrower::Modifications;
29
use Koha::Patron::Modifications;
30
30
31
my $query = new CGI;
31
my $query = new CGI;
32
32
Lines 50-59 foreach my $param (@params) { Link Here
50
        my $action = $query->param($param);
50
        my $action = $query->param($param);
51
51
52
        if ( $action eq 'approve' ) {
52
        if ( $action eq 'approve' ) {
53
            Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
53
            Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
54
        }
54
        }
55
        elsif ( $action eq 'deny' ) {
55
        elsif ( $action eq 'deny' ) {
56
            Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
56
            Koha::Patron::Modifications->DenyModifications( $borrowernumber );
57
        }
57
        }
58
        elsif ( $action eq 'ignore' ) {
58
        elsif ( $action eq 'ignore' ) {
59
59
(-)a/members/members-update.pl (-2 / +2 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Members;
26
use C4::Members;
27
use C4::Branch;
27
use C4::Branch;
28
use C4::Category;
28
use C4::Category;
29
use Koha::Borrower::Modifications;
29
use Koha::Patron::Modifications;
30
30
31
my $query = new CGI;
31
my $query = new CGI;
32
32
Lines 49-55 my $branch = Link Here
49
  : undef;
49
  : undef;
50
50
51
my $pending_modifications =
51
my $pending_modifications =
52
  Koha::Borrower::Modifications->GetPendingModifications($branch);
52
  Koha::Patron::Modifications->GetPendingModifications($branch);
53
53
54
my $borrowers;
54
my $borrowers;
55
foreach my $pm (@$pending_modifications) {
55
foreach my $pm (@$pending_modifications) {
(-)a/members/mod_debarment.pl (-1 / +1 lines)
Lines 23-29 use CGI qw ( -utf8 ); Link Here
23
23
24
use C4::Auth;
24
use C4::Auth;
25
use Koha::DateUtils;
25
use Koha::DateUtils;
26
use Koha::Borrower::Debarments;
26
use Koha::Patron::Debarments;
27
27
28
my $cgi = new CGI;
28
my $cgi = new CGI;
29
29
(-)a/members/moremember.pl (-1 / +1 lines)
Lines 51-57 use C4::Branch; # GetBranchName Link Here
51
use C4::Form::MessagingPreferences;
51
use C4::Form::MessagingPreferences;
52
use List::MoreUtils qw/uniq/;
52
use List::MoreUtils qw/uniq/;
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
54
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
54
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
55
use Module::Load;
55
use Module::Load;
56
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
56
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
57
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
57
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
(-)a/misc/cronjobs/cleanup_database.pl (-2 / +2 lines)
Lines 364-370 sub PurgeZ3950 { Link Here
364
}
364
}
365
365
366
sub PurgeDebarments {
366
sub PurgeDebarments {
367
    require Koha::Borrower::Debarments;
367
    require Koha::Patron::Debarments;
368
    my $days = shift;
368
    my $days = shift;
369
    $count = 0;
369
    $count = 0;
370
    $sth   = $dbh->prepare(
370
    $sth   = $dbh->prepare(
Lines 376-382 sub PurgeDebarments { Link Here
376
    );
376
    );
377
    $sth->execute($days) or die $dbh->errstr;
377
    $sth->execute($days) or die $dbh->errstr;
378
    while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
378
    while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
379
        Koha::Borrower::Debarments::DelDebarment($borrower_debarment_id);
379
        Koha::Patron::Debarments::DelDebarment($borrower_debarment_id);
380
        $count++;
380
        $count++;
381
    }
381
    }
382
    return $count;
382
    return $count;
(-)a/misc/cronjobs/longoverdue.pl (-2 / +2 lines)
Lines 39-45 use C4::Circulation qw/LostItem/; Link Here
39
use Getopt::Long;
39
use Getopt::Long;
40
use C4::Log;
40
use C4::Log;
41
use Pod::Usage;
41
use Pod::Usage;
42
use Koha::Borrowers;
42
use Koha::Patrons;
43
43
44
my  $lost;  #  key=lost value,  value=num days.
44
my  $lost;  #  key=lost value,  value=num days.
45
my ($charge, $verbose, $confirm, $quiet);
45
my ($charge, $verbose, $confirm, $quiet);
Lines 302-308 foreach my $startrange (sort keys %$lost) { Link Here
302
        $count=0;
302
        $count=0;
303
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
303
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
304
            if( $filter_borrower_categories ) {
304
            if( $filter_borrower_categories ) {
305
                my $category = uc Koha::Borrowers->find( $row->{borrowernumber} )->categorycode();
305
                my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode();
306
                next ITEM unless ( $category_to_process{ $category } );
306
                next ITEM unless ( $category_to_process{ $category } );
307
            }
307
            }
308
            printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
308
            printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
(-)a/misc/cronjobs/overdue_notices.pl (-1 / +1 lines)
Lines 43-49 use C4::Letters; Link Here
43
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
43
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
44
use C4::Budgets qw(GetCurrency);
44
use C4::Budgets qw(GetCurrency);
45
use C4::Log;
45
use C4::Log;
46
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
46
use Koha::Patron::Debarments qw(AddUniqueDebarment);
47
use Koha::DateUtils;
47
use Koha::DateUtils;
48
use Koha::Calendar;
48
use Koha::Calendar;
49
49
(-)a/opac/opac-discharge.pl (-6 / +6 lines)
Lines 28-34 use C4::Log; Link Here
28
use C4::Debug;
28
use C4::Debug;
29
use C4::Branch;
29
use C4::Branch;
30
use C4::Members;
30
use C4::Members;
31
use Koha::Borrower::Discharge;
31
use Koha::Patron::Discharge;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
33
34
my $input = new CGI;
34
my $input = new CGI;
Lines 44-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
44
});
44
});
45
45
46
if ( $op eq 'request' ) {
46
if ( $op eq 'request' ) {
47
    my $success = Koha::Borrower::Discharge::request({
47
    my $success = Koha::Patron::Discharge::request({
48
        borrowernumber => $loggedinuser,
48
        borrowernumber => $loggedinuser,
49
    });
49
    });
50
50
Lines 60-66 elsif ( $op eq 'get' ) { Link Here
60
60
61
        # Getting member data
61
        # Getting member data
62
        my $data = GetMember( borrowernumber => $loggedinuser );
62
        my $data = GetMember( borrowernumber => $loggedinuser );
63
        my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
63
        my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
64
            borrowernumber => $loggedinuser,
64
            borrowernumber => $loggedinuser,
65
            branchcode => $data->{'branchcode'},
65
            branchcode => $data->{'branchcode'},
66
        });
66
        });
Lines 83-98 elsif ( $op eq 'get' ) { Link Here
83
    }
83
    }
84
}
84
}
85
else {
85
else {
86
    my $pending = Koha::Borrower::Discharge::count({
86
    my $pending = Koha::Patron::Discharge::count({
87
        borrowernumber => $loggedinuser,
87
        borrowernumber => $loggedinuser,
88
        pending        => 1,
88
        pending        => 1,
89
    });
89
    });
90
    my $available = Koha::Borrower::Discharge::count({
90
    my $available = Koha::Patron::Discharge::count({
91
        borrowernumber => $loggedinuser,
91
        borrowernumber => $loggedinuser,
92
        validated      => 1,
92
        validated      => 1,
93
    });
93
    });
94
    $template->param(
94
    $template->param(
95
        available => $available && Koha::Borrower::Discharge::is_discharged({borrowernumber => $loggedinuser}),
95
        available => $available && Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser}),
96
        pending   => $pending,
96
        pending   => $pending,
97
    );
97
    );
98
}
98
}
(-)a/opac/opac-memberentry.pl (-5 / +5 lines)
Lines 25-32 use C4::Auth; Link Here
25
use C4::Output;
25
use C4::Output;
26
use C4::Members;
26
use C4::Members;
27
use C4::Form::MessagingPreferences;
27
use C4::Form::MessagingPreferences;
28
use Koha::Borrowers;
28
use Koha::Patrons;
29
use Koha::Borrower::Modifications;
29
use Koha::Patron::Modifications;
30
use C4::Branch qw(GetBranchesLoop);
30
use C4::Branch qw(GetBranchesLoop);
31
use C4::Scrubber;
31
use C4::Scrubber;
32
use Email::Valid;
32
use Email::Valid;
Lines 115-121 if ( $action eq 'create' ) { Link Here
115
            my $verification_token = md5_hex( \%borrower );
115
            my $verification_token = md5_hex( \%borrower );
116
            $borrower{'password'} = random_string("..........");
116
            $borrower{'password'} = random_string("..........");
117
117
118
            Koha::Borrower::Modifications->new(
118
            Koha::Patron::Modifications->new(
119
                verification_token => $verification_token )
119
                verification_token => $verification_token )
120
              ->AddModifications(\%borrower);
120
              ->AddModifications(\%borrower);
121
121
Lines 196-202 elsif ( $action eq 'update' ) { Link Here
196
            );
196
            );
197
197
198
            my $m =
198
            my $m =
199
              Koha::Borrower::Modifications->new(
199
              Koha::Patron::Modifications->new(
200
                borrowernumber => $borrowernumber );
200
                borrowernumber => $borrowernumber );
201
201
202
            $m->DelModifications;
202
            $m->DelModifications;
Lines 227-233 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
227
227
228
    $template->param(
228
    $template->param(
229
        borrower  => $borrower,
229
        borrower  => $borrower,
230
        guarantor => Koha::Borrowers->find($borrowernumber)->guarantor(),
230
        guarantor => Koha::Patrons->find($borrowernumber)->guarantor(),
231
    );
231
    );
232
232
233
    if (C4::Context->preference('OPACpatronimages')) {
233
    if (C4::Context->preference('OPACpatronimages')) {
(-)a/opac/opac-privacy.pl (-2 / +2 lines)
Lines 24-30 use C4::Context; Link Here
24
use C4::Circulation;
24
use C4::Circulation;
25
use C4::Members;
25
use C4::Members;
26
use C4::Output;
26
use C4::Output;
27
use Koha::Borrowers;
27
use Koha::Patrons;
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
30
Lines 75-81 elsif ( $op eq "delete_record" ) { Link Here
75
}
75
}
76
76
77
# get borrower privacy ....
77
# get borrower privacy ....
78
my $borrower = Koha::Borrowers->find( $borrowernumber );;
78
my $borrower = Koha::Patrons->find( $borrowernumber );;
79
79
80
$template->param(
80
$template->param(
81
    'Ask_data'                       => 1,
81
    'Ask_data'                       => 1,
(-)a/opac/opac-registration-verify.pl (-4 / +4 lines)
Lines 23-29 use C4::Auth; Link Here
23
use C4::Output;
23
use C4::Output;
24
use C4::Members;
24
use C4::Members;
25
use C4::Form::MessagingPreferences;
25
use C4::Form::MessagingPreferences;
26
use Koha::Borrower::Modifications;
26
use Koha::Patron::Modifications;
27
27
28
my $cgi = new CGI;
28
my $cgi = new CGI;
29
my $dbh = C4::Context->dbh;
29
my $dbh = C4::Context->dbh;
Lines 34-40 unless ( C4::Context->preference('PatronSelfRegistration') ) { Link Here
34
}
34
}
35
35
36
my $token = $cgi->param('token');
36
my $token = $cgi->param('token');
37
my $m = Koha::Borrower::Modifications->new( verification_token => $token );
37
my $m = Koha::Patron::Modifications->new( verification_token => $token );
38
38
39
my ( $template, $borrowernumber, $cookie );
39
my ( $template, $borrowernumber, $cookie );
40
if ( $m->Verify() ) {
40
if ( $m->Verify() ) {
Lines 50-62 if ( $m->Verify() ) { Link Here
50
    $template->param(
50
    $template->param(
51
        OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
51
        OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
52
52
53
    my $borrower = Koha::Borrower::Modifications->GetModifications({ verification_token => $token });
53
    my $borrower = Koha::Patron::Modifications->GetModifications({ verification_token => $token });
54
54
55
    my $password;
55
    my $password;
56
    ( $borrowernumber, $password ) = AddMember_Opac(%$borrower);
56
    ( $borrowernumber, $password ) = AddMember_Opac(%$borrower);
57
57
58
    if ($borrowernumber) {
58
    if ($borrowernumber) {
59
        Koha::Borrower::Modifications->DelModifications({ verification_token => $token });
59
        Koha::Patron::Modifications->DelModifications({ verification_token => $token });
60
        C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
60
        C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
61
61
62
        $template->param( password_cleartext => $password );
62
        $template->param( password_cleartext => $password );
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 34-40 use C4::Branch; # GetBranches Link Here
34
use C4::Overdues;
34
use C4::Overdues;
35
use C4::Debug;
35
use C4::Debug;
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Borrower::Debarments qw(IsDebarred);
37
use Koha::Patron::Debarments qw(IsDebarred);
38
use Date::Calc qw/Today Date_to_Days/;
38
use Date::Calc qw/Today Date_to_Days/;
39
# use Data::Dumper;
39
# use Data::Dumper;
40
40
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 35-41 use C4::Items; Link Here
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Borrower::Debarments qw(IsDebarred);
38
use Koha::Patron::Debarments qw(IsDebarred);
39
use Koha::Holds;
39
use Koha::Holds;
40
use Koha::Database;
40
use Koha::Database;
41
41
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 44-50 use C4::Utils::DataTables::Members; Link Here
44
use C4::Members;
44
use C4::Members;
45
use C4::Search;		# enabled_staff_search_views
45
use C4::Search;		# enabled_staff_search_views
46
use Koha::DateUtils;
46
use Koha::DateUtils;
47
use Koha::Borrower::Debarments qw(IsDebarred);
47
use Koha::Patron::Debarments qw(IsDebarred);
48
use Koha::Holds;
48
use Koha::Holds;
49
49
50
my $dbh = C4::Context->dbh;
50
my $dbh = C4::Context->dbh;
(-)a/t/Borrower.t (-343 lines)
Lines 1-343 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 18;
21
use Test::Warn;
22
use t::lib::Mocks;
23
24
BEGIN {
25
    t::lib::Mocks::mock_dbh;
26
    use_ok('Koha::Object');
27
    use_ok('Koha::Borrower');
28
}
29
30
my $object = Koha::Borrower->new( { surname => 'Test Borrower' } );
31
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
32
$object->surname('Test Borrower Surname');
33
is( $object->surname(), 'Test Borrower Surname', "Accessor returns correct value after set" );
34
35
my $object2 = Koha::Borrower->new( { surname => 'Test Borrower 2' } );
36
is( $object2->surname(), 'Test Borrower 2', "Accessor returns correct value" );
37
$object2->surname('Test Borrower Surname 2');
38
is( $object2->surname(), 'Test Borrower Surname 2', "Accessor returns correct value after set" );
39
40
my $ret;
41
$ret = $object2->set( { surname => "Test Borrower Surname 3", firstname => "Test Firstname" } );
42
ok( ref($ret) eq 'Koha::Borrower', "Set returns object on success" );
43
is( $object2->surname(),   "Test Borrower Surname 3", "Set sets first field correctly" );
44
is( $object2->firstname(), "Test Firstname",          "Set sets second field correctly" );
45
46
warning_is { $ret = $object->set({ surname => "Test Borrower Surname 4", bork => "bork" }) }
47
            "No property bork!",
48
            "Expected 'No property bork!' caught";
49
is( $object2->surname(), "Test Borrower Surname 3", "Bad Set does not set field" );
50
is( $ret, 0, "Set returns 0 when passed a bad property" );
51
52
warning_is { $ret = $object->bork() }
53
            "No method bork!",
54
            "Expected 'No method bork!' caught for getter.";
55
ok( ! defined $ret, 'Bad getter returns undef' );
56
57
warning_is { $ret = $object->bork('bork') }
58
            "No method bork!",
59
            "Expected 'No method bork!' caught for setter.";
60
ok( ! defined $ret, 'Bad setter returns undef' );
61
62
my $borrower = Koha::Borrower->new(
63
    {
64
        borrowernumber      => '12345',
65
        cardnumber          => '1234567890',
66
        surname             => 'mySurname',
67
        firstname           => 'myFirstname',
68
        title               => 'Mr.',
69
        othernames          => 'myOthernames',
70
        initials            => 'MM',
71
        streetnumber        => '100',
72
        streettype          => 'Blvd',
73
        address             => 'my personnal address',
74
        address2            => 'my adress2',
75
        city                => 'Marseille',
76
        state               => 'mystate',
77
        zipcode             => '13006',
78
        country             => 'France',
79
        email               => 'mySurname.myFirstname@email.com',
80
        phone               => '0402872934',
81
        mobile              => '0627884632',
82
        fax                 => '0402872935',
83
        emailpro            => 'myEmailPro@email.com',
84
        phonepro            => '0402873334',
85
        B_streetnumber      => '101',
86
        B_streettype        => 'myB_streettype',
87
        B_address           => 'myB_address',
88
        B_address2          => 'myB_address2',
89
        B_city              => 'myB_city',
90
        B_state             => 'myB_state',
91
        B_zipcode           => '23456',
92
        B_country           => 'myB_country',
93
        B_email             => 'myB_email',
94
        B_phone             => '0678353935',
95
        dateofbirth         => '1990-07-16',
96
        branchcode          => 'myBranCode',
97
        categorycode        => 'myCatCode',
98
        dateenrolled        => '2015-03-19',
99
        dateexpiry          => '2016-03-19',
100
        gonenoaddress       => '0',
101
        lost                => '0',
102
        debarred            => '2015-04-19',
103
        debarredcomment     => 'You are debarred',
104
        contactname         => 'myContactname',
105
        contactfirstname    => 'myContactfirstname',
106
        contacttitle        => 'myContacttitle',
107
        guarantorid         => '123454321',
108
        borrowernotes       => 'borrowernotes',
109
        relationship        => 'myRelationship',
110
        sex                 => 'M',
111
        password            => 'hfkurhfe976634èj!',
112
        flags               => '55555',
113
        userid              => '87987',
114
        opacnote            => 'myOpacnote',
115
        contactnote         => 'myContactnote',
116
        sort1               => 'mySort1',
117
        sort2               => 'mySort2',
118
        altcontactfirstname => 'myAltcontactfirstname',
119
        altcontactsurname   => 'myAltcontactsurname',
120
        altcontactaddress1  => 'myAltcontactaddress1',
121
        altcontactaddress2  => 'myAltcontactaddress2',
122
        altcontactaddress3  => 'myAltcontactaddress3',
123
        altcontactstate     => 'myAltcontactstate',
124
        altcontactzipcode   => '465843',
125
        altcontactcountry   => 'myOtherCountry',
126
        altcontactphone     => 'myOtherphone',
127
        smsalertnumber      => '0683027346',
128
        privacy             => '667788',
129
    }
130
);
131
132
#borrower Accessor tests
133
subtest 'Accessor tests' => sub {
134
    plan tests => 65;
135
    is( $borrower->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
136
    is( $borrower->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
137
    is( $borrower->surname,        'mySurname',                       'surname accessor returns correct value' );
138
    is( $borrower->firstname,      'myFirstname',                     'firstname accessor returns correct value' );
139
    is( $borrower->title,          'Mr.',                             'title accessor returns correct value' );
140
    is( $borrower->othernames,     'myOthernames',                    'othernames accessor returns correct value' );
141
    is( $borrower->initials,       'MM',                              'initials accessor returns correct value' );
142
    is( $borrower->streetnumber,   '100',                             'streetnumber accessor returns correct value' );
143
    is( $borrower->streettype,     'Blvd',                            'streettype accessor returns correct value' );
144
    is( $borrower->address,        'my personnal address',            'address accessor returns correct value' );
145
    is( $borrower->address2,       'my adress2',                      'address2 accessor returns correct value' );
146
    is( $borrower->city,           'Marseille',                       'city accessor returns correct value' );
147
    is( $borrower->state,          'mystate',                         'state accessor returns correct value' );
148
    is( $borrower->zipcode,        '13006',                           'zipcode accessor returns correct value' );
149
    is( $borrower->country,        'France',                          'country accessor returns correct value' );
150
    is( $borrower->email,          'mySurname.myFirstname@email.com', 'email accessor returns correct value' );
151
    is( $borrower->phone,          '0402872934',                      'phone accessor returns correct value' );
152
    is( $borrower->mobile,         '0627884632',                      'mobile accessor returns correct value' );
153
    is( $borrower->fax,            '0402872935',                      'fax accessor returns correct value' );
154
    is( $borrower->emailpro,       'myEmailPro@email.com',            'emailpro accessor returns correct value' );
155
    is( $borrower->phonepro,       '0402873334',                      'phonepro accessor returns correct value' );
156
    is( $borrower->B_streetnumber, '101',                             'B_streetnumber accessor returns correct value' );
157
    is( $borrower->B_streettype,   'myB_streettype',                  'B_streettype accessor returns correct value' );
158
    is( $borrower->B_address,      'myB_address',                     'B_address accessor returns correct value' );
159
    is( $borrower->B_address2,     'myB_address2',                    'B_address2 accessor returns correct value' );
160
    is( $borrower->B_city,         'myB_city',                        'B_city accessor returns correct value' );
161
    is( $borrower->B_state,        'myB_state',                       'B_state accessor returns correct value' );
162
    is( $borrower->B_zipcode,      '23456',                           'B_zipcode accessor returns correct value' );
163
    is( $borrower->B_country,      'myB_country',                     'B_country accessor returns correct value' );
164
    is( $borrower->B_email,        'myB_email',                       'B_email accessor returns correct value' );
165
    is( $borrower->B_phone,        '0678353935',                      'B_phone accessor returns correct value' );
166
    is( $borrower->dateofbirth,    '1990-07-16',                      'dateofbirth accessor returns correct value' );
167
    is( $borrower->branchcode,     'myBranCode',                      'branchcode accessor returns correct value' );
168
    is( $borrower->categorycode,   'myCatCode',                       'categorycode accessor returns correct value' );
169
    is( $borrower->dateenrolled,   '2015-03-19',                      'dateenrolled accessor returns correct value' );
170
    is( $borrower->dateexpiry,     '2016-03-19',                      'dateexpiry accessor returns correct value' );
171
    is( $borrower->gonenoaddress,  '0',                               'gonenoaddress accessor returns correct value' );
172
    is( $borrower->lost,           '0',                               'lost accessor returns correct value' );
173
    is( $borrower->debarred,       '2015-04-19',                      'debarred accessor returns correct value' );
174
    is( $borrower->debarredcomment,     'You are debarred',      'debarredcomment accessor returns correct value' );
175
    is( $borrower->contactname,         'myContactname',         'contactname accessor returns correct value' );
176
    is( $borrower->contactfirstname,    'myContactfirstname',    'contactfirstname accessor returns correct value' );
177
    is( $borrower->contacttitle,        'myContacttitle',        'contacttitle accessor returns correct value' );
178
    is( $borrower->guarantorid,         '123454321',             'guarantorid accessor returns correct value' );
179
    is( $borrower->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
180
    is( $borrower->relationship,        'myRelationship',        'relationship accessor returns correct value' );
181
    is( $borrower->sex,                 'M',                     'sex accessor returns correct value' );
182
    is( $borrower->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
183
    is( $borrower->flags,               '55555',                 'flags accessor returns correct value' );
184
    is( $borrower->userid,              '87987',                 'userid accessor returns correct value' );
185
    is( $borrower->opacnote,            'myOpacnote',            'opacnote accessor returns correct value' );
186
    is( $borrower->contactnote,         'myContactnote',         'contactnote accessor returns correct value' );
187
    is( $borrower->sort1,               'mySort1',               'sort1 accessor returns correct value' );
188
    is( $borrower->sort2,               'mySort2',               'sort2 accessor returns correct value' );
189
    is( $borrower->altcontactfirstname, 'myAltcontactfirstname', 'altcontactfirstname accessor returns correct value' );
190
    is( $borrower->altcontactsurname,   'myAltcontactsurname',   'altcontactsurname accessor returns correct value' );
191
    is( $borrower->altcontactaddress1,  'myAltcontactaddress1',  'altcontactaddress1 accessor returns correct value' );
192
    is( $borrower->altcontactaddress2,  'myAltcontactaddress2',  'altcontactaddress2 accessor returns correct value' );
193
    is( $borrower->altcontactaddress3,  'myAltcontactaddress3',  'altcontactaddress3 accessor returns correct value' );
194
    is( $borrower->altcontactstate,     'myAltcontactstate',     'altcontactstate accessor returns correct value' );
195
    is( $borrower->altcontactzipcode,   '465843',                'altcontactzipcode accessor returns correct value' );
196
    is( $borrower->altcontactcountry,   'myOtherCountry',        'altcontactcountry accessor returns correct value' );
197
    is( $borrower->altcontactphone,     'myOtherphone',          'altcontactphone accessor returns correct value' );
198
    is( $borrower->smsalertnumber,      '0683027346',            'smsalertnumber accessor returns correct value' );
199
    is( $borrower->privacy,             '667788',                'privacy accessor returns correct value' );
200
};
201
202
#borrower Set tests
203
subtest 'Set tests' => sub {
204
    plan tests => 65;
205
206
    $borrower->set(
207
        {
208
            borrowernumber      => '12346',
209
            cardnumber          => '1234567891',
210
            surname             => 'SmySurname',
211
            firstname           => 'SmyFirstname',
212
            title               => 'Mme.',
213
            othernames          => 'SmyOthernames',
214
            initials            => 'SS',
215
            streetnumber        => '200',
216
            streettype          => 'Rue',
217
            address             => 'Smy personnal address',
218
            address2            => 'Smy adress2',
219
            city                => 'Lyon',
220
            state               => 'Smystate',
221
            zipcode             => '69000',
222
            country             => 'France',
223
            email               => 'SmySurname.myFirstname@email.com',
224
            phone               => '0402872935',
225
            mobile              => '0627884633',
226
            fax                 => '0402872936',
227
            emailpro            => 'SmyEmailPro@email.com',
228
            phonepro            => '0402873335',
229
            B_streetnumber      => '102',
230
            B_streettype        => 'SmyB_streettype',
231
            B_address           => 'SmyB_address',
232
            B_address2          => 'SmyB_address2',
233
            B_city              => 'SmyB_city',
234
            B_state             => 'SmyB_state',
235
            B_zipcode           => '12333',
236
            B_country           => 'SmyB_country',
237
            B_email             => 'SmyB_email',
238
            B_phone             => '0678353936',
239
            dateofbirth         => '1991-07-16',
240
            branchcode          => 'SmyBranCode',
241
            categorycode        => 'SmyCatCode',
242
            dateenrolled        => '2014-03-19',
243
            dateexpiry          => '2017-03-19',
244
            gonenoaddress       => '1',
245
            lost                => '1',
246
            debarred            => '2016-04-19',
247
            debarredcomment     => 'You are still debarred',
248
            contactname         => 'SmyContactname',
249
            contactfirstname    => 'SmyContactfirstname',
250
            contacttitle        => 'SmyContacttitle',
251
            guarantorid         => '223454321',
252
            borrowernotes       => 'Sborrowernotes',
253
            relationship        => 'SmyRelationship',
254
            sex                 => 'F',
255
            password            => 'zerzerzer#',
256
            flags               => '666666',
257
            userid              => '98233',
258
            opacnote            => 'SmyOpacnote',
259
            contactnote         => 'SmyContactnote',
260
            sort1               => 'SmySort1',
261
            sort2               => 'SmySort2',
262
            altcontactfirstname => 'SmyAltcontactfirstname',
263
            altcontactsurname   => 'SmyAltcontactsurname',
264
            altcontactaddress1  => 'SmyAltcontactaddress1',
265
            altcontactaddress2  => 'SmyAltcontactaddress2',
266
            altcontactaddress3  => 'SmyAltcontactaddress3',
267
            altcontactstate     => 'SmyAltcontactstate',
268
            altcontactzipcode   => '565843',
269
            altcontactcountry   => 'SmyOtherCountry',
270
            altcontactphone     => 'SmyOtherphone',
271
            smsalertnumber      => '0683027347',
272
            privacy             => '667789'
273
        }
274
    );
275
276
    is( $borrower->borrowernumber,      '12346',                            'borrowernumber field set ok' );
277
    is( $borrower->cardnumber,          '1234567891',                       'cardnumber field set ok' );
278
    is( $borrower->surname,             'SmySurname',                       'surname field set ok' );
279
    is( $borrower->firstname,           'SmyFirstname',                     'firstname field set ok' );
280
    is( $borrower->title,               'Mme.',                             'title field set ok' );
281
    is( $borrower->othernames,          'SmyOthernames',                    'othernames field set ok' );
282
    is( $borrower->initials,            'SS',                               'initials field set ok' );
283
    is( $borrower->streetnumber,        '200',                              'streetnumber field set ok' );
284
    is( $borrower->streettype,          'Rue',                              'streettype field set ok' );
285
    is( $borrower->address,             'Smy personnal address',            'address field set ok' );
286
    is( $borrower->address2,            'Smy adress2',                      'address2 field set ok' );
287
    is( $borrower->city,                'Lyon',                             'city field set ok' );
288
    is( $borrower->state,               'Smystate',                         'state field set ok' );
289
    is( $borrower->zipcode,             '69000',                            'zipcode field set ok' );
290
    is( $borrower->country,             'France',                           'country field set ok' );
291
    is( $borrower->email,               'SmySurname.myFirstname@email.com', 'email field set ok' );
292
    is( $borrower->phone,               '0402872935',                       'phone field set ok' );
293
    is( $borrower->mobile,              '0627884633',                       'mobile field set ok' );
294
    is( $borrower->fax,                 '0402872936',                       'fax field set ok' );
295
    is( $borrower->emailpro,            'SmyEmailPro@email.com',            'emailpro field set ok' );
296
    is( $borrower->phonepro,            '0402873335',                       'phonepro field set ok' );
297
    is( $borrower->B_streetnumber,      '102',                              'B_streetnumber field set ok' );
298
    is( $borrower->B_streettype,        'SmyB_streettype',                  'B_streettype field set ok' );
299
    is( $borrower->B_address,           'SmyB_address',                     'B_address field set ok' );
300
    is( $borrower->B_address2,          'SmyB_address2',                    'B_address2 field set ok' );
301
    is( $borrower->B_city,              'SmyB_city',                        'B_city field set ok' );
302
    is( $borrower->B_state,             'SmyB_state',                       'B_state field set ok' );
303
    is( $borrower->B_zipcode,           '12333',                            'B_zipcode field set ok' );
304
    is( $borrower->B_country,           'SmyB_country',                     'B_country field set ok' );
305
    is( $borrower->B_email,             'SmyB_email',                       'B_email field set ok' );
306
    is( $borrower->B_phone,             '0678353936',                       'B_phone field set ok' );
307
    is( $borrower->dateofbirth,         '1991-07-16',                       'dateofbirth field set ok' );
308
    is( $borrower->branchcode,          'SmyBranCode',                      'branchcode field set ok' );
309
    is( $borrower->categorycode,        'SmyCatCode',                       'categorycode field set ok' );
310
    is( $borrower->dateenrolled,        '2014-03-19',                       'dateenrolled field set ok' );
311
    is( $borrower->dateexpiry,          '2017-03-19',                       'dateexpiry field set ok' );
312
    is( $borrower->gonenoaddress,       '1',                                'gonenoaddress field set ok' );
313
    is( $borrower->lost,                '1',                                'lost field set ok' );
314
    is( $borrower->debarred,            '2016-04-19',                       'debarred field set ok' );
315
    is( $borrower->debarredcomment,     'You are still debarred',           'debarredcomment field set ok' );
316
    is( $borrower->contactname,         'SmyContactname',                   'contactname field set ok' );
317
    is( $borrower->contactfirstname,    'SmyContactfirstname',              'contactfirstname field set ok' );
318
    is( $borrower->contacttitle,        'SmyContacttitle',                  'contacttitle field set ok' );
319
    is( $borrower->guarantorid,         '223454321',                        'guarantorid field set ok' );
320
    is( $borrower->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
321
    is( $borrower->relationship,        'SmyRelationship',                  'relationship field set ok' );
322
    is( $borrower->sex,                 'F',                                'sex field set ok' );
323
    is( $borrower->password,            'zerzerzer#',                       'password field set ok' );
324
    is( $borrower->flags,               '666666',                           'flags field set ok' );
325
    is( $borrower->userid,              '98233',                            'userid field set ok' );
326
    is( $borrower->opacnote,            'SmyOpacnote',                      'opacnote field set ok' );
327
    is( $borrower->contactnote,         'SmyContactnote',                   'contactnote field set ok' );
328
    is( $borrower->sort1,               'SmySort1',                         'sort1 field set ok' );
329
    is( $borrower->sort2,               'SmySort2',                         'sort2 field set ok' );
330
    is( $borrower->altcontactfirstname, 'SmyAltcontactfirstname',           'altcontactfirstname field set ok' );
331
    is( $borrower->altcontactsurname,   'SmyAltcontactsurname',             'altcontactsurname field set ok' );
332
    is( $borrower->altcontactaddress1,  'SmyAltcontactaddress1',            'altcontactaddress1 field set ok' );
333
    is( $borrower->altcontactaddress2,  'SmyAltcontactaddress2',            'altcontactaddress2 field set ok' );
334
    is( $borrower->altcontactaddress3,  'SmyAltcontactaddress3',            'altcontactaddress3 field set ok' );
335
    is( $borrower->altcontactstate,     'SmyAltcontactstate',               'altcontactstate field set ok' );
336
    is( $borrower->altcontactzipcode,   '565843',                           'altcontactzipcode field set ok' );
337
    is( $borrower->altcontactcountry,   'SmyOtherCountry',                  'altcontactcountry field set ok' );
338
    is( $borrower->altcontactphone,     'SmyOtherphone',                    'altcontactphone field set ok' );
339
    is( $borrower->smsalertnumber,      '0683027347',                       'smsalertnumber field set ok' );
340
    is( $borrower->privacy,             '667789',                           'privacy field set ok' );
341
};
342
343
1;
(-)a/t/Patron.t (+343 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 18;
21
use Test::Warn;
22
use t::lib::Mocks;
23
24
BEGIN {
25
    t::lib::Mocks::mock_dbh;
26
    use_ok('Koha::Object');
27
    use_ok('Koha::Patron');
28
}
29
30
my $object = Koha::Patron->new( { surname => 'Test Patron' } );
31
is( $object->surname(), 'Test Patron', "Accessor returns correct value" );
32
$object->surname('Test Patron Surname');
33
is( $object->surname(), 'Test Patron Surname', "Accessor returns correct value after set" );
34
35
my $object2 = Koha::Patron->new( { surname => 'Test Patron 2' } );
36
is( $object2->surname(), 'Test Patron 2', "Accessor returns correct value" );
37
$object2->surname('Test Patron Surname 2');
38
is( $object2->surname(), 'Test Patron Surname 2', "Accessor returns correct value after set" );
39
40
my $ret;
41
$ret = $object2->set( { surname => "Test Patron Surname 3", firstname => "Test Firstname" } );
42
ok( ref($ret) eq 'Koha::Patron', "Set returns object on success" );
43
is( $object2->surname(),   "Test Patron Surname 3", "Set sets first field correctly" );
44
is( $object2->firstname(), "Test Firstname",          "Set sets second field correctly" );
45
46
warning_is { $ret = $object->set({ surname => "Test Patron Surname 4", bork => "bork" }) }
47
            "No property bork!",
48
            "Expected 'No property bork!' caught";
49
is( $object2->surname(), "Test Patron Surname 3", "Bad Set does not set field" );
50
is( $ret, 0, "Set returns 0 when passed a bad property" );
51
52
warning_is { $ret = $object->bork() }
53
            "No method bork!",
54
            "Expected 'No method bork!' caught for getter.";
55
ok( ! defined $ret, 'Bad getter returns undef' );
56
57
warning_is { $ret = $object->bork('bork') }
58
            "No method bork!",
59
            "Expected 'No method bork!' caught for setter.";
60
ok( ! defined $ret, 'Bad setter returns undef' );
61
62
my $patron = Koha::Patron->new(
63
    {
64
        borrowernumber      => '12345',
65
        cardnumber          => '1234567890',
66
        surname             => 'mySurname',
67
        firstname           => 'myFirstname',
68
        title               => 'Mr.',
69
        othernames          => 'myOthernames',
70
        initials            => 'MM',
71
        streetnumber        => '100',
72
        streettype          => 'Blvd',
73
        address             => 'my personnal address',
74
        address2            => 'my adress2',
75
        city                => 'Marseille',
76
        state               => 'mystate',
77
        zipcode             => '13006',
78
        country             => 'France',
79
        email               => 'mySurname.myFirstname@email.com',
80
        phone               => '0402872934',
81
        mobile              => '0627884632',
82
        fax                 => '0402872935',
83
        emailpro            => 'myEmailPro@email.com',
84
        phonepro            => '0402873334',
85
        B_streetnumber      => '101',
86
        B_streettype        => 'myB_streettype',
87
        B_address           => 'myB_address',
88
        B_address2          => 'myB_address2',
89
        B_city              => 'myB_city',
90
        B_state             => 'myB_state',
91
        B_zipcode           => '23456',
92
        B_country           => 'myB_country',
93
        B_email             => 'myB_email',
94
        B_phone             => '0678353935',
95
        dateofbirth         => '1990-07-16',
96
        branchcode          => 'myBranCode',
97
        categorycode        => 'myCatCode',
98
        dateenrolled        => '2015-03-19',
99
        dateexpiry          => '2016-03-19',
100
        gonenoaddress       => '0',
101
        lost                => '0',
102
        debarred            => '2015-04-19',
103
        debarredcomment     => 'You are debarred',
104
        contactname         => 'myContactname',
105
        contactfirstname    => 'myContactfirstname',
106
        contacttitle        => 'myContacttitle',
107
        guarantorid         => '123454321',
108
        borrowernotes       => 'borrowernotes',
109
        relationship        => 'myRelationship',
110
        sex                 => 'M',
111
        password            => 'hfkurhfe976634èj!',
112
        flags               => '55555',
113
        userid              => '87987',
114
        opacnote            => 'myOpacnote',
115
        contactnote         => 'myContactnote',
116
        sort1               => 'mySort1',
117
        sort2               => 'mySort2',
118
        altcontactfirstname => 'myAltcontactfirstname',
119
        altcontactsurname   => 'myAltcontactsurname',
120
        altcontactaddress1  => 'myAltcontactaddress1',
121
        altcontactaddress2  => 'myAltcontactaddress2',
122
        altcontactaddress3  => 'myAltcontactaddress3',
123
        altcontactstate     => 'myAltcontactstate',
124
        altcontactzipcode   => '465843',
125
        altcontactcountry   => 'myOtherCountry',
126
        altcontactphone     => 'myOtherphone',
127
        smsalertnumber      => '0683027346',
128
        privacy             => '667788',
129
    }
130
);
131
132
# patron Accessor tests
133
subtest 'Accessor tests' => sub {
134
    plan tests => 65;
135
    is( $patron->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
136
    is( $patron->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
137
    is( $patron->surname,        'mySurname',                       'surname accessor returns correct value' );
138
    is( $patron->firstname,      'myFirstname',                     'firstname accessor returns correct value' );
139
    is( $patron->title,          'Mr.',                             'title accessor returns correct value' );
140
    is( $patron->othernames,     'myOthernames',                    'othernames accessor returns correct value' );
141
    is( $patron->initials,       'MM',                              'initials accessor returns correct value' );
142
    is( $patron->streetnumber,   '100',                             'streetnumber accessor returns correct value' );
143
    is( $patron->streettype,     'Blvd',                            'streettype accessor returns correct value' );
144
    is( $patron->address,        'my personnal address',            'address accessor returns correct value' );
145
    is( $patron->address2,       'my adress2',                      'address2 accessor returns correct value' );
146
    is( $patron->city,           'Marseille',                       'city accessor returns correct value' );
147
    is( $patron->state,          'mystate',                         'state accessor returns correct value' );
148
    is( $patron->zipcode,        '13006',                           'zipcode accessor returns correct value' );
149
    is( $patron->country,        'France',                          'country accessor returns correct value' );
150
    is( $patron->email,          'mySurname.myFirstname@email.com', 'email accessor returns correct value' );
151
    is( $patron->phone,          '0402872934',                      'phone accessor returns correct value' );
152
    is( $patron->mobile,         '0627884632',                      'mobile accessor returns correct value' );
153
    is( $patron->fax,            '0402872935',                      'fax accessor returns correct value' );
154
    is( $patron->emailpro,       'myEmailPro@email.com',            'emailpro accessor returns correct value' );
155
    is( $patron->phonepro,       '0402873334',                      'phonepro accessor returns correct value' );
156
    is( $patron->B_streetnumber, '101',                             'B_streetnumber accessor returns correct value' );
157
    is( $patron->B_streettype,   'myB_streettype',                  'B_streettype accessor returns correct value' );
158
    is( $patron->B_address,      'myB_address',                     'B_address accessor returns correct value' );
159
    is( $patron->B_address2,     'myB_address2',                    'B_address2 accessor returns correct value' );
160
    is( $patron->B_city,         'myB_city',                        'B_city accessor returns correct value' );
161
    is( $patron->B_state,        'myB_state',                       'B_state accessor returns correct value' );
162
    is( $patron->B_zipcode,      '23456',                           'B_zipcode accessor returns correct value' );
163
    is( $patron->B_country,      'myB_country',                     'B_country accessor returns correct value' );
164
    is( $patron->B_email,        'myB_email',                       'B_email accessor returns correct value' );
165
    is( $patron->B_phone,        '0678353935',                      'B_phone accessor returns correct value' );
166
    is( $patron->dateofbirth,    '1990-07-16',                      'dateofbirth accessor returns correct value' );
167
    is( $patron->branchcode,     'myBranCode',                      'branchcode accessor returns correct value' );
168
    is( $patron->categorycode,   'myCatCode',                       'categorycode accessor returns correct value' );
169
    is( $patron->dateenrolled,   '2015-03-19',                      'dateenrolled accessor returns correct value' );
170
    is( $patron->dateexpiry,     '2016-03-19',                      'dateexpiry accessor returns correct value' );
171
    is( $patron->gonenoaddress,  '0',                               'gonenoaddress accessor returns correct value' );
172
    is( $patron->lost,           '0',                               'lost accessor returns correct value' );
173
    is( $patron->debarred,       '2015-04-19',                      'debarred accessor returns correct value' );
174
    is( $patron->debarredcomment,     'You are debarred',      'debarredcomment accessor returns correct value' );
175
    is( $patron->contactname,         'myContactname',         'contactname accessor returns correct value' );
176
    is( $patron->contactfirstname,    'myContactfirstname',    'contactfirstname accessor returns correct value' );
177
    is( $patron->contacttitle,        'myContacttitle',        'contacttitle accessor returns correct value' );
178
    is( $patron->guarantorid,         '123454321',             'guarantorid accessor returns correct value' );
179
    is( $patron->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
180
    is( $patron->relationship,        'myRelationship',        'relationship accessor returns correct value' );
181
    is( $patron->sex,                 'M',                     'sex accessor returns correct value' );
182
    is( $patron->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
183
    is( $patron->flags,               '55555',                 'flags accessor returns correct value' );
184
    is( $patron->userid,              '87987',                 'userid accessor returns correct value' );
185
    is( $patron->opacnote,            'myOpacnote',            'opacnote accessor returns correct value' );
186
    is( $patron->contactnote,         'myContactnote',         'contactnote accessor returns correct value' );
187
    is( $patron->sort1,               'mySort1',               'sort1 accessor returns correct value' );
188
    is( $patron->sort2,               'mySort2',               'sort2 accessor returns correct value' );
189
    is( $patron->altcontactfirstname, 'myAltcontactfirstname', 'altcontactfirstname accessor returns correct value' );
190
    is( $patron->altcontactsurname,   'myAltcontactsurname',   'altcontactsurname accessor returns correct value' );
191
    is( $patron->altcontactaddress1,  'myAltcontactaddress1',  'altcontactaddress1 accessor returns correct value' );
192
    is( $patron->altcontactaddress2,  'myAltcontactaddress2',  'altcontactaddress2 accessor returns correct value' );
193
    is( $patron->altcontactaddress3,  'myAltcontactaddress3',  'altcontactaddress3 accessor returns correct value' );
194
    is( $patron->altcontactstate,     'myAltcontactstate',     'altcontactstate accessor returns correct value' );
195
    is( $patron->altcontactzipcode,   '465843',                'altcontactzipcode accessor returns correct value' );
196
    is( $patron->altcontactcountry,   'myOtherCountry',        'altcontactcountry accessor returns correct value' );
197
    is( $patron->altcontactphone,     'myOtherphone',          'altcontactphone accessor returns correct value' );
198
    is( $patron->smsalertnumber,      '0683027346',            'smsalertnumber accessor returns correct value' );
199
    is( $patron->privacy,             '667788',                'privacy accessor returns correct value' );
200
};
201
202
# patron Set tests
203
subtest 'Set tests' => sub {
204
    plan tests => 65;
205
206
    $patron->set(
207
        {
208
            borrowernumber      => '12346',
209
            cardnumber          => '1234567891',
210
            surname             => 'SmySurname',
211
            firstname           => 'SmyFirstname',
212
            title               => 'Mme.',
213
            othernames          => 'SmyOthernames',
214
            initials            => 'SS',
215
            streetnumber        => '200',
216
            streettype          => 'Rue',
217
            address             => 'Smy personnal address',
218
            address2            => 'Smy adress2',
219
            city                => 'Lyon',
220
            state               => 'Smystate',
221
            zipcode             => '69000',
222
            country             => 'France',
223
            email               => 'SmySurname.myFirstname@email.com',
224
            phone               => '0402872935',
225
            mobile              => '0627884633',
226
            fax                 => '0402872936',
227
            emailpro            => 'SmyEmailPro@email.com',
228
            phonepro            => '0402873335',
229
            B_streetnumber      => '102',
230
            B_streettype        => 'SmyB_streettype',
231
            B_address           => 'SmyB_address',
232
            B_address2          => 'SmyB_address2',
233
            B_city              => 'SmyB_city',
234
            B_state             => 'SmyB_state',
235
            B_zipcode           => '12333',
236
            B_country           => 'SmyB_country',
237
            B_email             => 'SmyB_email',
238
            B_phone             => '0678353936',
239
            dateofbirth         => '1991-07-16',
240
            branchcode          => 'SmyBranCode',
241
            categorycode        => 'SmyCatCode',
242
            dateenrolled        => '2014-03-19',
243
            dateexpiry          => '2017-03-19',
244
            gonenoaddress       => '1',
245
            lost                => '1',
246
            debarred            => '2016-04-19',
247
            debarredcomment     => 'You are still debarred',
248
            contactname         => 'SmyContactname',
249
            contactfirstname    => 'SmyContactfirstname',
250
            contacttitle        => 'SmyContacttitle',
251
            guarantorid         => '223454321',
252
            borrowernotes       => 'Sborrowernotes',
253
            relationship        => 'SmyRelationship',
254
            sex                 => 'F',
255
            password            => 'zerzerzer#',
256
            flags               => '666666',
257
            userid              => '98233',
258
            opacnote            => 'SmyOpacnote',
259
            contactnote         => 'SmyContactnote',
260
            sort1               => 'SmySort1',
261
            sort2               => 'SmySort2',
262
            altcontactfirstname => 'SmyAltcontactfirstname',
263
            altcontactsurname   => 'SmyAltcontactsurname',
264
            altcontactaddress1  => 'SmyAltcontactaddress1',
265
            altcontactaddress2  => 'SmyAltcontactaddress2',
266
            altcontactaddress3  => 'SmyAltcontactaddress3',
267
            altcontactstate     => 'SmyAltcontactstate',
268
            altcontactzipcode   => '565843',
269
            altcontactcountry   => 'SmyOtherCountry',
270
            altcontactphone     => 'SmyOtherphone',
271
            smsalertnumber      => '0683027347',
272
            privacy             => '667789'
273
        }
274
    );
275
276
    is( $patron->borrowernumber,      '12346',                            'borrowernumber field set ok' );
277
    is( $patron->cardnumber,          '1234567891',                       'cardnumber field set ok' );
278
    is( $patron->surname,             'SmySurname',                       'surname field set ok' );
279
    is( $patron->firstname,           'SmyFirstname',                     'firstname field set ok' );
280
    is( $patron->title,               'Mme.',                             'title field set ok' );
281
    is( $patron->othernames,          'SmyOthernames',                    'othernames field set ok' );
282
    is( $patron->initials,            'SS',                               'initials field set ok' );
283
    is( $patron->streetnumber,        '200',                              'streetnumber field set ok' );
284
    is( $patron->streettype,          'Rue',                              'streettype field set ok' );
285
    is( $patron->address,             'Smy personnal address',            'address field set ok' );
286
    is( $patron->address2,            'Smy adress2',                      'address2 field set ok' );
287
    is( $patron->city,                'Lyon',                             'city field set ok' );
288
    is( $patron->state,               'Smystate',                         'state field set ok' );
289
    is( $patron->zipcode,             '69000',                            'zipcode field set ok' );
290
    is( $patron->country,             'France',                           'country field set ok' );
291
    is( $patron->email,               'SmySurname.myFirstname@email.com', 'email field set ok' );
292
    is( $patron->phone,               '0402872935',                       'phone field set ok' );
293
    is( $patron->mobile,              '0627884633',                       'mobile field set ok' );
294
    is( $patron->fax,                 '0402872936',                       'fax field set ok' );
295
    is( $patron->emailpro,            'SmyEmailPro@email.com',            'emailpro field set ok' );
296
    is( $patron->phonepro,            '0402873335',                       'phonepro field set ok' );
297
    is( $patron->B_streetnumber,      '102',                              'B_streetnumber field set ok' );
298
    is( $patron->B_streettype,        'SmyB_streettype',                  'B_streettype field set ok' );
299
    is( $patron->B_address,           'SmyB_address',                     'B_address field set ok' );
300
    is( $patron->B_address2,          'SmyB_address2',                    'B_address2 field set ok' );
301
    is( $patron->B_city,              'SmyB_city',                        'B_city field set ok' );
302
    is( $patron->B_state,             'SmyB_state',                       'B_state field set ok' );
303
    is( $patron->B_zipcode,           '12333',                            'B_zipcode field set ok' );
304
    is( $patron->B_country,           'SmyB_country',                     'B_country field set ok' );
305
    is( $patron->B_email,             'SmyB_email',                       'B_email field set ok' );
306
    is( $patron->B_phone,             '0678353936',                       'B_phone field set ok' );
307
    is( $patron->dateofbirth,         '1991-07-16',                       'dateofbirth field set ok' );
308
    is( $patron->branchcode,          'SmyBranCode',                      'branchcode field set ok' );
309
    is( $patron->categorycode,        'SmyCatCode',                       'categorycode field set ok' );
310
    is( $patron->dateenrolled,        '2014-03-19',                       'dateenrolled field set ok' );
311
    is( $patron->dateexpiry,          '2017-03-19',                       'dateexpiry field set ok' );
312
    is( $patron->gonenoaddress,       '1',                                'gonenoaddress field set ok' );
313
    is( $patron->lost,                '1',                                'lost field set ok' );
314
    is( $patron->debarred,            '2016-04-19',                       'debarred field set ok' );
315
    is( $patron->debarredcomment,     'You are still debarred',           'debarredcomment field set ok' );
316
    is( $patron->contactname,         'SmyContactname',                   'contactname field set ok' );
317
    is( $patron->contactfirstname,    'SmyContactfirstname',              'contactfirstname field set ok' );
318
    is( $patron->contacttitle,        'SmyContacttitle',                  'contacttitle field set ok' );
319
    is( $patron->guarantorid,         '223454321',                        'guarantorid field set ok' );
320
    is( $patron->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
321
    is( $patron->relationship,        'SmyRelationship',                  'relationship field set ok' );
322
    is( $patron->sex,                 'F',                                'sex field set ok' );
323
    is( $patron->password,            'zerzerzer#',                       'password field set ok' );
324
    is( $patron->flags,               '666666',                           'flags field set ok' );
325
    is( $patron->userid,              '98233',                            'userid field set ok' );
326
    is( $patron->opacnote,            'SmyOpacnote',                      'opacnote field set ok' );
327
    is( $patron->contactnote,         'SmyContactnote',                   'contactnote field set ok' );
328
    is( $patron->sort1,               'SmySort1',                         'sort1 field set ok' );
329
    is( $patron->sort2,               'SmySort2',                         'sort2 field set ok' );
330
    is( $patron->altcontactfirstname, 'SmyAltcontactfirstname',           'altcontactfirstname field set ok' );
331
    is( $patron->altcontactsurname,   'SmyAltcontactsurname',             'altcontactsurname field set ok' );
332
    is( $patron->altcontactaddress1,  'SmyAltcontactaddress1',            'altcontactaddress1 field set ok' );
333
    is( $patron->altcontactaddress2,  'SmyAltcontactaddress2',            'altcontactaddress2 field set ok' );
334
    is( $patron->altcontactaddress3,  'SmyAltcontactaddress3',            'altcontactaddress3 field set ok' );
335
    is( $patron->altcontactstate,     'SmyAltcontactstate',               'altcontactstate field set ok' );
336
    is( $patron->altcontactzipcode,   '565843',                           'altcontactzipcode field set ok' );
337
    is( $patron->altcontactcountry,   'SmyOtherCountry',                  'altcontactcountry field set ok' );
338
    is( $patron->altcontactphone,     'SmyOtherphone',                    'altcontactphone field set ok' );
339
    is( $patron->smsalertnumber,      '0683027347',                       'smsalertnumber field set ok' );
340
    is( $patron->privacy,             '667789',                           'privacy field set ok' );
341
};
342
343
1;
(-)a/t/db_dependent/Accounts.t (-3 / +3 lines)
Lines 27-33 use t::lib::TestBuilder; Link Here
27
BEGIN {
27
BEGIN {
28
    use_ok('C4::Accounts');
28
    use_ok('C4::Accounts');
29
    use_ok('Koha::Object');
29
    use_ok('Koha::Object');
30
    use_ok('Koha::Borrower');
30
    use_ok('Koha::Patron');
31
    use_ok('Data::Dumper');
31
    use_ok('Data::Dumper');
32
}
32
}
33
33
Lines 107-113 my @test_data = ( Link Here
107
    { amount => -5    , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 }
107
    { amount => -5    , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 }
108
);
108
);
109
109
110
my $borrower = Koha::Borrower->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => 'MPL' } )->store();
110
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => 'MPL' } )->store();
111
111
112
for my $data ( @test_data ) {
112
for my $data ( @test_data ) {
113
    $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
113
    $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
Lines 144-150 subtest "recordpayment() tests" => sub { Link Here
144
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
144
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
145
    my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
145
    my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
146
146
147
    my $borrower = Koha::Borrower->new( {
147
    my $borrower = Koha::Patron->new( {
148
        cardnumber => '1234567890',
148
        cardnumber => '1234567890',
149
        surname => 'McFly',
149
        surname => 'McFly',
150
        firstname => 'Marty',
150
        firstname => 'Marty',
(-)a/t/db_dependent/BiblioObject.t (-2 / +2 lines)
Lines 21-27 use C4::Context; Link Here
21
use C4::Biblio qw( AddBiblio );
21
use C4::Biblio qw( AddBiblio );
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Branches;
23
use Koha::Branches;
24
use Koha::Borrowers;
24
use Koha::Patrons;
25
25
26
use Test::More tests => 4;
26
use Test::More tests => 4;
27
27
Lines 35-41 my $dbh = C4::Context->dbh; Link Here
35
$dbh->{RaiseError} = 1;
35
$dbh->{RaiseError} = 1;
36
36
37
my @branches = Koha::Branches->search();
37
my @branches = Koha::Branches->search();
38
my $borrower = Koha::Borrowers->search()->next();
38
my $borrower = Koha::Patrons->search()->next();
39
39
40
my $biblio = MARC::Record->new();
40
my $biblio = MARC::Record->new();
41
$biblio->append_fields(
41
$biblio->append_fields(
(-)a/t/db_dependent/Circulation/AnonymiseIssueHistory.t (-2 / +2 lines)
Lines 203-209 subtest 'Test StoreLastBorrower' => sub { Link Here
203
203
204
    $item_object   = Koha::Items->find( $item->{itemnumber} );
204
    $item_object   = Koha::Items->find( $item->{itemnumber} );
205
    $patron_object = $item_object->last_returned_by();
205
    $patron_object = $item_object->last_returned_by();
206
    is( ref($patron_object), 'Koha::Borrower', 'Koha::Item::last_returned_by returned Koha::Borrower' );
206
    is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' );
207
207
208
    $patron = $builder->build(
208
    $patron = $builder->build(
209
        {
209
        {
Lines 234-240 subtest 'Test StoreLastBorrower' => sub { Link Here
234
            value  => { privacy => 1, }
234
            value  => { privacy => 1, }
235
        }
235
        }
236
    );
236
    );
237
    $patron_object = Koha::Borrowers->find( $patron->{borrowernumber} );
237
    $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
238
238
239
    $item_object->last_returned_by($patron_object);
239
    $item_object->last_returned_by($patron_object);
240
    $item_object = Koha::Items->find( $item->{itemnumber} );
240
    $item_object = Koha::Items->find( $item->{itemnumber} );
(-)a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t (-1 / +1 lines)
Lines 12-18 use C4::Items qw( AddItem ); Link Here
12
use C4::Members qw( AddMember GetMember );
12
use C4::Members qw( AddMember GetMember );
13
use Koha::Database;
13
use Koha::Database;
14
use Koha::DateUtils;
14
use Koha::DateUtils;
15
use Koha::Borrower::Debarments qw( GetDebarments DelDebarment );
15
use Koha::Patron::Debarments qw( GetDebarments DelDebarment );
16
16
17
use t::lib::TestBuilder;
17
use t::lib::TestBuilder;
18
18
(-)a/t/db_dependent/Creators/Lib.t (-1 / +1 lines)
Lines 29-35 BEGIN { Link Here
29
    use_ok('C4::Creators::Lib');
29
    use_ok('C4::Creators::Lib');
30
    use_ok('C4::Biblio');
30
    use_ok('C4::Biblio');
31
    use_ok('C4::Context');
31
    use_ok('C4::Context');
32
    use_ok('Koha::Borrower');
32
    use_ok('Koha::Patron');
33
    use_ok('MARC::Record');
33
    use_ok('MARC::Record');
34
}
34
}
35
35
(-)a/t/db_dependent/Hold.t (-2 / +2 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use C4::Context;
20
use C4::Context;
21
use C4::Biblio qw( AddBiblio );
21
use C4::Biblio qw( AddBiblio );
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Borrowers;
23
use Koha::Patrons;
24
use Koha::Branches;
24
use Koha::Branches;
25
use Koha::Item;
25
use Koha::Item;
26
26
Lines 35-41 my $dbh = C4::Context->dbh; Link Here
35
$dbh->{RaiseError} = 1;
35
$dbh->{RaiseError} = 1;
36
36
37
my @branches = Koha::Branches->search();
37
my @branches = Koha::Branches->search();
38
my $borrower = Koha::Borrowers->search()->next();
38
my $borrower = Koha::Patrons->search()->next();
39
39
40
my $biblio = MARC::Record->new();
40
my $biblio = MARC::Record->new();
41
my $title  = 'Silence in the library';
41
my $title  = 'Silence in the library';
(-)a/t/db_dependent/Koha_borrower_modifications.t (-20 / +20 lines)
Lines 6-12 use Test::More tests => 14; Link Here
6
use C4::Context;
6
use C4::Context;
7
use C4::Members;
7
use C4::Members;
8
8
9
use Koha::Borrower::Modifications;
9
use Koha::Patron::Modifications;
10
10
11
my $dbh = C4::Context->dbh;
11
my $dbh = C4::Context->dbh;
12
$dbh->{RaiseError} = 1;
12
$dbh->{RaiseError} = 1;
Lines 15-25 $dbh->{AutoCommit} = 0; Link Here
15
$dbh->do("DELETE FROM borrower_modifications");
15
$dbh->do("DELETE FROM borrower_modifications");
16
16
17
## Create new pending modification
17
## Create new pending modification
18
Koha::Borrower::Modifications->new( verification_token => '1234567890' )
18
Koha::Patron::Modifications->new( verification_token => '1234567890' )
19
  ->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
19
  ->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
20
20
21
## Get the new pending modification
21
## Get the new pending modification
22
my $borrower = Koha::Borrower::Modifications->GetModifications(
22
my $borrower = Koha::Patron::Modifications->GetModifications(
23
    { verification_token => '1234567890' } );
23
    { verification_token => '1234567890' } );
24
24
25
## Verify we get the same data
25
## Verify we get the same data
Lines 28-92 ok( $borrower->{'surname'} = 'Hall', Link Here
28
28
29
## Check the Verify method
29
## Check the Verify method
30
ok(
30
ok(
31
    Koha::Borrower::Modifications->Verify('1234567890'),
31
    Koha::Patron::Modifications->Verify('1234567890'),
32
    'Test that Verify() succeeds with a valid token'
32
    'Test that Verify() succeeds with a valid token'
33
);
33
);
34
34
35
## Delete the pending modification
35
## Delete the pending modification
36
$borrower = Koha::Borrower::Modifications->DelModifications(
36
$borrower = Koha::Patron::Modifications->DelModifications(
37
    { verification_token => '1234567890' } );
37
    { verification_token => '1234567890' } );
38
38
39
## Verify it's no longer in the database
39
## Verify it's no longer in the database
40
$borrower = Koha::Borrower::Modifications->GetModifications(
40
$borrower = Koha::Patron::Modifications->GetModifications(
41
    { verification_token => '1234567890' } );
41
    { verification_token => '1234567890' } );
42
ok( !defined( $borrower->{'surname'} ), 'Test DelModifications()' );
42
ok( !defined( $borrower->{'surname'} ), 'Test DelModifications()' );
43
43
44
## Check the Verify method
44
## Check the Verify method
45
ok(
45
ok(
46
    !Koha::Borrower::Modifications->Verify('1234567890'),
46
    !Koha::Patron::Modifications->Verify('1234567890'),
47
    'Test that Verify() method fails for a bad token'
47
    'Test that Verify() method fails for a bad token'
48
);
48
);
49
49
50
## Create new pending modification, but for an existing borrower
50
## Create new pending modification, but for an existing borrower
51
Koha::Borrower::Modifications->new( borrowernumber => '2' )
51
Koha::Patron::Modifications->new( borrowernumber => '2' )
52
  ->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
52
  ->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
53
53
54
## Test the counter
54
## Test the counter
55
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
55
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
56
    'Test GetPendingModificationsCount()' );
56
    'Test GetPendingModificationsCount()' );
57
57
58
## Create new pending modification for another existing borrower
58
## Create new pending modification for another existing borrower
59
Koha::Borrower::Modifications->new( borrowernumber => '3' )
59
Koha::Patron::Modifications->new( borrowernumber => '3' )
60
  ->AddModifications( { surname => 'Smith', firstname => 'Sandy' } );
60
  ->AddModifications( { surname => 'Smith', firstname => 'Sandy' } );
61
61
62
## Test the counter
62
## Test the counter
63
ok(
63
ok(
64
    Koha::Borrower::Modifications->GetPendingModificationsCount() == 2,
64
    Koha::Patron::Modifications->GetPendingModificationsCount() == 2,
65
'Add a new pending modification and test GetPendingModificationsCount() again'
65
'Add a new pending modification and test GetPendingModificationsCount() again'
66
);
66
);
67
67
68
## Check GetPendingModifications
68
## Check GetPendingModifications
69
my $pendings = Koha::Borrower::Modifications->GetPendingModifications();
69
my $pendings = Koha::Patron::Modifications->GetPendingModifications();
70
my @firstnames_mod = sort ( $pendings->[0]->{firstname}, $pendings->[1]->{firstname} );
70
my @firstnames_mod = sort ( $pendings->[0]->{firstname}, $pendings->[1]->{firstname} );
71
ok( $firstnames_mod[0] eq 'Kyle', 'Test GetPendingModifications()' );
71
ok( $firstnames_mod[0] eq 'Kyle', 'Test GetPendingModifications()' );
72
ok( $firstnames_mod[1] eq 'Sandy', 'Test GetPendingModifications() again' );
72
ok( $firstnames_mod[1] eq 'Sandy', 'Test GetPendingModifications() again' );
73
73
74
## This should delete the row from the table
74
## This should delete the row from the table
75
Koha::Borrower::Modifications->DenyModifications('3');
75
Koha::Patron::Modifications->DenyModifications('3');
76
76
77
## Test the counter
77
## Test the counter
78
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
78
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
79
    'Test DenyModifications()' );
79
    'Test DenyModifications()' );
80
80
81
## Save a copy of the borrowers original data
81
## Save a copy of the borrowers original data
82
my $old_borrower = GetMember( borrowernumber => '2' );
82
my $old_borrower = GetMember( borrowernumber => '2' );
83
83
84
## Apply the modifications
84
## Apply the modifications
85
Koha::Borrower::Modifications->ApproveModifications('2');
85
Koha::Patron::Modifications->ApproveModifications('2');
86
86
87
## Test the counter
87
## Test the counter
88
ok(
88
ok(
89
    Koha::Borrower::Modifications->GetPendingModificationsCount() == 0,
89
    Koha::Patron::Modifications->GetPendingModificationsCount() == 0,
90
    'Test ApproveModifications() removes pending modification from db'
90
    'Test ApproveModifications() removes pending modification from db'
91
);
91
);
92
92
Lines 98-104 ok( $new_borrower->{'surname'} eq 'Hall', Link Here
98
    'Test ApproveModifications() applys modification to borrower' );
98
    'Test ApproveModifications() applys modification to borrower' );
99
99
100
## Now let's put it back the way it was
100
## Now let's put it back the way it was
101
Koha::Borrower::Modifications->new( borrowernumber => '2' )->AddModifications(
101
Koha::Patron::Modifications->new( borrowernumber => '2' )->AddModifications(
102
    {
102
    {
103
        surname   => $old_borrower->{'surname'},
103
        surname   => $old_borrower->{'surname'},
104
        firstname => $old_borrower->{'firstname'}
104
        firstname => $old_borrower->{'firstname'}
Lines 106-120 Koha::Borrower::Modifications->new( borrowernumber => '2' )->AddModifications( Link Here
106
);
106
);
107
107
108
## Test the counter
108
## Test the counter
109
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
109
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
110
    'Test GetPendingModificationsCount()' );
110
    'Test GetPendingModificationsCount()' );
111
111
112
## Apply the modifications
112
## Apply the modifications
113
Koha::Borrower::Modifications->ApproveModifications('2');
113
Koha::Patron::Modifications->ApproveModifications('2');
114
114
115
## Test the counter
115
## Test the counter
116
ok(
116
ok(
117
    Koha::Borrower::Modifications->GetPendingModificationsCount() == 0,
117
    Koha::Patron::Modifications->GetPendingModificationsCount() == 0,
118
    'Test ApproveModifications() removes pending modification from db, again'
118
    'Test ApproveModifications() removes pending modification from db, again'
119
);
119
);
120
120
(-)a/t/db_dependent/Borrower.t (-6 / +6 lines)
Lines 25-31 use Koha::Database; Link Here
25
25
26
BEGIN {
26
BEGIN {
27
    use_ok('Koha::Object');
27
    use_ok('Koha::Object');
28
    use_ok('Koha::Borrower');
28
    use_ok('Koha::Patron');
29
}
29
}
30
30
31
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
Lines 34-40 $schema->storage->txn_begin; Link Here
34
my $categorycode = $schema->resultset('Category')->first()->categorycode();
34
my $categorycode = $schema->resultset('Category')->first()->categorycode();
35
my $branchcode = $schema->resultset('Branch')->first()->branchcode();
35
my $branchcode = $schema->resultset('Branch')->first()->branchcode();
36
36
37
my $object = Koha::Borrower->new();
37
my $object = Koha::Patron->new();
38
38
39
is( $object->in_storage, 0, "Object is not in storage" );
39
is( $object->in_storage, 0, "Object is not in storage" );
40
40
Lines 47-54 is( $object->in_storage, 1, "Object is now stored" ); Link Here
47
47
48
my $borrowernumber = $object->borrowernumber;
48
my $borrowernumber = $object->borrowernumber;
49
49
50
my $borrower = $schema->resultset('Borrower')->find( $borrowernumber );
50
my $patron = $schema->resultset('Borrower')->find( $borrowernumber );
51
is( $borrower->surname(), "Test Surname", "Object found in database" );
51
is( $patron->surname(), "Test Surname", "Object found in database" );
52
52
53
is( $object->is_changed(), 0, "Object is unchanged" );
53
is( $object->is_changed(), 0, "Object is unchanged" );
54
$object->surname("Test Surname");
54
$object->surname("Test Surname");
Lines 65-72 $object->store(); Link Here
65
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
65
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
66
66
67
$object->delete();
67
$object->delete();
68
$borrower = $schema->resultset('Borrower')->find( $borrowernumber );
68
$patron = $schema->resultset('Borrower')->find( $borrowernumber );
69
ok( ! $borrower, "Object no longer found in database" );
69
ok( ! $patron, "Object no longer found in database" );
70
is( $object->in_storage, 0, "Object is not in storage" );
70
is( $object->in_storage, 0, "Object is not in storage" );
71
71
72
1;
72
1;
(-)a/t/db_dependent/Borrower_Debarments.t (-4 / +4 lines)
Lines 10-16 use t::lib::TestBuilder; Link Here
10
10
11
use Test::More tests => 31;
11
use Test::More tests => 31;
12
12
13
use_ok('Koha::Borrower::Debarments');
13
use_ok('Koha::Patron::Debarments');
14
14
15
my $schema = Koha::Database->schema;
15
my $schema = Koha::Database->schema;
16
$schema->storage->txn_begin;
16
$schema->storage->txn_begin;
Lines 65-73 $debarments = GetDebarments({ borrowernumber => $borrowernumber }); Link Here
65
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
65
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
66
66
67
67
68
my $borrower = GetMember( borrowernumber => $borrowernumber );
68
my $patron = GetMember( borrowernumber => $borrowernumber );
69
is( $borrower->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly" );
69
is( $patron->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly" );
70
is( $borrower->{'debarredcomment'}, "Test 1\nTest 3", "Field borrowers.debarredcomment set correctly" );
70
is( $patron->{'debarredcomment'}, "Test 1\nTest 3", "Field borrowers.debarredcomment set correctly" );
71
71
72
72
73
AddUniqueDebarment({
73
AddUniqueDebarment({
(-)a/t/db_dependent/Borrower_Discharge.t (-30 / +30 lines)
Lines 25-31 use C4::Context; Link Here
25
use C4::Items qw( AddItem );
25
use C4::Items qw( AddItem );
26
use C4::Members qw( AddMember GetMember );
26
use C4::Members qw( AddMember GetMember );
27
27
28
use Koha::Borrower::Discharge;
28
use Koha::Patron::Discharge;
29
use Koha::Database;
29
use Koha::Database;
30
30
31
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
Lines 47-65 my $another_library = $builder->build({ Link Here
47
47
48
C4::Context->_new_userenv('xxx');
48
C4::Context->_new_userenv('xxx');
49
C4::Context->set_userenv(0, 0, 0, 'firstname', 'surname', $library->{branchcode}, $library->{branchcode}, '', '', '', '', '');
49
C4::Context->set_userenv(0, 0, 0, 'firstname', 'surname', $library->{branchcode}, $library->{branchcode}, '', '', '', '', '');
50
my $borrower = $builder->build({
50
my $patron = $builder->build({
51
    source => 'Borrower',
51
    source => 'Borrower',
52
    value => {
52
    value => {
53
        branchcode => $library->{branchcode},
53
        branchcode => $library->{branchcode},
54
    }
54
    }
55
});
55
});
56
my $borrower2 = $builder->build({
56
my $patron2 = $builder->build({
57
    source => 'Borrower',
57
    source => 'Borrower',
58
    value => {
58
    value => {
59
        branchcode => $library->{branchcode},
59
        branchcode => $library->{branchcode},
60
    }
60
    }
61
});
61
});
62
my $borrower3 = $builder->build({
62
my $patron3 = $builder->build({
63
    source => 'Borrower',
63
    source => 'Borrower',
64
    value => {
64
    value => {
65
        branchcode => $another_library->{branchcode},
65
        branchcode => $another_library->{branchcode},
Lines 70-119 my $borrower3 = $builder->build({ Link Here
70
my ( $biblionumber ) = AddBiblio( MARC::Record->new, '');
70
my ( $biblionumber ) = AddBiblio( MARC::Record->new, '');
71
my $barcode = 'BARCODE42';
71
my $barcode = 'BARCODE42';
72
my ( undef, undef, $itemnumber ) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $barcode }, $biblionumber);
72
my ( undef, undef, $itemnumber ) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $barcode }, $biblionumber);
73
AddIssue( $borrower, $barcode );
73
AddIssue( $patron, $barcode );
74
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrower->{borrowernumber} }), 0, 'A patron with issues cannot be discharged' );
74
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->{borrowernumber} }), 0, 'A patron with issues cannot be discharged' );
75
75
76
is( Koha::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }), undef, 'No request done if patron has issues' );
76
is( Koha::Patron::Discharge::request({ borrowernumber => $patron->{borrowernumber} }), undef, 'No request done if patron has issues' );
77
is( Koha::Borrower::Discharge::discharge({ borrowernumber => $borrower->{borrowernumber} }), undef, 'No discharge done if patron has issues' );
77
is( Koha::Patron::Discharge::discharge({ borrowernumber => $patron->{borrowernumber} }), undef, 'No discharge done if patron has issues' );
78
is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request' );
78
is_deeply( Koha::Patron::Discharge::get_pendings(), [], 'There is no pending discharge request' );
79
is_deeply( Koha::Borrower::Discharge::get_validated(), [], 'There is no validated discharge' );
79
is_deeply( Koha::Patron::Discharge::get_validated(), [], 'There is no validated discharge' );
80
80
81
AddReturn( $barcode );
81
AddReturn( $barcode );
82
82
83
# Discharge possible without issue
83
# Discharge possible without issue
84
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrower->{borrowernumber} }), 1, 'A patron without issues can be discharged' );
84
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->{borrowernumber} }), 1, 'A patron without issues can be discharged' );
85
85
86
is(Koha::Borrower::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
86
is(Koha::Patron::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
87
87
88
# Verify that the user is not discharged anymore if the restriction has been lifted
88
# Verify that the user is not discharged anymore if the restriction has been lifted
89
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower->{borrowernumber} } );
89
Koha::Patron::Discharge::discharge( { borrowernumber => $patron->{borrowernumber} } );
90
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower2->{borrowernumber} } );
90
Koha::Patron::Discharge::discharge( { borrowernumber => $patron2->{borrowernumber} } );
91
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower3->{borrowernumber} } );
91
Koha::Patron::Discharge::discharge( { borrowernumber => $patron3->{borrowernumber} } );
92
is( Koha::Borrower::Discharge::is_discharged( { borrowernumber => $borrower->{borrowernumber} } ), 1, 'The patron has been discharged' );
92
is( Koha::Patron::Discharge::is_discharged( { borrowernumber => $patron->{borrowernumber} } ), 1, 'The patron has been discharged' );
93
is( Koha::Borrower::Debarments::IsDebarred( $borrower->{borrowernumber} ), '9999-12-31', 'The patron has been debarred after discharge' );
93
is( Koha::Patron::Debarments::IsDebarred( $patron->{borrowernumber} ), '9999-12-31', 'The patron has been debarred after discharge' );
94
is( scalar( @{ Koha::Borrower::Discharge::get_validated() } ),             3,            'There are 3 validated discharges' );
94
is( scalar( @{ Koha::Patron::Discharge::get_validated() } ),             3,            'There are 3 validated discharges' );
95
is( scalar( @{ Koha::Borrower::Discharge::get_validated( { borrowernumber => $borrower->{borrowernumber} } ) } ), 1, 'There is 1 validated discharge for a given patron' );
95
is( scalar( @{ Koha::Patron::Discharge::get_validated( { borrowernumber => $patron->{borrowernumber} } ) } ), 1, 'There is 1 validated discharge for a given patron' );
96
is( scalar( @{ Koha::Borrower::Discharge::get_validated( { branchcode => $library->{branchcode} } ) } ), 2, 'There is 2 validated discharges for a given branchcode' );    # This is not used in the code yet
96
is( scalar( @{ Koha::Patron::Discharge::get_validated( { branchcode => $library->{branchcode} } ) } ), 2, 'There is 2 validated discharges for a given branchcode' );    # This is not used in the code yet
97
Koha::Borrower::Debarments::DelUniqueDebarment( { 'borrowernumber' => $borrower->{borrowernumber}, 'type' => 'DISCHARGE' } );
97
Koha::Patron::Debarments::DelUniqueDebarment( { 'borrowernumber' => $patron->{borrowernumber}, 'type' => 'DISCHARGE' } );
98
ok( !Koha::Borrower::Debarments::IsDebarred( $borrower->{borrowernumber} ), 'The debarment has been lifted' );
98
ok( !Koha::Patron::Debarments::IsDebarred( $patron->{borrowernumber} ), 'The debarment has been lifted' );
99
ok( !Koha::Borrower::Discharge::is_discharged( { borrowernumber => $borrower->{borrowernumber} } ), 'The patron is not discharged after the restriction has been lifted' );
99
ok( !Koha::Patron::Discharge::is_discharged( { borrowernumber => $patron->{borrowernumber} } ), 'The patron is not discharged after the restriction has been lifted' );
100
100
101
# Verify that the discharge works multiple times
101
# Verify that the discharge works multiple times
102
Koha::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} });
102
Koha::Patron::Discharge::request({ borrowernumber => $patron->{borrowernumber} });
103
is(scalar( @{ Koha::Borrower::Discharge::get_pendings() }), 1, 'There is a pending discharge request (second time)');
103
is(scalar( @{ Koha::Patron::Discharge::get_pendings() }), 1, 'There is a pending discharge request (second time)');
104
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower->{borrowernumber} } );
104
Koha::Patron::Discharge::discharge( { borrowernumber => $patron->{borrowernumber} } );
105
is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request (second time)');
105
is_deeply( Koha::Patron::Discharge::get_pendings(), [], 'There is no pending discharge request (second time)');
106
106
107
# Check if PDF::FromHTML is installed.
107
# Check if PDF::FromHTML is installed.
108
my $check = eval { require PDF::FromHTML; };
108
my $check = eval { require PDF::FromHTML; };
109
109
110
# Tests for if PDF::FromHTML is installed
110
# Tests for if PDF::FromHTML is installed
111
if ($check) {
111
if ($check) {
112
    isnt( Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrower->{borrowernumber} }), undef, "Temporary PDF generated." );
112
    isnt( Koha::Patron::Discharge::generate_as_pdf({ borrowernumber => $patron->{borrowernumber} }), undef, "Temporary PDF generated." );
113
}
113
}
114
# Tests for if PDF::FromHTML is not installed
114
# Tests for if PDF::FromHTML is not installed
115
else {
115
else {
116
    warning_like { Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrower->{borrowernumber}, testing => 1 }) }
116
    warning_like { Koha::Patron::Discharge::generate_as_pdf({ borrowernumber => $patron->{borrowernumber}, testing => 1 }) }
117
          [ qr/Can't locate PDF\/FromHTML.pm in \@INC/ ],
117
          [ qr/Can't locate PDF\/FromHTML.pm in \@INC/ ],
118
          "Expected failure because of missing PDF::FromHTML.";
118
          "Expected failure because of missing PDF::FromHTML.";
119
}
119
}
Lines 126-132 else { Link Here
126
# Even if we switch off this flag, the connection will be blocked.
126
# Even if we switch off this flag, the connection will be blocked.
127
# The error is:
127
# The error is:
128
# DBIx::Class::ResultSet::create(): DBI Exception: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "INSERT INTO discharges ( borrower, needed, validated) VALUES ( ?, ?, ? )" with ParamValues: 0='121', 1='2014-01-08T16:38:29', 2=undef] at /home/koha/src/Koha/DataObject/Discharge.pm line 33
128
# DBIx::Class::ResultSet::create(): DBI Exception: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "INSERT INTO discharges ( borrower, needed, validated) VALUES ( ?, ?, ? )" with ParamValues: 0='121', 1='2014-01-08T16:38:29', 2=undef] at /home/koha/src/Koha/DataObject/Discharge.pm line 33
129
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }), 1, 'Discharge request sent' );
129
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $patron->{borrowernumber} }), 1, 'Discharge request sent' );
130
130
131
$schema->storage->txn_rollback;
131
$schema->storage->txn_rollback;
132
132
(-)a/t/db_dependent/Borrower_Files.t (-2 / +2 lines)
Lines 27-33 use t::lib::TestBuilder; Link Here
27
27
28
use Test::More tests => 23;
28
use Test::More tests => 23;
29
29
30
use_ok('Koha::Borrower::Files');
30
use_ok('Koha::Patron::Files');
31
31
32
my $schema = Koha::Database->schema;
32
my $schema = Koha::Database->schema;
33
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
Lines 49-55 my $borrowernumber = AddMember( Link Here
49
    branchcode => $library->{branchcode},
49
    branchcode => $library->{branchcode},
50
);
50
);
51
51
52
my $bf = Koha::Borrower::Files->new(
52
my $bf = Koha::Patron::Files->new(
53
    borrowernumber => $borrowernumber,
53
    borrowernumber => $borrowernumber,
54
);
54
);
55
55
(-)a/t/db_dependent/Borrowers.t (-21 / +21 lines)
Lines 25-31 use Koha::Database; Link Here
25
25
26
BEGIN {
26
BEGIN {
27
    use_ok('Koha::Objects');
27
    use_ok('Koha::Objects');
28
    use_ok('Koha::Borrowers');
28
    use_ok('Koha::Patrons');
29
}
29
}
30
30
31
# Start transaction
31
# Start transaction
Lines 41-47 my $categorycode = Link Here
41
my $branchcode =
41
my $branchcode =
42
  Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
42
  Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
43
43
44
my $b1 = Koha::Borrower->new(
44
my $b1 = Koha::Patron->new(
45
    {
45
    {
46
        surname      => 'Test 1',
46
        surname      => 'Test 1',
47
        branchcode   => $branchcode,
47
        branchcode   => $branchcode,
Lines 49-55 my $b1 = Koha::Borrower->new( Link Here
49
    }
49
    }
50
);
50
);
51
$b1->store();
51
$b1->store();
52
my $b2 = Koha::Borrower->new(
52
my $b2 = Koha::Patron->new(
53
    {
53
    {
54
        surname      => 'Test 2',
54
        surname      => 'Test 2',
55
        branchcode   => $branchcode,
55
        branchcode   => $branchcode,
Lines 57-63 my $b2 = Koha::Borrower->new( Link Here
57
    }
57
    }
58
);
58
);
59
$b2->store();
59
$b2->store();
60
my $b3 = Koha::Borrower->new(
60
my $b3 = Koha::Patron->new(
61
    {
61
    {
62
        surname      => 'Test 3',
62
        surname      => 'Test 3',
63
        branchcode   => $branchcode,
63
        branchcode   => $branchcode,
Lines 66-96 my $b3 = Koha::Borrower->new( Link Here
66
);
66
);
67
$b3->store();
67
$b3->store();
68
68
69
my $b1_new = Koha::Borrowers->find( $b1->borrowernumber() );
69
my $b1_new = Koha::Patrons->find( $b1->borrowernumber() );
70
is( $b1->surname(), $b1_new->surname(), "Found matching borrower" );
70
is( $b1->surname(), $b1_new->surname(), "Found matching patron" );
71
71
72
my @borrowers = Koha::Borrowers->search( { branchcode => $branchcode } );
72
my @patrons = Koha::Patrons->search( { branchcode => $branchcode } );
73
is( @borrowers, 3, "Found 3 borrowers with Search" );
73
is( @patrons, 3, "Found 3 patrons with Search" );
74
74
75
my $unexistent = Koha::Borrowers->find( '1234567890' );
75
my $unexistent = Koha::Patrons->find( '1234567890' );
76
is( $unexistent, undef, 'Koha::Objects->Find should return undef if the record does not exist' );
76
is( $unexistent, undef, 'Koha::Objects->Find should return undef if the record does not exist' );
77
77
78
my $borrowers = Koha::Borrowers->search( { branchcode => $branchcode } );
78
my $patrons = Koha::Patrons->search( { branchcode => $branchcode } );
79
is( $borrowers->count( { branchcode => $branchcode } ), 3, "Counted 3 borrowers with Count" );
79
is( $patrons->count( { branchcode => $branchcode } ), 3, "Counted 3 patrons with Count" );
80
80
81
my $b = $borrowers->next();
81
my $b = $patrons->next();
82
is( $b->surname(), 'Test 1', "Next returns first borrower" );
82
is( $b->surname(), 'Test 1', "Next returns first patron" );
83
$b = $borrowers->next();
83
$b = $patrons->next();
84
is( $b->surname(), 'Test 2', "Next returns second borrower" );
84
is( $b->surname(), 'Test 2', "Next returns second patron" );
85
$b = $borrowers->next();
85
$b = $patrons->next();
86
is( $b->surname(), 'Test 3', "Next returns third borrower" );
86
is( $b->surname(), 'Test 3', "Next returns third patron" );
87
$b = $borrowers->next();
87
$b = $patrons->next();
88
is( $b, undef, "Next returns undef" );
88
is( $b, undef, "Next returns undef" );
89
89
90
# Test Reset and iteration in concert
90
# Test Reset and iteration in concert
91
$borrowers->reset();
91
$patrons->reset();
92
foreach my $b ( $borrowers->as_list() ) {
92
foreach my $b ( $patrons->as_list() ) {
93
    is( $b->categorycode(), $categorycode, "Iteration returns a borrower object" );
93
    is( $b->categorycode(), $categorycode, "Iteration returns a patron object" );
94
}
94
}
95
95
96
1;
96
1;
(-)a/t/db_dependent/Review.t (-4 / +4 lines)
Lines 27-33 use Time::Piece; Link Here
27
BEGIN {
27
BEGIN {
28
    use_ok('C4::Biblio');
28
    use_ok('C4::Biblio');
29
    use_ok('C4::Review');
29
    use_ok('C4::Review');
30
    use_ok('Koha::Borrower');
30
    use_ok('Koha::Patron');
31
    use_ok('MARC::Record');
31
    use_ok('MARC::Record');
32
}
32
}
33
33
Lines 59-65 my $builder = t::lib::TestBuilder->new; Link Here
59
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
59
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
60
my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
60
my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
61
61
62
my $b1 = Koha::Borrower->new(
62
my $b1 = Koha::Patron->new(
63
    {   surname      => 'Borrower 1',
63
    {   surname      => 'Borrower 1',
64
        branchcode   => $branchcode,
64
        branchcode   => $branchcode,
65
        categorycode => $categorycode
65
        categorycode => $categorycode
Lines 67-73 my $b1 = Koha::Borrower->new( Link Here
67
);
67
);
68
$b1->store();
68
$b1->store();
69
69
70
my $b2 = Koha::Borrower->new(
70
my $b2 = Koha::Patron->new(
71
    {   surname      => 'Borrower 2',
71
    {   surname      => 'Borrower 2',
72
        branchcode   => $branchcode,
72
        branchcode   => $branchcode,
73
        categorycode => $categorycode
73
        categorycode => $categorycode
Lines 75-81 my $b2 = Koha::Borrower->new( Link Here
75
);
75
);
76
$b2->store();
76
$b2->store();
77
77
78
my $b3 = Koha::Borrower->new(
78
my $b3 = Koha::Patron->new(
79
    {   surname      => 'Borrower 3',
79
    {   surname      => 'Borrower 3',
80
        branchcode   => $branchcode,
80
        branchcode   => $branchcode,
81
        categorycode => $categorycode
81
        categorycode => $categorycode
(-)a/t/db_dependent/api/v1/patrons.t (-1 / +1 lines)
Lines 25-31 use C4::Auth; Link Here
25
use C4::Context;
25
use C4::Context;
26
26
27
use Koha::Database;
27
use Koha::Database;
28
use Koha::Borrower;
28
use Koha::Patron;
29
29
30
my $builder = t::lib::TestBuilder->new();
30
my $builder = t::lib::TestBuilder->new();
31
31
(-)a/tools/import_borrowers.pl (-2 / +1 lines)
Lines 47-53 use C4::Members::AttributeTypes; Link Here
47
use C4::Members::Messaging;
47
use C4::Members::Messaging;
48
use C4::Reports::Guided;
48
use C4::Reports::Guided;
49
use C4::Templates;
49
use C4::Templates;
50
use Koha::Borrower::Debarments;
50
use Koha::Patron::Debarments;
51
use Koha::DateUtils;
51
use Koha::DateUtils;
52
52
53
use Text::CSV;
53
use Text::CSV;
54
- 

Return to bug 15548