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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 48-54 use Koha::Checkouts; Link Here
48
use Koha::Illrequests;
48
use Koha::Illrequests;
49
use Koha::Items;
49
use Koha::Items;
50
use Koha::Patrons;
50
use Koha::Patrons;
51
use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments );
51
use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments AddUniqueDebarment );
52
use Koha::Database;
52
use Koha::Database;
53
use Koha::Libraries;
53
use Koha::Libraries;
54
use Koha::Account::Lines;
54
use Koha::Account::Lines;
(-)a/Koha/Patron/Debarments.pm (-9 / +13 lines)
Lines 21-39 use Modern::Perl; Link Here
21
21
22
use C4::Context;
22
use C4::Context;
23
23
24
use parent qw( Exporter );
24
our ( @ISA, @EXPORT_OK );
25
25
26
our @EXPORT = qw(
26
BEGIN {
27
  GetDebarments
27
    require Exporter;
28
    @ISA       = qw(Exporter);
29
    @EXPORT_OK = qw(
30
      GetDebarments
28
31
29
  AddDebarment
32
      AddDebarment
30
  DelDebarment
33
      DelDebarment
31
  ModDebarment
34
      ModDebarment
32
35
33
  AddUniqueDebarment
36
      AddUniqueDebarment
34
  DelUniqueDebarment
37
      DelUniqueDebarment
35
38
36
);
39
    );
40
}
37
41
38
=head1 Koha::Patron::Debarments
42
=head1 Koha::Patron::Debarments
39
43
(-)a/Koha/Patron/Discharge.pm (-1 / +1 lines)
Lines 11-17 use C4::Letters qw( GetPreparedLetter ); Link Here
11
use Koha::Database;
11
use Koha::Database;
12
use Koha::DateUtils qw( dt_from_string output_pref );
12
use Koha::DateUtils qw( dt_from_string output_pref );
13
use Koha::Patrons;
13
use Koha::Patrons;
14
use Koha::Patron::Debarments;
14
use Koha::Patron::Debarments qw( AddDebarment );
15
15
16
sub count {
16
sub count {
17
    my ($params) = @_;
17
    my ($params) = @_;
(-)a/misc/cronjobs/cleanup_database.pl (+1 lines)
Lines 52-57 use Koha::Old::Patrons; Link Here
52
use Koha::Item::Transfers;
52
use Koha::Item::Transfers;
53
use Koha::PseudonymizedTransactions;
53
use Koha::PseudonymizedTransactions;
54
use Koha::Patron::Messages;
54
use Koha::Patron::Messages;
55
use Koha::Patron::Debarments qw( DelDebarment );
55
56
56
sub usage {
57
sub usage {
57
    print STDERR <<USAGE;
58
    print STDERR <<USAGE;
(-)a/t/db_dependent/Circulation.t (+1 lines)
Lines 46-51 use Koha::Items; Link Here
46
use Koha::Item::Transfers;
46
use Koha::Item::Transfers;
47
use Koha::Checkouts;
47
use Koha::Checkouts;
48
use Koha::Patrons;
48
use Koha::Patrons;
49
use Koha::Patron::Debarments qw( GetDebarments AddDebarment DelUniqueDebarment );
49
use Koha::Holds;
50
use Koha::Holds;
50
use Koha::CirculationRules;
51
use Koha::CirculationRules;
51
use Koha::Subscriptions;
52
use Koha::Subscriptions;
(-)a/t/db_dependent/Circulation/MarkIssueReturned.t (-1 / +1 lines)
Lines 30-36 use Koha::Database; Link Here
30
use Koha::DateUtils qw(dt_from_string);
30
use Koha::DateUtils qw(dt_from_string);
31
use Koha::Old::Checkouts;
31
use Koha::Old::Checkouts;
32
use Koha::Patrons;
32
use Koha::Patrons;
33
use Koha::Patron::Debarments;
33
use Koha::Patron::Debarments qw( GetDebarments AddUniqueDebarment );
34
34
35
my $schema = Koha::Database->schema;
35
my $schema = Koha::Database->schema;
36
my $builder = t::lib::TestBuilder->new;
36
my $builder = t::lib::TestBuilder->new;
(-)a/t/db_dependent/Patron/Borrower_Debarments.t (-24 / +24 lines)
Lines 29-35 my $borrowernumber = Koha::Patron->new({ Link Here
29
    branchcode => $library->{branchcode},
29
    branchcode => $library->{branchcode},
30
})->store->borrowernumber;
30
})->store->borrowernumber;
31
31
32
my $success = AddDebarment({
32
my $success = Koha::Patron::Debarments::AddDebarment({
33
    borrowernumber => $borrowernumber,
33
    borrowernumber => $borrowernumber,
34
    expiration => '9999-06-10',
34
    expiration => '9999-06-10',
35
    type => 'MANUAL',
35
    type => 'MANUAL',
Lines 38-68 my $success = AddDebarment({ Link Here
38
is( $success, 1, "AddDebarment returned true" );
38
is( $success, 1, "AddDebarment returned true" );
39
39
40
40
41
my $debarments = GetDebarments({ borrowernumber => $borrowernumber });
41
my $debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
42
is( @$debarments, 1, "GetDebarments returns 1 debarment" );
42
is( @$debarments, 1, "GetDebarments returns 1 debarment" );
43
is( $debarments->[0]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
43
is( $debarments->[0]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
44
is( $debarments->[0]->{'expiration'}, '9999-06-10', "Correctly stored 'expiration'" );
44
is( $debarments->[0]->{'expiration'}, '9999-06-10', "Correctly stored 'expiration'" );
45
is( $debarments->[0]->{'comment'}, 'Test 1', "Correctly stored 'comment'" );
45
is( $debarments->[0]->{'comment'}, 'Test 1', "Correctly stored 'comment'" );
46
46
47
47
48
$success = AddDebarment({
48
$success = Koha::Patron::Debarments::AddDebarment({
49
    borrowernumber => $borrowernumber,
49
    borrowernumber => $borrowernumber,
50
    comment => 'Test 2',
50
    comment => 'Test 2',
51
});
51
});
52
52
53
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
53
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
54
is( @$debarments, 2, "GetDebarments returns 2 debarments" );
54
is( @$debarments, 2, "GetDebarments returns 2 debarments" );
55
is( $debarments->[1]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
55
is( $debarments->[1]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
56
is( $debarments->[1]->{'expiration'}, undef, "Correctly stored debarrment with no expiration" );
56
is( $debarments->[1]->{'expiration'}, undef, "Correctly stored debarrment with no expiration" );
57
is( $debarments->[1]->{'comment'}, 'Test 2', "Correctly stored 'comment'" );
57
is( $debarments->[1]->{'comment'}, 'Test 2', "Correctly stored 'comment'" );
58
58
59
59
60
ModDebarment({
60
Koha::Patron::Debarments::ModDebarment({
61
    borrower_debarment_id => $debarments->[1]->{'borrower_debarment_id'},
61
    borrower_debarment_id => $debarments->[1]->{'borrower_debarment_id'},
62
    comment => 'Test 3',
62
    comment => 'Test 3',
63
    expiration => '9998-06-10',
63
    expiration => '9998-06-10',
64
});
64
});
65
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
65
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
66
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
66
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
67
67
68
my $patron = Koha::Patrons->find( $borrowernumber )->unblessed;
68
my $patron = Koha::Patrons->find( $borrowernumber )->unblessed;
Lines 70-92 is( $patron->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly Link Here
70
is( $patron->{'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
Koha::Patron::Debarments::AddUniqueDebarment({
74
    borrowernumber => $borrowernumber,
74
    borrowernumber => $borrowernumber,
75
    type           => 'OVERDUES'
75
    type           => 'OVERDUES'
76
});
76
});
77
$debarments = GetDebarments({
77
$debarments = Koha::Patron::Debarments::GetDebarments({
78
    borrowernumber => $borrowernumber,
78
    borrowernumber => $borrowernumber,
79
    type => 'OVERDUES',
79
    type => 'OVERDUES',
80
});
80
});
81
is( @$debarments, 1, "GetDebarments returns 1 OVERDUES debarment" );
81
is( @$debarments, 1, "GetDebarments returns 1 OVERDUES debarment" );
82
is( $debarments->[0]->{'type'}, 'OVERDUES', "AddOverduesDebarment created new debarment correctly" );
82
is( $debarments->[0]->{'type'}, 'OVERDUES', "AddOverduesDebarment created new debarment correctly" );
83
83
84
AddUniqueDebarment({
84
Koha::Patron::Debarments::AddUniqueDebarment({
85
    borrowernumber => $borrowernumber,
85
    borrowernumber => $borrowernumber,
86
    expiration => '9999-11-09',
86
    expiration => '9999-11-09',
87
    type => 'OVERDUES'
87
    type => 'OVERDUES'
88
});
88
});
89
$debarments = GetDebarments({
89
$debarments = Koha::Patron::Debarments::GetDebarments({
90
    borrowernumber => $borrowernumber,
90
    borrowernumber => $borrowernumber,
91
    type => 'OVERDUES',
91
    type => 'OVERDUES',
92
});
92
});
Lines 94-156 is( @$debarments, 1, "GetDebarments returns 1 OVERDUES debarment after running A Link Here
94
is( $debarments->[0]->{'expiration'}, '9999-11-09', "AddOverduesDebarment updated OVERDUES debarment correctly" );
94
is( $debarments->[0]->{'expiration'}, '9999-11-09', "AddOverduesDebarment updated OVERDUES debarment correctly" );
95
95
96
96
97
my $delUniqueDebarment = DelUniqueDebarment({
97
my $delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
98
});
98
});
99
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' returns undef" );
99
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' returns undef" );
100
$debarments = GetDebarments({
100
$debarments = Koha::Patron::Debarments::GetDebarments({
101
    borrowernumber => $borrowernumber,
101
    borrowernumber => $borrowernumber,
102
    type => 'OVERDUES',
102
    type => 'OVERDUES',
103
});
103
});
104
is( @$debarments, 1, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' does not delete the debarment" );
104
is( @$debarments, 1, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' does not delete the debarment" );
105
105
106
$delUniqueDebarment = DelUniqueDebarment({
106
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
107
    borrowernumber => $borrowernumber,
107
    borrowernumber => $borrowernumber,
108
});
108
});
109
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'type' returns undef" );
109
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'type' returns undef" );
110
$debarments = GetDebarments({
110
$debarments = Koha::Patron::Debarments::GetDebarments({
111
    borrowernumber => $borrowernumber,
111
    borrowernumber => $borrowernumber,
112
    type => 'OVERDUES',
112
    type => 'OVERDUES',
113
});
113
});
114
is( @$debarments, 1, "DelUniqueDebarment without the argument 'type' does not delete the debarment" );
114
is( @$debarments, 1, "DelUniqueDebarment without the argument 'type' does not delete the debarment" );
115
115
116
$delUniqueDebarment = DelUniqueDebarment({
116
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
117
    type => 'OVERDUES'
117
    type => 'OVERDUES'
118
});
118
});
119
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'borrowernumber' returns undef" );
119
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'borrowernumber' returns undef" );
120
$debarments = GetDebarments({
120
$debarments = Koha::Patron::Debarments::GetDebarments({
121
    borrowernumber => $borrowernumber,
121
    borrowernumber => $borrowernumber,
122
    type => 'OVERDUES',
122
    type => 'OVERDUES',
123
});
123
});
124
is( @$debarments, 1, "DelUniqueDebarment without the argument 'borrowerumber' does not delete the debarment" );
124
is( @$debarments, 1, "DelUniqueDebarment without the argument 'borrowerumber' does not delete the debarment" );
125
125
126
$delUniqueDebarment = DelUniqueDebarment({
126
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
127
    borrowernumber => $borrowernumber,
127
    borrowernumber => $borrowernumber,
128
    type => 'SUSPENSION',
128
    type => 'SUSPENSION',
129
});
129
});
130
is( $delUniqueDebarment, undef, "DelUniqueDebarment with wrong arguments returns undef" );
130
is( $delUniqueDebarment, undef, "DelUniqueDebarment with wrong arguments returns undef" );
131
$debarments = GetDebarments({
131
$debarments = Koha::Patron::Debarments::GetDebarments({
132
    borrowernumber => $borrowernumber,
132
    borrowernumber => $borrowernumber,
133
    type => 'OVERDUES',
133
    type => 'OVERDUES',
134
});
134
});
135
is( @$debarments, 1, "DelUniqueDebarment with wrong arguments does not delete the debarment" );
135
is( @$debarments, 1, "DelUniqueDebarment with wrong arguments does not delete the debarment" );
136
136
137
$delUniqueDebarment = DelUniqueDebarment({
137
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
138
    borrowernumber => $borrowernumber,
138
    borrowernumber => $borrowernumber,
139
    type => 'OVERDUES',
139
    type => 'OVERDUES',
140
});
140
});
141
is( $delUniqueDebarment, 1, "DelUniqueDebarment returns 1" );
141
is( $delUniqueDebarment, 1, "DelUniqueDebarment returns 1" );
142
$debarments = GetDebarments({
142
$debarments = Koha::Patron::Debarments::GetDebarments({
143
    borrowernumber => $borrowernumber,
143
    borrowernumber => $borrowernumber,
144
    type => 'OVERDUES',
144
    type => 'OVERDUES',
145
});
145
});
146
is( @$debarments, 0, "DelUniqueDebarment functions correctly" );
146
is( @$debarments, 0, "DelUniqueDebarment functions correctly" );
147
147
148
148
149
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
149
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
150
foreach my $d ( @$debarments ) {
150
foreach my $d ( @$debarments ) {
151
    DelDebarment( $d->{'borrower_debarment_id'} );
151
    Koha::Patron::Debarments::DelDebarment( $d->{'borrower_debarment_id'} );
152
}
152
}
153
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
153
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
154
is( @$debarments, 0, "DelDebarment functions correctly" );
154
is( @$debarments, 0, "DelDebarment functions correctly" );
155
155
156
$dbh->do(q|UPDATE borrowers SET debarred = '1970-01-01'|);
156
$dbh->do(q|UPDATE borrowers SET debarred = '1970-01-01'|);
Lines 173-179 my $borrowernumber2 = Koha::Patron->new( Link Here
173
)->store->borrowernumber;
173
)->store->borrowernumber;
174
my $debarreddate2    = '9999-06-10'; # Be sure to be in the future
174
my $debarreddate2    = '9999-06-10'; # Be sure to be in the future
175
my $debarredcomment2 = 'Test merge';
175
my $debarredcomment2 = 'Test merge';
176
AddDebarment(
176
Koha::Patron::Debarments::AddDebarment(
177
    {
177
    {
178
        borrowernumber => $borrowernumber2,
178
        borrowernumber => $borrowernumber2,
179
        expiration     => $debarreddate2,
179
        expiration     => $debarreddate2,
(-)a/t/db_dependent/api/v1/patrons.t (-2 / +1 lines)
Lines 32-38 use Koha::DateUtils qw(dt_from_string output_pref); Link Here
32
use Koha::Exceptions::Patron;
32
use Koha::Exceptions::Patron;
33
use Koha::Exceptions::Patron::Attribute;
33
use Koha::Exceptions::Patron::Attribute;
34
use Koha::Patron::Attributes;
34
use Koha::Patron::Attributes;
35
use Koha::Patron::Debarments qw/AddDebarment/;
35
use Koha::Patron::Debarments qw( AddDebarment );
36
36
37
use JSON qw(encode_json);
37
use JSON qw(encode_json);
38
38
39
- 

Return to bug 29395