Bug 20366: Add new method Koha::Acquisition::Basket->basket_group
Can be moved to a separate bug report. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
7b114c51eb
commit
c267716e6b
4 changed files with 137 additions and 2 deletions
|
@ -20,6 +20,7 @@ package Koha::Acquisition::Basket;
|
|||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Acquisition::BasketGroups;
|
||||
|
||||
use base qw( Koha::Object );
|
||||
|
||||
|
@ -45,6 +46,18 @@ sub bookseller {
|
|||
return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs );
|
||||
}
|
||||
|
||||
=head3 basket_group
|
||||
|
||||
Returns the basket group associated to this basket
|
||||
|
||||
=cut
|
||||
|
||||
sub basket_group {
|
||||
my ($self) = @_;
|
||||
my $basket_group_rs = $self->_result->basketgroupid;
|
||||
return unless $basket_group_rs;
|
||||
return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs );
|
||||
}
|
||||
|
||||
=head3 effective_create_items
|
||||
|
||||
|
|
44
Koha/Acquisition/BasketGroup.pm
Normal file
44
Koha/Acquisition/BasketGroup.pm
Normal file
|
@ -0,0 +1,44 @@
|
|||
package Koha::Acquisition::BasketGroup;
|
||||
|
||||
# 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
|
||||
use base qw( Koha::Object );
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Acquisition::BasketGroup - Koha Basket group Object class
|
||||
|
||||
=head1 API
|
||||
|
||||
=head2 Class Methods
|
||||
|
||||
=cut
|
||||
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
||||
sub _type {
|
||||
return 'Aqbasketgroup';
|
||||
}
|
||||
|
||||
1;
|
49
Koha/Acquisition/BasketGroups.pm
Normal file
49
Koha/Acquisition/BasketGroups.pm
Normal file
|
@ -0,0 +1,49 @@
|
|||
package Koha::Acquisition::BasketGroups;
|
||||
|
||||
# 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Acquisition::BasketGroup;
|
||||
|
||||
use base qw( Koha::Objects );
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Acquisition::BasketGroups - Koha Basket groups object set class
|
||||
|
||||
=head1 API
|
||||
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
||||
sub _type {
|
||||
return 'Aqbasketgroup';
|
||||
}
|
||||
|
||||
=head3 object_class
|
||||
|
||||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::Acquisition::BasketGroup';
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2017 Koha Development team
|
||||
# Copyright 2018 Koha Development team
|
||||
#
|
||||
# This file is part of Koha
|
||||
#
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 3;
|
||||
use Test::More tests => 4;
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
||||
|
@ -78,3 +78,32 @@ subtest 'create_items + effective_create_items tests' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'basket_group' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
my $b = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Acquisition::Baskets',
|
||||
value => { basketgroupid => undef }, # not linked to a basketgroupid
|
||||
}
|
||||
);
|
||||
|
||||
my $basket = Koha::Acquisition::Baskets->find( $b->basketno );
|
||||
is( $basket->basket_group, undef,
|
||||
'->basket_group should return undef if not linked to a basket group');
|
||||
|
||||
$b = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Acquisition::Baskets',
|
||||
# Will be linked to a basket group by TestBuilder
|
||||
}
|
||||
);
|
||||
|
||||
$basket = Koha::Acquisition::Baskets->find( $b->basketno );
|
||||
is( ref( $basket->basket_group ), 'Koha::Acquisition::BasketGroup',
|
||||
'->basket_group should return a Koha::Acquisition::BasketGroup object if linked to a basket group');
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue