Bug 26988: Add API route to fetch hold pickup locations and use it in the holds table
[koha.git] / Koha / Acquisition / Bookseller.pm
1 package Koha::Acquisition::Bookseller;
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::Acquisition::Bookseller::Contacts;
21 use Koha::Subscriptions;
22
23 use base qw( Koha::Object );
24
25 =head1 NAME
26
27 Koha::Acquisition::Bookseller Object class
28
29 =head1 API
30
31 =head2 Class methods
32
33 =head3 baskets
34
35     my $vendor  = Koha::Acquisition::Booksellers->find( $id );
36     my @baskets = $vendor->baskets();
37
38 Returns the list of baskets for the vendor
39
40 =cut
41
42 sub baskets {
43     my ( $self ) = @_;
44     my $baskets_rs = $self->_result->aqbaskets;
45     return Koha::Acquisition::Baskets->_new_from_dbic( $baskets_rs );
46 }
47
48 =head3 contacts
49
50     my $vendor   = Koha::Acquisition::Booksellers->find( $id );
51     my @contacts = $vendor->contacts();
52
53 Returns the list of contacts for the vendor
54
55 =cut
56
57 sub contacts {
58     my ($self) = @_;
59     my $contacts_rs = $self->_result->aqcontacts;
60     return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic( $contacts_rs );
61 }
62
63 =head3 subscriptions
64
65     my $vendor        = Koha::Acquisition::Booksellers->find( $id );
66     my @subscriptions = $vendor->subscriptions();
67
68 Returns the list of subscriptions for the vendor
69
70 =cut
71
72 sub subscriptions {
73     my ($self) = @_;
74
75     # FIXME FK missing at DB level
76     return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
77 }
78
79 =head3 to_api_mapping
80
81 This method returns the mapping for representing a Koha::Acquisition::Bookseller object
82 on the API.
83
84 =cut
85
86 sub to_api_mapping {
87     return {
88         listprice       => 'list_currency',
89         invoiceprice    => 'invoice_currency',
90         gstreg          => 'gst',
91         listincgst      => 'list_includes_gst',
92         invoiceincgst   => 'invoice_includes_gst'
93     };
94 }
95
96 =head2 Internal methods
97
98 =head3 _type
99
100 =cut
101
102 sub _type {
103     return 'Aqbookseller';
104 }
105
106 1;