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

(-)a/Koha/Patron.pm (-3 / +3 lines)
Lines 170-184 sub do_check_for_previous_checkout { Link Here
170
    return $old_issues->count;  # 0 || N
170
    return $old_issues->count;  # 0 || N
171
}
171
}
172
172
173
=head3 extend_subscription
173
=head3 renew_account
174
174
175
my $new_expiry_date = $patron->extend_subscription
175
my $new_expiry_date = $patron->renew_account
176
176
177
Extending the subscription to the expiry date.
177
Extending the subscription to the expiry date.
178
178
179
=cut
179
=cut
180
180
181
sub extend_subscription {
181
sub renew_account {
182
    my ($self) = @_;
182
    my ($self) = @_;
183
183
184
    my $date =
184
    my $date =
(-)a/members/setstatus.pl (-1 / +1 lines)
Lines 47-53 my $dateexpiry; Link Here
47
47
48
if ( $reregistration eq 'y' ) {
48
if ( $reregistration eq 'y' ) {
49
    # re-reregistration function to automatic calcul of date expiry
49
    # re-reregistration function to automatic calcul of date expiry
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->extend_subscription;
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->renew_account;
51
} else {
51
} else {
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
53
    $sth->execute( $status, $borrowernumber );
53
    $sth->execute( $status, $borrowernumber );
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 103-109 subtest 'siblings' => sub { Link Here
103
    $retrieved_guarantee_1->delete;
103
    $retrieved_guarantee_1->delete;
104
};
104
};
105
105
106
subtest 'extend_subscription' => sub {
106
subtest 'renew_account' => sub {
107
    plan tests => 6;
107
    plan tests => 6;
108
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
108
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
109
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
109
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
Lines 128-148 subtest 'extend_subscription' => sub { Link Here
128
128
129
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
129
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
130
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
130
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
131
    my $expiry_date = $retrieved_patron->extend_subscription;
131
    my $expiry_date = $retrieved_patron->renew_account;
132
    is( $expiry_date, $a_year_later_minus_a_month, );
132
    is( $expiry_date, $a_year_later_minus_a_month, );
133
    my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
133
    my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
134
    is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month );
134
    is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month );
135
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
135
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
136
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->extend_subscription should have logged' );
136
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' );
137
137
138
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
138
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
139
    t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
139
    t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
140
    $expiry_date = $retrieved_patron->extend_subscription;
140
    $expiry_date = $retrieved_patron->renew_account;
141
    is( $expiry_date, $a_year_later, );
141
    is( $expiry_date, $a_year_later, );
142
    $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
142
    $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
143
    is( dt_from_string($retrieved_expiry_date), $a_year_later );
143
    is( dt_from_string($retrieved_expiry_date), $a_year_later );
144
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
144
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
145
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->extend_subscription should not have logged' );
145
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
146
146
147
    $retrieved_patron->delete;
147
    $retrieved_patron->delete;
148
};
148
};
149
- 

Return to bug 16911