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

(-)a/Koha/Subscription.pm (+15 lines)
Lines 24-29 use Carp; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Biblios;
25
use Koha::Biblios;
26
use Koha::Acquisition::Booksellers;
26
use Koha::Acquisition::Booksellers;
27
use Koha::Subscription::Frequencies;
27
28
28
use base qw(Koha::Object);
29
use base qw(Koha::Object);
29
30
Lines 106-111 sub remove_subscriber { Link Here
106
    $subscriber->delete if $subscriber;
107
    $subscriber->delete if $subscriber;
107
}
108
}
108
109
110
=head3 frequency
111
112
my $frequency = $subscription->frequency
113
114
Return the subscription frequency
115
116
=cut
117
118
sub frequency {
119
    my($self)=@_;
120
    my $frequency_rs= $self->_result->periodicity;
121
    return Koha::Subscription::Frequency->_new_from_dbic($frequency_rs);
122
}
123
109
=head3 type
124
=head3 type
110
125
111
=cut
126
=cut
(-)a/Koha/Subscription/Frequencies.pm (+50 lines)
Line 0 Link Here
1
package Koha::Subscription::Frequencies;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::Subscription::Frequency;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::Subscription::Frequencies - Koha Subscription Frequency Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'SubscriptionFrequency';
44
}
45
46
sub object_class {
47
    return 'Koha::Subscription::Frequency';
48
}
49
50
1;
(-)a/Koha/Subscription/Frequency.pm (+44 lines)
Line 0 Link Here
1
package Koha::Subscription::Frequency;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Subscription::Frequency - Koha Subscription Frequency Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'SubscriptionFrequency';
42
}
43
44
1;
(-)a/t/db_dependent/Koha/Subscription.t (-2 / +14 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use Koha::Subscriptions;
24
use Koha::Subscriptions;
25
use Koha::Biblio;
25
use Koha::Biblio;
Lines 88-93 subtest 'Koha::Subscription->vendor' => sub { Link Here
88
    is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' );
88
    is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' );
89
};
89
};
90
90
91
subtest 'Koha::Subscription->frequency' => sub {
92
    plan tests => 2;
93
    my $frequency = $builder->build_object( { class => 'Koha::Subscription::Frequencies' } );
94
    my $subscription = $builder->build_object(
95
        {
96
            class  => 'Koha::Subscriptions',
97
            value  => { periodicity => $frequency->id }
98
        }
99
    );
100
    is( ref($subscription->frequency), 'Koha::Subscription::Frequency', 'Koha::Subscription->frequency should return a Koha::Subscription::Frequency' );
101
    is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' );
102
};
103
91
$schema->storage->txn_rollback;
104
$schema->storage->txn_rollback;
92
105
93
1;
106
1;
94
- 

Return to bug 21474