From 211cf94da2fed9b0a67748611b3330c5ce9d386b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 20 Oct 2021 18:02:01 -0300 Subject: [PATCH] Bug 29288: Add current_checkouts and old_checkouts methods to Koha::Biblio This patch adds helper methods for accessing current and past checkouts for a given Koha::Biblio object. To test: 1. Apply the unit tests 2. Run: $ kshell k$ prove t/db_dependent/Koha/Biblio.t => FAIL: Methods are not implemented 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind --- Koha/Biblio.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index e3618dc80f..bf61d7ec16 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -35,10 +35,12 @@ use Koha::Acquisition::Orders; use Koha::ArticleRequests; use Koha::Biblio::Metadatas; use Koha::Biblioitems; +use Koha::Checkouts; use Koha::CirculationRules; use Koha::Item::Transfer::Limits; use Koha::Items; use Koha::Libraries; +use Koha::Old::Checkouts; use Koha::Suggestions; use Koha::Subscriptions; @@ -353,6 +355,36 @@ sub article_requests { return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); } +=head3 current_checkouts + + my $current_checkouts = $biblio->current_checkouts + +Returns the current checkouts associated with this biblio + +=cut + +sub current_checkouts { + my ($self) = @_; + + return Koha::Checkouts->search( { "item.biblionumber" => $self->id }, + { join => 'item' } ); +} + +=head3 old_checkouts + + my $old_checkouts = $biblio->old_checkouts + +Returns the past checkouts associated with this biblio + +=cut + +sub old_checkouts { + my ( $self ) = @_; + + return Koha::Old::Checkouts->search( { "item.biblionumber" => $self->id }, + { join => 'item' } ); +} + =head3 items my $items = $biblio->items(); -- 2.20.1