Bugzilla – Attachment 121715 Details for
Bug 28294
C4::Circulation::updateWrongTransfer should be moved into Koha::
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28294: Convert updateWrongTransfer to use request_transfer
Bug-28294-Convert-updateWrongTransfer-to-use-reque.patch (text/plain), 3.00 KB, created by
Martin Renvoize (ashimema)
on 2021-06-08 10:58:32 UTC
(
hide
)
Description:
Bug 28294: Convert updateWrongTransfer to use request_transfer
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-08 10:58:32 UTC
Size:
3.00 KB
patch
obsolete
>From edaf21d64e4e6814286d5a87b1dc1f4b9599b958 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 17 May 2021 17:14:16 +0100 >Subject: [PATCH] Bug 28294: Convert updateWrongTransfer to use > request_transfer > >This patch is an interim patch to prove that the updated >request_transfer method achieves the same as updateWrongTransfer. > >Test plan >1/ Run t/db_dependant/Circulation.t before and after applying this >patch. > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > C4/Circulation.pm | 14 ++++---------- > Koha/Item/Transfer.pm | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+), 10 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 7a28b100c3..b497fceebd 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3591,19 +3591,13 @@ This function validate the line of brachtransfer but with the wrong destination > sub updateWrongTransfer { > my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_; > >- # first step: cancel the original transfer >- my $item = Koha::Items->find($itemNumber); >- my $transfer = $item->get_transfer; >- $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store(); >- >- # second step: create a new transfer to the right location >- my $new_transfer = $item->request_transfer( >+ my $transfer = Koha::Items->find($itemNumber)->get_transfer; >+ my $new_transfer = $transfer->replace( > { > to => $transfer->to_library, >- reason => $transfer->reason, >- comment => $transfer->comments, >+ reason => 'WrongTransfer', > ignore_limits => 1, >- enqueue => 1 >+ force => 1 > } > ); > >diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm >index 59387d4415..8aa70fa67c 100644 >--- a/Koha/Item/Transfer.pm >+++ b/Koha/Item/Transfer.pm >@@ -186,6 +186,45 @@ sub cancel { > return $self; > } > >+=head3 replace >+ >+ my $new_transfer = $transfer->replace( >+ { >+ to => $to_library, >+ reason => $reason, >+ [ ignore_limits => 0, force => 0 ] >+ } >+ ); >+ >+Replace this transfer by cancelling it and setting up a new transfer request. >+ >+=cut >+ >+sub replace { >+ my ( $self, $params ) = @_; >+ >+ Koha::Exceptions::MissingParameter->throw( >+ error => "The 'reason' parameter is mandatory" ) >+ unless defined($params->{reason}); >+ >+ my $in_transit = $self->in_transit; >+ >+ # Throw exception if item is in transit already >+ Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $in_transit ); >+ >+ my $new_transfer = $self->item->request_transfer( >+ { >+ to => $self->to_library, >+ reason => $params->{'reason'}, >+ ignore_limits => $params->{'ignore_limits'}, >+ force => $params->{'force'}, >+ replace => 1 >+ } >+ ); >+ >+ return $new_transfer; >+} >+ > =head3 type > > =cut >-- >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 28294
:
120637
|
121062
|
121063
|
121064
|
121077
|
121078
|
121079
|
121095
|
121096
|
121097
|
121714
|
121715
|
121716
|
130082
|
130083
|
130084
|
130085
|
130086
|
130087
|
132212
|
132213
|
132214
|
132215
|
132216
|
132217
|
160516
|
160517
|
160518
|
160519
|
160520
|
160521
|
160536
|
160692
|
168281
|
172778
|
172781
|
173856
|
174805