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

(-)a/Koha/Checkout.pm (+13 lines)
Lines 41-46 Koha::Checkout - Koha Checkout object class Link Here
41
41
42
=cut
42
=cut
43
43
44
=head3 is_onsite_checkout
45
46
my is_onsite_checkout = $checkout->is_onsite_checkout();
47
48
Return 1 if the checkout is an on-site checkout.
49
50
=cut
51
52
sub is_onsite_checkout {
53
    my ( $self ) = @_;
54
    return $self->checkout_type eq $Koha::Checkouts::type->{onsite_checkout};
55
}
56
44
=head3 is_overdue
57
=head3 is_overdue
45
58
46
my  $is_overdue = $checkout->is_overdue( [ $reference_dt ] );
59
my  $is_overdue = $checkout->is_overdue( [ $reference_dt ] );
(-)a/Koha/Checkouts.pm (+13 lines)
Lines 55-60 sub calculate_dropbox_date { Link Here
55
    return $dropbox_date;
55
    return $dropbox_date;
56
}
56
}
57
57
58
=cut
59
60
=head2 Name to code mappings
61
62
=head3 $type
63
64
=cut
65
66
our $type = {
67
    'checkout'        => 'C',
68
    'onsite_checkout' => 'OS',
69
};
70
58
=head3 type
71
=head3 type
59
72
60
=cut
73
=cut
(-)a/Koha/Template/Plugin/Checkouts.pm (+61 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Checkouts;
2
3
# Copyright 2020 Hypernova Oy
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 NAME
21
22
Koha::Template::Plugin::Checkouts
23
24
=head1 DESCRIPTION
25
26
The Checkouts plugin is a helper for using Koha::Checkouts in templates.
27
28
=head1 SYNOPSYS
29
30
    [% USE Checkouts %]
31
32
=cut
33
34
use Modern::Perl;
35
36
use Template::Plugin;
37
use base qw( Template::Plugin );
38
39
use C4::Koha;
40
use C4::Context;
41
use Koha::Checkouts;
42
43
=head1 FUNCTIONS
44
45
=head2 type
46
47
Returns $Koha::Checkouts::type HASHref.
48
49
Usage:
50
51
    [% IF (checkout_type == Checkouts.type.onsite_checkout %]
52
        ...
53
    [% END %]
54
55
=cut
56
57
sub type {
58
    return $Koha::Checkouts::type;
59
}
60
61
1;
(-)a/t/db_dependent/Koha/Checkouts.t (-1 / +20 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 9;
23
use Test::Exception;
23
24
24
use C4::Circulation;
25
use C4::Circulation;
25
use Koha::Checkouts;
26
use Koha::Checkouts;
Lines 56-61 is( Koha::Checkouts->search->count, $nb_of_checkouts + 2, 'The 2 checkouts shoul Link Here
56
my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id );
57
my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id );
57
is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' );
58
is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' );
58
59
60
subtest 'Koha::Checkouts checkout_codes' => sub {
61
    plan tests => 2;
62
    is( $Koha::Checkouts::type->{checkout}, 'C' );
63
    is( $Koha::Checkouts::type->{onsite_checkout}, 'OS' );
64
};
65
66
subtest 'is_onsite_checkout' => sub {
67
    plan tests => 2;
68
69
    my $old_checkout_type = $retrieved_checkout_1->checkout_type;
70
    $new_checkout_1->checkout_type($Koha::Checkouts::type->{checkout})->store;
71
    ok( !$new_checkout_1->is_onsite_checkout, 'It is not on-site checkout' );
72
    $new_checkout_1->checkout_type($Koha::Checkouts::type->{onsite_checkout})->store;
73
    is( $new_checkout_1->is_onsite_checkout,
74
        1, 'It is an on-site checkout' );
75
    $new_checkout_1->checkout_type($old_checkout_type)->store;
76
};
77
59
subtest 'is_overdue' => sub {
78
subtest 'is_overdue' => sub {
60
    plan tests => 6;
79
    plan tests => 6;
61
    my $ten_days_ago   = dt_from_string->add( days => -10 );
80
    my $ten_days_ago   = dt_from_string->add( days => -10 );
(-)a/t/db_dependent/Template/Plugin/Checkouts.t (-1 / +31 lines)
Line 0 Link Here
0
- 
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 => 1;
21
use t::lib::Mocks;
22
use t::lib::TestBuilder;
23
24
use Koha::Template::Plugin::Checkouts;
25
26
subtest 'type() tests' => sub {
27
    plan tests => 2;
28
29
    is( Koha::Template::Plugin::Checkouts->new->type->{checkout}, 'C' );
30
    is( Koha::Template::Plugin::Checkouts->new->type->{onsite_checkout}, 'OS' );
31
};

Return to bug 25037