Bugzilla – Attachment 97415 Details for
Bug 24430
Remove C4::Biblio::CountBiblioInOrders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24430: Add ->orders and ->orders_count to Koha::Biblio
Bug-24430-Add--orders-and--orderscount-to-KohaBibl.patch (text/plain), 2.28 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-01-15 19:30:15 UTC
(
hide
)
Description:
Bug 24430: Add ->orders and ->orders_count to Koha::Biblio
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-01-15 19:30:15 UTC
Size:
2.28 KB
patch
obsolete
>From 4662ae7052d1068638eaddc2661fc02144a365c6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 15 Jan 2020 16:25:52 -0300 >Subject: [PATCH] Bug 24430: Add ->orders and ->orders_count to Koha::Biblio > >This patch introduces an accessor to the related orders, and a method >that returns the orders count. The target usage for the count is the >API. In the rest of the codebase, we would just call: > > $biblio->orders->count > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Biblio.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Biblio.pm | 30 ++++++++++++++++++++++++++++++ > Koha/Schema/Result/Biblio.pm | 7 +++++++ > 2 files changed, 37 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 9ee4192e03..495df59db9 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -32,6 +32,7 @@ use Koha::DateUtils qw( dt_from_string ); > > use base qw(Koha::Object); > >+use Koha::Acquisition::Orders; > use Koha::ArticleRequest::Status; > use Koha::ArticleRequests; > use Koha::Biblio::Metadatas; >@@ -82,6 +83,35 @@ sub metadata { > return Koha::Biblio::Metadata->_new_from_dbic($metadata); > } > >+=head3 orders >+ >+my $orders = $biblio->orders(); >+ >+Returns a Koha::Acquisition::Orders object >+ >+=cut >+ >+sub orders { >+ my ( $self ) = @_; >+ >+ my $orders = $self->_result->orders; >+ return Koha::Acquisition::Orders->_new_from_dbic($orders); >+} >+ >+=head3 orders_count >+ >+my $orders_count = $biblio->orders_count(); >+ >+Returns the number of acquisition orders related to this biblio. >+ >+=cut >+ >+sub orders_count { >+ my ( $self ) = @_; >+ >+ return $self->orders->count; >+} >+ > =head3 can_article_request > > my $bool = $biblio->can_article_request( $borrower ); >diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm >index 116764ec69..7c66b1dc03 100644 >--- a/Koha/Schema/Result/Biblio.pm >+++ b/Koha/Schema/Result/Biblio.pm >@@ -417,6 +417,13 @@ __PACKAGE__->has_one( > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+__PACKAGE__->has_many( >+ "orders", >+ "Koha::Schema::Result::Aqorder", >+ { "foreign.biblionumber" => "self.biblionumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > __PACKAGE__->add_columns( > "+serial" => { is_boolean => 1 } > ); >-- >2.25.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24430
:
97414
|
97415
|
97416
|
97443
|
97446
|
97447
|
97448
|
97563
|
97564
|
97565
|
97652
|
97653
|
97654