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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 3221-3227 sub AddRenewal { Link Here
3221
        my $renewal = Koha::Checkouts::Renewal->new(
3221
        my $renewal = Koha::Checkouts::Renewal->new(
3222
            {
3222
            {
3223
                checkout_id => $issue->issue_id,
3223
                checkout_id => $issue->issue_id,
3224
                renewer_id  => C4::Context->userenv->{'number'},
3224
                renewer_id  => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
3225
                seen        => $seen,
3225
                seen        => $seen,
3226
                interface   => C4::Context->interface
3226
                interface   => C4::Context->interface
3227
            }
3227
            }
(-)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 && $self->in_storage )
51
    unless ( ( !$self->checkout_id && $self->in_storage )
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 56-64 use Koha::ActionLogs; Link Here
56
use Koha::Notice::Messages;
56
use Koha::Notice::Messages;
57
use Koha::Cache::Memory::Lite;
57
use Koha::Cache::Memory::Lite;
58
58
59
my $builder = t::lib::TestBuilder->new;
59
sub set_userenv {
60
sub set_userenv {
60
    my ( $library ) = @_;
61
    my ( $library ) = @_;
61
    t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
62
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
63
    t::lib::Mocks::mock_userenv({ patron => $staff, branchcode => $library->{branchcode} });
62
}
64
}
63
65
64
sub str {
66
sub str {
Lines 105-111 sub test_debarment_on_checkout { Link Here
105
107
106
my $schema = Koha::Database->schema;
108
my $schema = Koha::Database->schema;
107
$schema->storage->txn_begin;
109
$schema->storage->txn_begin;
108
my $builder = t::lib::TestBuilder->new;
109
my $dbh = C4::Context->dbh;
110
my $dbh = C4::Context->dbh;
110
111
111
# Prevent random failures by mocking ->now
112
# Prevent random failures by mocking ->now
Lines 712-717 subtest "CanBookBeRenewed tests" => sub { Link Here
712
    # Make sure fine calculation isn't skipped when adding renewal
713
    # Make sure fine calculation isn't skipped when adding renewal
713
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
714
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
714
715
716
    my $staff = $builder->build_object({ class => "Koha::Patrons" });
717
    t::lib::Mocks::mock_userenv({ patron => $staff });
718
715
    t::lib::Mocks::mock_preference('RenewalLog', 0);
719
    t::lib::Mocks::mock_preference('RenewalLog', 0);
716
    my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
720
    my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
717
    my %params_renewal = (
721
    my %params_renewal = (
Lines 3940-3965 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
3940
        }
3944
        }
3941
    });
3945
    });
3942
    my $future = dt_from_string->add( days => 1 );
3946
    my $future = dt_from_string->add( days => 1 );
3943
    my $deny_issue = $builder->build_object({ class => 'Koha::Checkouts', value => {
3947
    my $deny_issue = $builder->build_object(
3944
        returndate => undef,
3948
        {
3945
        renewals => 0,
3949
            class => 'Koha::Checkouts',
3946
        auto_renew => 0,
3950
            value => {
3947
        borrowernumber => $idr_borrower->borrowernumber,
3951
                returndate      => undef,
3948
        itemnumber => $deny_book->itemnumber,
3952
                renewals_count  => 0,
3949
        onsite_checkout => 0,
3953
                auto_renew      => 0,
3950
        date_due => $future,
3954
                borrowernumber  => $idr_borrower->borrowernumber,
3955
                itemnumber      => $deny_book->itemnumber,
3956
                onsite_checkout => 0,
3957
                date_due        => $future,
3958
            }
3951
        }
3959
        }
3952
    });
3960
    );
3953
    my $allow_issue = $builder->build_object({ class => 'Koha::Checkouts', value => {
3961
    my $allow_issue = $builder->build_object(
3954
        returndate => undef,
3962
        {
3955
        renewals => 0,
3963
            class => 'Koha::Checkouts',
3956
        auto_renew => 0,
3964
            value => {
3957
        borrowernumber => $idr_borrower->borrowernumber,
3965
                returndate      => undef,
3958
        itemnumber => $allow_book->itemnumber,
3966
                renewals_count  => 0,
3959
        onsite_checkout => 0,
3967
                auto_renew      => 0,
3960
        date_due => $future,
3968
                borrowernumber  => $idr_borrower->borrowernumber,
3969
                itemnumber      => $allow_book->itemnumber,
3970
                onsite_checkout => 0,
3971
                date_due        => $future,
3972
            }
3961
        }
3973
        }
3962
    });
3974
    );
3963
3975
3964
    my $idr_rules;
3976
    my $idr_rules;
3965
3977
(-)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