Bug 33105: Add Koha object classes

Signed-off-by: Jonathan Field <jonathan.fieeld@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-04-11 23:01:02 +02:00 committed by Tomas Cohen Arazi
parent 1a135e5e8c
commit 56cdee5037
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
3 changed files with 138 additions and 0 deletions

View file

@ -20,6 +20,7 @@ use Modern::Perl;
use Koha::Acquisition::Bookseller::Aliases;
use Koha::Acquisition::Bookseller::Contacts;
use Koha::Acquisition::Bookseller::Interfaces;
use Koha::Acquisition::Bookseller::Issues;
use Koha::Subscriptions;
use base qw( Koha::Object );
@ -137,6 +138,17 @@ sub interfaces {
return Koha::Acquisition::Bookseller::Interfaces->_new_from_dbic( $rs );
}
=head3 issues
my $issues = $vendor->issues
=cut
sub issues {
my ($self) = @_;
my $rs = $self->_result->aqbookseller_issues;
return Koha::Acquisition::Bookseller::Issues->_new_from_dbic( $rs );
}
=head3 to_api_mapping

View file

@ -0,0 +1,77 @@
package Koha::Acquisition::Bookseller::Issue;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use base qw(Koha::Object);
=head1 NAME
Koha::Acquisition::Bookseller::Issue - Koha Issue Object class
=head1 API
=head2 Class methods
=head3 strings_map
=cut
sub strings_map {
my ( $self, $params ) = @_;
my $strings = {};
if ( defined $self->type ) {
my $type_av_category = 'VENDOR_ISSUE_TYPE';
my $av = Koha::AuthorisedValues->search(
{
category => $type_av_category,
authorised_value => $self->type,
}
);
my $type_str = $av->count
? $params->{public}
? $av->next->opac_description
: $av->next->lib
: $self->type;
$strings->{type} = {
category => 'VENDOR_ISSUE_TYPE',
str => $type_str,
type => 'av',
};
}
return $strings;
}
=head2 Internal methods
=head3 _type
=cut
sub _type {
return 'AqbooksellerIssue';
}
1;

View file

@ -0,0 +1,49 @@
package Koha::Acquisition::Bookseller::Issues;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use Koha::Acquisition::Bookseller::Issue;
use base qw(Koha::Objects);
=head1 NAME
Koha::Acquisition::Bookseller::Issues
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'AqbooksellerIssue';
}
sub object_class {
return 'Koha::Acquisition::Bookseller::Issue';
}
1;