Bugzilla – Attachment 104437 Details for
Bug 24620
Existing transfers not closed when hold is set to waiting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24620: [19.11.x] Close existing transfer when hold set to waiting (squashed)
Bug-24620-1911x-Close-existing-transfer-when-hold-.patch (text/plain), 4.77 KB, created by
Nick Clemens
on 2020-05-06 15:15:03 UTC
(
hide
)
Description:
Bug 24620: [19.11.x] Close existing transfer when hold set to waiting (squashed)
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2020-05-06 15:15:03 UTC
Size:
4.77 KB
patch
obsolete
>From 95edc4314b848ee7819aa4f5541586e5a57b0f41 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 10 Feb 2020 18:18:45 +0000 >Subject: [PATCH] Bug 24620: [19.11.x] Close existing transfer when hold set to > waiting (squashed) > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Bug 24620: Close existing transfers when setting item to waiting > >This patch adds a clause in ModReserveAffect to check if there >are existing transfers and close them when setting a hold to waiting > >To test: > 1 - Set AutomaticItemReturn to Do > 2 - Checkin an item from Library B at Library A > 3 - Confirm item is in transfer (check the details page) > 4 - Place a item level hold for pickup at library A > 5 - Checkin the item at Library A > 6 - Confirm the hold > 7 - View the details page > 8 - Note the item is in transit and waiting > 9 - Apply patch >10 - Delete hold and repeat >11 - Confirm that transfer is closed when hold marked waiting > >Signed-off-by: Sally <sally.healey@cheshirewestandchester.gov.uk> > >Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Bug 24620: Fix test, remove replaced code, use dt_from_string > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Reserves.pm | 13 +++++++++++-- > t/db_dependent/Circulation.t | 38 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 48 insertions(+), 3 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 86b4b8ba2c..cc4bc5e9b4 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1105,8 +1105,17 @@ sub ModReserveAffect { > $hold->itemnumber($itemnumber); > $hold->set_waiting($transferToDo); > >- _koha_notify_reserve( $hold->reserve_id ) >- if ( !$transferToDo && !$already_on_shelf ); >+ if( !$transferToDo ){ >+ _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf; >+ my $transfers = Koha::Item::Transfers->search({ >+ itemnumber => $itemnumber, >+ datearrived => undef >+ }); >+ while( my $transfer = $transfers->next ){ >+ $transfer->datearrived( dt_from_string() )->store; >+ }; >+ } >+ > > _FixPriority( { biblionumber => $biblionumber } ); > my $item = Koha::Items->find($itemnumber); >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 2c3d3aa2b4..3514dc8553 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 46; >+use Test::More tests => 47; > use Test::MockModule; > > use Data::Dumper; >@@ -40,8 +40,10 @@ use Koha::DateUtils; > use Koha::Database; > use Koha::IssuingRules; > use Koha::Items; >+use Koha::Item::Transfers; > use Koha::Checkouts; > use Koha::Patrons; >+use Koha::Holds; > use Koha::CirculationRules; > use Koha::Subscriptions; > use Koha::Account::Lines; >@@ -3424,6 +3426,40 @@ subtest "Test Backdating of Returns" => sub { > is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' ); > }; > >+subtest 'Filling a hold should cancel existing transfer' => sub { >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference('AutomaticItemReturn', 1); >+ >+ my $libraryA = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $libraryB = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $patron_category->{categorycode}, >+ branchcode => $libraryA->branchcode, >+ } >+ } >+ )->store; >+ >+ my $item = $builder->build_sample_item({ >+ homebranch => $libraryB->branchcode, >+ }); >+ >+ my ( undef, $message ) = AddReturn( $item->barcode, $libraryA->branchcode, undef, undef ); >+ is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 1, "We generate a transfer on checkin"); >+ AddReserve($libraryA->branchcode,$patron->borrowernumber,$item->biblionumber,undef,undef,undef,undef,undef,undef,$item->itemnumber); >+ my $reserves = Koha::Holds->search({ itemnumber => $item->itemnumber }); >+ is( $reserves->count, 1, "Reserve is placed"); >+ ( undef, $message ) = AddReturn( $item->barcode, $libraryA->branchcode, undef, undef ); >+ my $reserve = $reserves->next; >+ ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve->reserve_id ); >+ $reserve->discard_changes; >+ ok( $reserve->found eq 'W', "Reserve is marked waiting" ); >+ is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 0, "No outstanding transfers when hold is waiting"); >+}; >+ > $schema->storage->txn_rollback; > C4::Context->clear_syspref_cache(); > $cache->clear_from_cache('single_holidays'); >-- >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 24620
:
98678
|
98679
|
98711
|
98805
|
100448
|
100451
|
102914
|
102915
|
102916
| 104437