Bugzilla – Attachment 98206 Details for
Bug 24440
Add ->current_item_level_holds to Koha::Acquisition::Order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24440: Add ->current_holds to Koha::Acquisition::Order
Bug-24440-Add--currentholds-to-KohaAcquisitionOrde.patch (text/plain), 3.08 KB, created by
David Nind
on 2020-01-31 07:05:33 UTC
(
hide
)
Description:
Bug 24440: Add ->current_holds to Koha::Acquisition::Order
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-01-31 07:05:33 UTC
Size:
3.08 KB
patch
obsolete
>From ff533284463197b1bfa3a8113ef64d7b31aba9a9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 16 Jan 2020 15:58:25 -0300 >Subject: [PATCH] Bug 24440: Add ->current_holds to Koha::Acquisition::Order > >This patch introduces a method to fetch the current holds associated with the >items linked to an order line. It basically implements what's done in >parcel.pl, but fully tested and suitable for using on the API. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Acquisition/Order.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Acquisition/Order.pm | 34 +++++++++++++++++++++++++++++++++- > Koha/Schema/Result/Aqorder.pm | 14 ++++++++++++++ > 2 files changed, 47 insertions(+), 1 deletion(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 6d37e15c2b..0eb5c7f3fa 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -169,6 +169,37 @@ sub subscription { > return Koha::Subscription->_new_from_dbic( $subscription_rs ); > } > >+=head3 current_holds >+ >+ my $holds = $order->current_holds; >+ >+Returns the current holds associated to the order. It returns a I<Koha::Holds> >+resultset in scalar context or a list of I<Koha::Hold> objects in list context. >+ >+It returns B<undef> if no I<biblio> or no I<items> are linked to the order. >+ >+=cut >+ >+sub current_holds { >+ my ($self) = @_; >+ >+ my $items_rs = $self->_result->aqorders_items; >+ my @item_numbers = $items_rs->get_column('itemnumber')->all; >+ >+ return unless @item_numbers; >+ >+ my $biblio = $self->biblio; >+ return unless $biblio; >+ >+ return $biblio->current_holds->search( >+ { >+ itemnumber => { >+ -in => \@item_numbers >+ } >+ } >+ ); >+} >+ > =head3 items > > my $items = $order->items >@@ -196,7 +227,8 @@ Returns the bibliographic record associated to the order > > sub biblio { > my ( $self ) = @_; >- my $biblio_rs= $self->_result->biblionumber; >+ my $biblio_rs= $self->_result->biblio; >+ return unless $biblio_rs; > return Koha::Biblio->_new_from_dbic( $biblio_rs ); > } > >diff --git a/Koha/Schema/Result/Aqorder.pm b/Koha/Schema/Result/Aqorder.pm >index 75917c88f5..f9f307ceb2 100644 >--- a/Koha/Schema/Result/Aqorder.pm >+++ b/Koha/Schema/Result/Aqorder.pm >@@ -664,12 +664,26 @@ __PACKAGE__->many_to_many("borrowernumbers", "aqorder_users", "borrowernumber"); > # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-31 11:51:37 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GQEXetlivZm7buQohl8m4A > >+__PACKAGE__->belongs_to( >+ "biblio", >+ "Koha::Schema::Result::Biblio", >+ { 'foreign.biblionumber' => "self.biblionumber" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "SET NULL", >+ on_update => "CASCADE", >+ }, >+); >+ > sub koha_objects_class { > 'Koha::Acquisition::Orders'; > } >+ > sub koha_object_class { > 'Koha::Acquisition::Order'; > } >+ > __PACKAGE__->add_columns( > '+uncertainprice' => { is_boolean => 1 } > ); >-- >2.11.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 24440
:
97467
|
97468
|
97491
|
97492
|
98194
|
98195
|
98196
|
98197
|
98205
|
98206
|
98207
|
98208
|
98237
|
98283
|
98284
|
98285
|
98286
|
98287
|
98288