Bug 21983: Add Koha::Biblio->ill_requests
This patch adds a new method, used for retrieving the linked ill requests for a biblio. To test: 1. Apply this patch and run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
f6a7d96e1e
commit
a9759b3b0e
3 changed files with 50 additions and 1 deletions
|
@ -39,6 +39,7 @@ use Koha::Cache::Memory::Lite;
|
||||||
use Koha::Checkouts;
|
use Koha::Checkouts;
|
||||||
use Koha::CirculationRules;
|
use Koha::CirculationRules;
|
||||||
use Koha::Exceptions;
|
use Koha::Exceptions;
|
||||||
|
use Koha::Illrequests;
|
||||||
use Koha::Item::Transfer::Limits;
|
use Koha::Item::Transfer::Limits;
|
||||||
use Koha::Items;
|
use Koha::Items;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
|
@ -164,6 +165,21 @@ sub tickets {
|
||||||
return Koha::Tickets->_new_from_dbic( $rs );
|
return Koha::Tickets->_new_from_dbic( $rs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head3 ill_requests
|
||||||
|
|
||||||
|
my $ill_requests = $biblio->ill_requests();
|
||||||
|
|
||||||
|
Returns a Koha::Illrequests object
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub ill_requests {
|
||||||
|
my ( $self ) = @_;
|
||||||
|
|
||||||
|
my $ill_requests = $self->_result->ill_requests;
|
||||||
|
return Koha::Illrequests->_new_from_dbic($ill_requests);
|
||||||
|
}
|
||||||
|
|
||||||
=head3 item_groups
|
=head3 item_groups
|
||||||
|
|
||||||
my $item_groups = $biblio->item_groups();
|
my $item_groups = $biblio->item_groups();
|
||||||
|
|
|
@ -611,6 +611,13 @@ __PACKAGE__->has_many(
|
||||||
{ cascade_copy => 0, cascade_delete => 0 },
|
{ cascade_copy => 0, cascade_delete => 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
__PACKAGE__->has_many(
|
||||||
|
"ill_requests",
|
||||||
|
"Koha::Schema::Result::Illrequest",
|
||||||
|
{ "foreign.biblio_id" => "self.biblionumber" },
|
||||||
|
{ cascade_copy => 0, cascade_delete => 0 },
|
||||||
|
);
|
||||||
|
|
||||||
__PACKAGE__->has_one(
|
__PACKAGE__->has_one(
|
||||||
"metadata",
|
"metadata",
|
||||||
"Koha::Schema::Result::BiblioMetadata",
|
"Koha::Schema::Result::BiblioMetadata",
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
use Test::More tests => 23; # +1
|
use Test::More tests => 24;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
use Test::Warn;
|
use Test::Warn;
|
||||||
|
|
||||||
|
@ -1061,6 +1061,32 @@ subtest 'Recalls tests' => sub {
|
||||||
$schema->storage->txn_rollback;
|
$schema->storage->txn_rollback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
subtest 'ill_requests() tests' => sub {
|
||||||
|
|
||||||
|
plan tests => 3;
|
||||||
|
|
||||||
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
|
my $biblio = $builder->build_sample_biblio;
|
||||||
|
|
||||||
|
my $rs = $biblio->ill_requests;
|
||||||
|
is( ref($rs), 'Koha::Illrequests' );
|
||||||
|
is( $rs->count, 0, 'No linked requests' );
|
||||||
|
|
||||||
|
foreach ( 1..10 ) {
|
||||||
|
$builder->build_object(
|
||||||
|
{
|
||||||
|
class => 'Koha::Illrequests',
|
||||||
|
value => { biblio_id => $biblio->id }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
is( $biblio->ill_requests->count, 10, 'Linked requests are present' );
|
||||||
|
|
||||||
|
$schema->storage->txn_rollback;
|
||||||
|
};
|
||||||
|
|
||||||
subtest 'item_groups() tests' => sub {
|
subtest 'item_groups() tests' => sub {
|
||||||
|
|
||||||
plan tests => 6;
|
plan tests => 6;
|
||||||
|
|
Loading…
Reference in a new issue