Bugzilla – Attachment 97653 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 ->active_orders_count to Koha::Biblio
Bug-24430-Add--orders-and--activeorderscount-to-Ko.patch (text/plain), 2.59 KB, created by
Martin Renvoize (ashimema)
on 2020-01-21 11:23:18 UTC
(
hide
)
Description:
Bug 24430: Add ->orders and ->active_orders_count to Koha::Biblio
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-01-21 11:23:18 UTC
Size:
2.59 KB
patch
obsolete
>From f30c2874cdcbaf008ecc44fafccb89d44403e5f6 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 ->active_orders_count to > Koha::Biblio > >This patch introduces an accessor to the related orders, and a method >that returns the active 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> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Biblio.pm | 32 ++++++++++++++++++++++++++++++++ > Koha/Schema/Result/Biblio.pm | 7 +++++++ > 2 files changed, 39 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 9ee4192e03..d0c291a528 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,37 @@ 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 active_orders_count >+ >+my $orders_count = $biblio->active_orders_count(); >+ >+Returns the number of active acquisition orders related to this biblio. >+An order is considered active when it is not cancelled (i.e. when datecancellation >+is not undef). >+ >+=cut >+ >+sub active_orders_count { >+ my ( $self ) = @_; >+ >+ return $self->orders->search({ datecancellationprinted => undef })->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.20.1
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