Bugzilla – Attachment 114379 Details for
Bug 27209
Add Koha::Hold->set_pickup_location
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27209: Add Koha::Hold->set_pickup_location
Bug-27209-Add-KohaHold-setpickuplocation.patch (text/plain), 2.67 KB, created by
Victor Grousset/tuxayo
on 2020-12-14 12:47:27 UTC
(
hide
)
Description:
Bug 27209: Add Koha::Hold->set_pickup_location
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2020-12-14 12:47:27 UTC
Size:
2.67 KB
patch
obsolete
>From 121ab283a88a7ebf708ee50657362e1f9c2029e7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 11 Dec 2020 16:51:42 -0300 >Subject: [PATCH] Bug 27209: Add Koha::Hold->set_pickup_location > >This patch introduces a method to safely update a hold's pickup >location. It will raise exceptionis if the passed parameters are invalid >or absent. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Hold.t >=> SUCCESS; Tests pass >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > Koha/Exceptions/Hold.pm | 4 ++++ > Koha/Hold.pm | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 40 insertions(+) > >diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm >index 2a5b2faec6..65d7b9d9a9 100644 >--- a/Koha/Exceptions/Hold.pm >+++ b/Koha/Exceptions/Hold.pm >@@ -27,6 +27,10 @@ use Exception::Class ( > isa => 'Koha::Exceptions::Hold', > description => "Found holds cannot be suspended", > fields => ['status'] >+ }, >+ 'Koha::Exceptions::Hold::InvalidPickupLocation' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => 'The supplied pickup location is not valid' > } > ); > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 7754691238..d848962204 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > > use Carp; > use Data::Dumper qw(Dumper); >+use List::MoreUtils qw(any); > > use C4::Context qw(preference); > use C4::Letters; >@@ -221,6 +222,41 @@ sub set_waiting { > return $self; > } > >+=head3 set_pickup_location >+ >+ $hold->set_pickup_location({ library_id => $library->id }); >+ >+Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if >+the passed pickup location is not valid. >+ >+=cut >+ >+sub set_pickup_location { >+ my ( $self, $params ) = @_; >+ >+ Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory') >+ unless $params->{library_id}; >+ >+ my @pickup_locations; >+ >+ if ( $self->itemnumber ) { # item-level >+ @pickup_locations = $self->item->pickup_locations({ patron => $self->patron }); >+ } >+ else { # biblio-level >+ @pickup_locations = $self->biblio->pickup_locations({ patron => $self->patron }); >+ } >+ >+ if ( any { $_->branchcode eq $params->{library_id} } @pickup_locations ) { >+ # all good, set the new pickup location >+ $self->branchcode( $params->{library_id} )->store; >+ } >+ else { >+ Koha::Exceptions::Hold::InvalidPickupLocation->throw; >+ } >+ >+ return $self; >+} >+ > =head3 set_processing > > $hold->set_processing; >-- >2.29.2
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 27209
:
114356
|
114357
|
114374
|
114378
|
114379
|
114380
|
114443
|
114444
|
114445
|
114448
|
114449
|
114450