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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 3193-3199 sub AddRenewal { Link Here
3193
        my $renewal = Koha::Checkouts::Renewal->new(
3193
        my $renewal = Koha::Checkouts::Renewal->new(
3194
            {
3194
            {
3195
                checkout_id => $issue->issue_id,
3195
                checkout_id => $issue->issue_id,
3196
                renewer_id  => C4::Context->userenv->{'number'},
3196
                renewer_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
3197
                seen        => $seen,
3197
                seen        => $seen,
3198
                interface   => C4::Context->interface
3198
                interface   => C4::Context->interface
3199
            }
3199
            }
(-)a/Koha/Checkouts/Renewal.pm (-6 / +1 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use base qw(Koha::Object);
22
use base qw(Koha::Object);
23
23
24
use Koha::Checkouts;
24
use Koha::Checkouts;
25
use Koha::Exceptions::Checkouts::Renewals;
26
use Koha::Exceptions::Object;
25
use Koha::Exceptions::Object;
27
use Koha::Old::Checkouts;
26
use Koha::Old::Checkouts;
28
use Koha::Patrons;
27
use Koha::Patrons;
Lines 39-45 Koha::Checkouts::Renewal - Koha Renewal object class Link Here
39
38
40
=head3 store
39
=head3 store
41
40
42
    my $return_claim = Koha::Checkout::Renewal->new($args)->store;
41
    my $renewal = Koha::Checkout::Renewal->new($args)->store;
43
42
44
Overloaded I<store> method that validates the attributes and raises relevant
43
Overloaded I<store> method that validates the attributes and raises relevant
45
exceptions as needed.
44
exceptions as needed.
Lines 49-58 exceptions as needed. Link Here
49
sub store {
48
sub store {
50
    my ( $self ) = @_;
49
    my ( $self ) = @_;
51
50
52
    unless ( $self->in_storage || $self->renewer_id ) {
53
        Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw();
54
    }
55
56
    unless ( !$self->checkout_id
51
    unless ( !$self->checkout_id
57
        || Koha::Checkouts->find( $self->checkout_id )
52
        || Koha::Checkouts->find( $self->checkout_id )
58
        || Koha::Old::Checkouts->find( $self->checkout_id ) )
53
        || Koha::Old::Checkouts->find( $self->checkout_id ) )
(-)a/Koha/Exceptions/Checkouts/Renewals.pm (-49 lines)
Lines 1-49 Link Here
1
package Koha::Exceptions::Checkouts::Renewals;
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 Koha::Exception;
21
22
use Exception::Class (
23
    'Koha::Exceptions::Checkouts::Renewals' => {
24
        isa         => 'Koha::Exception',
25
    },
26
    'Koha::Exceptions::Checkouts::Renewals::NoRenewerID' => {
27
        isa         => 'Koha::Exceptions::Checkouts::Renewals',
28
        description => 'renewer_id is mandatory'
29
    },
30
);
31
32
=head1 NAME
33
34
Koha::Exceptions::Checkouts - Base class for Checkouts exceptions
35
36
=head1 Exceptions
37
38
=head2 Koha::Exceptions::Checkouts::Renewals
39
40
Generic return claim exception
41
42
=head2 Koha::Exceptions::Checkouts::Renewals::NoRenewerID
43
44
Exception to be used when a renewal is requested to be store but
45
the 'renewer_id' param is not passed.
46
47
=cut
48
49
1;
(-)a/t/db_dependent/Circulation.t (-20 / +32 lines)
Lines 55-63 use Koha::Account::Offsets; Link Here
55
use Koha::ActionLogs;
55
use Koha::ActionLogs;
56
use Koha::Notice::Messages;
56
use Koha::Notice::Messages;
57
57
58
my $builder = t::lib::TestBuilder->new;
58
sub set_userenv {
59
sub set_userenv {
59
    my ( $library ) = @_;
60
    my ( $library ) = @_;
60
    t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
61
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
62
    t::lib::Mocks::mock_userenv({ patron => $staff, branchcode => $library->{branchcode} });
61
}
63
}
62
64
63
sub str {
65
sub str {
Lines 104-110 sub test_debarment_on_checkout { Link Here
104
106
105
my $schema = Koha::Database->schema;
107
my $schema = Koha::Database->schema;
106
$schema->storage->txn_begin;
108
$schema->storage->txn_begin;
107
my $builder = t::lib::TestBuilder->new;
108
my $dbh = C4::Context->dbh;
109
my $dbh = C4::Context->dbh;
109
110
110
# Prevent random failures by mocking ->now
111
# Prevent random failures by mocking ->now
Lines 711-716 subtest "CanBookBeRenewed tests" => sub { Link Here
711
    # Make sure fine calculation isn't skipped when adding renewal
712
    # Make sure fine calculation isn't skipped when adding renewal
712
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
713
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
713
714
715
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
716
    t::lib::Mocks::mock_userenv({ patron => $staff });
717
714
    t::lib::Mocks::mock_preference('RenewalLog', 0);
718
    t::lib::Mocks::mock_preference('RenewalLog', 0);
715
    my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
719
    my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
716
    my %params_renewal = (
720
    my %params_renewal = (
Lines 3891-3916 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
3891
        }
3895
        }
3892
    });
3896
    });
3893
    my $future = dt_from_string->add( days => 1 );
3897
    my $future = dt_from_string->add( days => 1 );
3894
    my $deny_issue = $builder->build_object({ class => 'Koha::Checkouts', value => {
3898
    my $deny_issue = $builder->build_object(
3895
        returndate => undef,
3899
        {
3896
        renewals => 0,
3900
            class => 'Koha::Checkouts',
3897
        auto_renew => 0,
3901
            value => {
3898
        borrowernumber => $idr_borrower->borrowernumber,
3902
                returndate      => undef,
3899
        itemnumber => $deny_book->itemnumber,
3903
                renewals_count  => 0,
3900
        onsite_checkout => 0,
3904
                auto_renew      => 0,
3901
        date_due => $future,
3905
                borrowernumber  => $idr_borrower->borrowernumber,
3906
                itemnumber      => $deny_book->itemnumber,
3907
                onsite_checkout => 0,
3908
                date_due        => $future,
3909
            }
3902
        }
3910
        }
3903
    });
3911
    );
3904
    my $allow_issue = $builder->build_object({ class => 'Koha::Checkouts', value => {
3912
    my $allow_issue = $builder->build_object(
3905
        returndate => undef,
3913
        {
3906
        renewals => 0,
3914
            class => 'Koha::Checkouts',
3907
        auto_renew => 0,
3915
            value => {
3908
        borrowernumber => $idr_borrower->borrowernumber,
3916
                returndate      => undef,
3909
        itemnumber => $allow_book->itemnumber,
3917
                renewals_count  => 0,
3910
        onsite_checkout => 0,
3918
                auto_renew      => 0,
3911
        date_due => $future,
3919
                borrowernumber  => $idr_borrower->borrowernumber,
3920
                itemnumber      => $allow_book->itemnumber,
3921
                onsite_checkout => 0,
3922
                date_due        => $future,
3923
            }
3912
        }
3924
        }
3913
    });
3925
    );
3914
3926
3915
    my $idr_rules;
3927
    my $idr_rules;
3916
3928
(-)a/t/db_dependent/Koha/Account/Line.t (-3 / +2 lines)
Lines 509-515 subtest 'Renewal related tests' => sub { Link Here
509
            value => {
509
            value => {
510
                itemnumber      => $item->itemnumber,
510
                itemnumber      => $item->itemnumber,
511
                onsite_checkout => 0,
511
                onsite_checkout => 0,
512
                renewals        => 99,
512
                renewals_count  => 99,
513
                auto_renew      => 0
513
                auto_renew      => 0
514
            }
514
            }
515
        }
515
        }
Lines 558-564 subtest 'Renewal related tests' => sub { Link Here
558
            value => {
558
            value => {
559
                itemnumber      => $item->itemnumber,
559
                itemnumber      => $item->itemnumber,
560
                onsite_checkout => 0,
560
                onsite_checkout => 0,
561
                renewals        => 0,
561
                renewals_count  => 0,
562
                auto_renew      => 0
562
                auto_renew      => 0
563
            }
563
            }
564
        }
564
        }
565
- 

Return to bug 30275