Bugzilla – Attachment 184629 Details for
Bug 40331
Extra transfer generated when transfer for hold cancelled due to checkin at incorrect library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40331: Return existing transfer if requesting a new transfer that is identical
Bug-40331-Return-existing-transfer-if-requesting-a.patch (text/plain), 3.85 KB, created by
Nick Clemens (kidclamp)
on 2025-07-25 13:45:43 UTC
(
hide
)
Description:
Bug 40331: Return existing transfer if requesting a new transfer that is identical
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-07-25 13:45:43 UTC
Size:
3.85 KB
patch
obsolete
>From ec8e9d95ccc5f0d7fd7c137d91c9ddeb0a6fa83a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 25 Jul 2025 13:36:33 +0000 >Subject: [PATCH] Bug 40331: Return existing transfer if requesting a new > transfer that is identical > >Currently request_transfer checks for the existence of a current transfer on the item, and a new one can either be >enqueued or replace this transfer. This patch adds a check to see if the requested transfer matches an existing transfer >on the item. In the case that it does we simply return that transfer rather than create a new transfer. > >This has the effect of eliminating 'WrongTransfer' generation if an item is checked in twice at the same branch, which feels correct. > >To test: > 1 - place a hold on an item that is currently at branch A, for pickup at branch B > 2 - check your item in at Branch A, click to confirm the hold and transfer (print slip if you want to) > 3 - sudo koha-mysql kohadev: SELECT * FROM branchtransfers -- See one transfer > 4 - check your item in at Branch A again, get a message that the item is supposed to go to Branch B. Don't click on the modal yet > 5 - repeat 3 -- See two transfers, one cancelled as WrongTransfer, one pending > 6 - Click 'Confirm and transfer' on the modal > 7 - repeat 3 -- See three tranfers - the two from before and a new active transfer > 8 - DELETE FROM branchtransfers > 9 - Apply patch, restart all >10 - repeat 3 - no transfers >11 - Check item in at branch A again and confirm >12 - repeat 3, one transfer >13 - Check item in, don't confirm the modal >14 - repeat 3, one transfer >15 - Confirm the modal >16 - repeat 3, one transfer >17 - Check the item in at branch C >18 - repeat 3, two transfers - one cancelled WrongTransfer, one active >19 - Confirm modal >20 - repeat 3, two transfers >21 - Check item in at branch B >22 - repeat 3, two transfers, one cancelled, one completed >--- > Koha/Item.pm | 12 ++++++++++++ > t/db_dependent/Koha/Item.t | 13 ++++++++++++- > 2 files changed, 24 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index eb36e62b06f..19a7fc53698 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -804,6 +804,18 @@ sub request_transfer { > } > } > >+ my $matching_transfers = Koha::Item::Transfers->search( >+ { >+ tobranch => $params->{to}->branchcode, >+ frombranch => $self->holdingbranch, >+ itemnumber => $self->itemnumber, >+ reason => $params->{reason}, >+ datearrived => undef, >+ datecancelled => undef >+ } >+ ); >+ return $matching_transfers->next if $matching_transfers->count; >+ > Koha::Exceptions::Item::Transfer::Limit->throw() > unless ( $params->{ignore_limits} > || $self->can_be_transferred( { to => $params->{to} } ) ); >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index c505066d88c..aeb6f8fe68c 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -1119,7 +1119,7 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'request_transfer() tests' => sub { > >- plan tests => 18; >+ plan tests => 20; > > $schema->storage->txn_begin; > >@@ -1174,6 +1174,17 @@ subtest 'request_transfer() tests' => sub { > > my $original_transfer = $transfer->get_from_storage; > >+ # Duplicated request >+ $transfer = $item->request_transfer( { to => $library1, reason => 'Manual' } ); >+ is( >+ ref($transfer), 'Koha::Item::Transfer', >+ 'Koha::Item->request_transfer should return a Koha::Item::Transfer object' >+ ); >+ is( >+ $transfer->branchtransfer_id, $original_transfer->branchtransfer_id, >+ "When a matching transfer is requested we update the existing one" >+ ); >+ > # Transfer already in progress > throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) } > 'Koha::Exceptions::Item::Transfer::InQueue', >-- >2.39.5
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 40331
:
184629
|
184653