1 package Koha::Acquisition::Bookseller;
3 # This file is part of Koha.
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.
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.
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>.
20 use Koha::Acquisition::Bookseller::Aliases;
21 use Koha::Acquisition::Bookseller::Contacts;
22 use Koha::Acquisition::Bookseller::Interfaces;
23 use Koha::Subscriptions;
25 use base qw( Koha::Object );
29 Koha::Acquisition::Bookseller Object class
37 my $vendor = Koha::Acquisition::Booksellers->find( $id );
38 my @baskets = $vendor->baskets();
40 Returns the list of baskets for the vendor
46 my $baskets_rs = $self->_result->aqbaskets;
47 return Koha::Acquisition::Baskets->_new_from_dbic( $baskets_rs );
52 my $vendor = Koha::Acquisition::Booksellers->find( $id );
53 my @contacts = $vendor->contacts();
55 Returns the list of contacts for the vendor
61 my $contacts_rs = $self->_result->aqcontacts;
62 return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic( $contacts_rs );
67 my $vendor = Koha::Acquisition::Booksellers->find( $id );
68 my $subscriptions = $vendor->subscriptions();
70 Returns the list of subscriptions for the vendor
77 # FIXME FK missing at DB level
78 return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
83 my $aliases = $vendor->aliases
85 $vendor->aliases([{ alias => 'one alias'}]);
90 my ($self, $aliases) = @_;
93 my $schema = $self->_result->result_source->schema;
96 $self->aliases->delete;
97 for my $alias (@$aliases) {
98 $self->_result->add_to_aqbookseller_aliases($alias);
104 my $rs = $self->_result->aqbookseller_aliases;
105 return Koha::Acquisition::Bookseller::Aliases->_new_from_dbic( $rs );
110 my $interfaces = $vendor->interfaces
112 $vendor->interfaces(\@interfaces);
117 my ($self, $interfaces) = @_;
120 my $schema = $self->_result->result_source->schema;
123 $self->interfaces->delete;
124 for my $interface (@$interfaces) {
125 Koha::Acquisition::Bookseller::Interface->new(
128 vendor_id => $self->id,
136 my $rs = $self->_result->aqbookseller_interfaces;
137 return Koha::Acquisition::Bookseller::Interfaces->_new_from_dbic( $rs );
141 =head3 to_api_mapping
143 This method returns the mapping for representing a Koha::Acquisition::Bookseller object
150 listprice => 'list_currency',
151 invoiceprice => 'invoice_currency',
153 listincgst => 'list_includes_gst',
154 invoiceincgst => 'invoice_includes_gst'
158 =head2 Internal methods
165 return 'Aqbookseller';