From 0e23df9a056e5aedd5bf5fff27eb3babb26d9e2d Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Fri, 6 Dec 2019 06:59:45 -0500
Subject: [PATCH] Bug 24857: Add Object Methods

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Rebecca  Coert <rcoert@arlingtonva.us>
---
 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 be9561f583..794598159b 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 47a86eb0bb..80216dd341 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;
@@ -41,9 +43,9 @@ use Koha::Exceptions::Item::Transfer;
 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;
 
@@ -395,6 +397,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.30.1 (Apple Git-130)