From f0d26e1b232f1984d9ca30e5e245781704bdb0f2 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 --- Koha/Biblio.pm | 16 ++++++++++++++++ Koha/Item.pm | 29 +++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 4fe30113e3..f74af8ae7c 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 567a294911..fa1ac262e1 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -27,20 +27,21 @@ use Try::Tiny; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); -use C4::Context; -use C4::Circulation; -use C4::Reserves; use C4::Biblio qw( ModZebra ); # FIXME This is terrible, we should move the indexation code outside of C4::Biblio +use C4::Circulation; use C4::ClassSource; # FIXME We would like to avoid that +use C4::Context; use C4::Log qw( logaction ); +use C4::Reserves; +use Koha::Biblio::Volumes; use Koha::Checkouts; use Koha::CirculationRules; use Koha::Item::Transfer::Limits; use Koha::Item::Transfers; +use Koha::Libraries; use Koha::Patrons; use Koha::Plugins; -use Koha::Libraries; use Koha::StockRotationItem; use Koha::StockRotationRotas; @@ -339,6 +340,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.21.1 (Apple Git-122.3)