From 5e4b64ccbc3dac0903fef4513163f7071fe3c1db Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 6 Dec 2019 06:59:45 -0500 Subject: [PATCH] Bug 24857: Add Object Methods Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert --- Koha/Biblio.pm | 16 ++++++++++++++++ Koha/Item.pm | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 29c7d1edb4..ba2a2e7721 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -36,6 +36,7 @@ use Koha::Acquisition::Orders; use Koha::ArticleRequest::Status; use Koha::ArticleRequests; use Koha::Biblio::Metadatas; +use Koha::Biblio::Volumes; use Koha::Biblioitems; use Koha::CirculationRules; use Koha::Item::Transfer::Limits; @@ -114,6 +115,21 @@ sub active_orders { return $self->orders->search({ datecancellationprinted => undef }); } +=head3 volumes + +my $volumes = $biblio->volumes(); + +Returns a Koha::Biblio::Volumes object + +=cut + +sub volumes { + my ( $self ) = @_; + + my $volumes = $self->_result->volumes; + return Koha::Biblio::Volumes->_new_from_dbic($volumes); +} + =head3 can_article_request my $bool = $biblio->can_article_request( $borrower ); diff --git a/Koha/Item.pm b/Koha/Item.pm index bedf4d1856..380f8d7f6d 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -31,7 +31,9 @@ use C4::Context; use C4::Circulation; use C4::Reserves; use C4::ClassSource; # FIXME We would like to avoid that +use C4::Context; use C4::Log qw( logaction ); +use C4::Reserves; use Koha::Checkouts; use Koha::CirculationRules; @@ -40,9 +42,9 @@ use Koha::SearchEngine::Indexer; use Koha::Item::Transfer::Limits; use Koha::Item::Transfers; use Koha::ItemTypes; +use Koha::Libraries; use Koha::Patrons; use Koha::Plugins; -use Koha::Libraries; use Koha::StockRotationItem; use Koha::StockRotationRotas; @@ -385,6 +387,26 @@ sub checkout { return Koha::Checkout->_new_from_dbic( $checkout_rs ); } +=head3 volume + +my $volume = $item->volume; + +Return the volume for this item + +=cut + +sub volume { + my ( $self ) = @_; + + my $volume_item = $self->_result->volume_items->first; + return unless $volume_item; + + my $volume_rs = $volume_item->volume; + return unless $volume_rs; + + return Koha::Biblio::Volume->_new_from_dbic( $volume_rs ); +} + =head3 holds my $holds = $item->holds(); -- 2.24.1 (Apple Git-126)