Bugzilla – Attachment 189925 Details for
Bug 41298
Filtering holdings table with status In transit considers every item ever transferred to be "In transit"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41298: Fix filtering items by in transit
Bug-41298-Fix-filtering-items-by-in-transit.patch (text/plain), 6.20 KB, created by
OpenFifth Sandboxes
on 2025-11-25 13:25:30 UTC
(
hide
)
Description:
Bug 41298: Fix filtering items by in transit
Filename:
MIME Type:
Creator:
OpenFifth Sandboxes
Created:
2025-11-25 13:25:30 UTC
Size:
6.20 KB
patch
obsolete
>From 788f0c783e6649f54d0a018988b8eb4c4b17ae2c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 25 Nov 2025 14:04:56 +0100 >Subject: [PATCH] Bug 41298: Fix filtering items by in transit >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The filtering condition was not correct, the presence of a line in >the transfer table is not enough to now if the item is in transit. >Here we filter reusing the same conditions as >Koha::Item::Transfer->in_transit > >Test plan: >Have at least 2 items for a given bibliographic record >Transfer item 1 >Transfer item 2 >Receive/Fullfill the transfer for item 1 > >Item 1 is now available and item 2 is in transit > >Go to items record and filter holdings table with status "In transit" >=> Only item 2 is displayed > >Filter holdings table with status "Available" >=> Only item 1 is displayed > >Signed-off-by: Anneli Ãsterman <anneli.osterman@koha-suomi.fi> >--- > Koha/Items.pm | 4 +++ > t/db_dependent/Koha/Items.t | 59 ++++++++++++++++++++++++++----------- > 2 files changed, 45 insertions(+), 18 deletions(-) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 830bfc3914..862631fbfb 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -260,6 +260,10 @@ sub filter_by_in_transit { > my ( $self, $params ) = @_; > > $params //= {}; >+ $params->{datesent} = { '!=' => undef }; >+ $params->{datearrived} = undef; >+ $params->{datecancelled} = undef; >+ > my $transfers = Koha::Item::Transfers->search( > { %$params, 'me.itemnumber' => [ $self->get_column('itemnumber') ], }, > { >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 29a29a50e3..3e74ac1fb6 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -155,10 +155,10 @@ subtest 'search' => sub { > } > ); > >- ok( $lost_items->count == 1, "Filtered to 1 lost item" ); >- ok( $damaged_items->count == 1, "Filtered to 1 damaged item" ); >- ok( $withdrawn_items->count == 1, "Filtered to 1 withdrawn item" ); >- ok( $notforloan_items->count == 1, "Filtered to 1 notforloan item" ); >+ is( $lost_items->count, 1, "Filtered to 1 lost item" ); >+ is( $damaged_items->count, 1, "Filtered to 1 damaged item" ); >+ is( $withdrawn_items->count, 1, "Filtered to 1 withdrawn item" ); >+ is( $notforloan_items->count, 1, "Filtered to 1 notforloan item" ); > > C4::Circulation::AddIssue( $patron, $item_1->barcode ); > >@@ -169,15 +169,19 @@ subtest 'search' => sub { > } > ); > >- ok( $checked_out_items->count == 1, "Filtered to 1 checked out item" ); >+ is( $checked_out_items->count, 1, "Filtered to 1 checked out item" ); > > my $transfer_1 = $builder->build_object( > { > class => 'Koha::Item::Transfers', > value => { >- itemnumber => $item_2->itemnumber, >- frombranch => $library_1->{branchcode}, >- tobranch => $library_2->{branchcode}, >+ itemnumber => $item_2->itemnumber, >+ frombranch => $library_1->{branchcode}, >+ tobranch => $library_2->{branchcode}, >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()', > } > } > ); >@@ -189,7 +193,7 @@ subtest 'search' => sub { > } > ); > >- ok( $in_transit_items->count == 1, "Filtered to 1 in transit item" ); >+ is( $in_transit_items->count, 1, "Filtered to 1 in transit item" ); > > my $item_7 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } ); > >@@ -209,7 +213,7 @@ subtest 'search' => sub { > } > ); > >- ok( $on_hold_items->count == 1, "Filtered to 1 on hold item" ); >+ is( $on_hold_items->count, 1, "Filtered to 1 on hold item" ); > > my $item_8 = $builder->build_sample_item( > { >@@ -225,7 +229,7 @@ subtest 'search' => sub { > } > ); > >- ok( $restricted_items->count == 1, "Filtered to 1 restricted item" ); >+ is( $restricted_items->count, 1, "Filtered to 1 restricted item" ); > > $schema->storage->txn_rollback; > }; >@@ -2616,7 +2620,7 @@ subtest 'filter_by_checked_out' => sub { > }; > > subtest 'filter_by_in_transit' => sub { >- plan tests => 3; >+ plan tests => 5; > > $schema->storage->txn_begin; > >@@ -2636,9 +2640,13 @@ subtest 'filter_by_in_transit' => sub { > { > class => 'Koha::Item::Transfers', > value => { >- itemnumber => $item_1->itemnumber, >- frombranch => $library_1->{branchcode}, >- tobranch => $library_2->{branchcode}, >+ itemnumber => $item_1->itemnumber, >+ frombranch => $library_1->{branchcode}, >+ tobranch => $library_2->{branchcode}, >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()', > } > } > ); >@@ -2649,15 +2657,30 @@ subtest 'filter_by_in_transit' => sub { > { > class => 'Koha::Item::Transfers', > value => { >- itemnumber => $item_2->itemnumber, >- frombranch => $library_2->{branchcode}, >- tobranch => $library_1->{branchcode}, >+ itemnumber => $item_2->itemnumber, >+ frombranch => $library_2->{branchcode}, >+ tobranch => $library_1->{branchcode}, >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()', > } > } > ); > > is( $biblio->items->filter_by_in_transit->count, 2, "Filtered 2 in transit items" ); > >+ $item_1->get_transfer->receive; >+ >+ is_deeply( >+ [ $biblio->items->filter_by_in_transit->get_column('itemnumber') ], [ $item_2->itemnumber ], >+ "First item has been received" >+ ); >+ >+ $item_2->get_transfer->cancel( { reason => "Manual", force => 1 } ); >+ >+ is( $biblio->items->filter_by_in_transit->count, 0, "Second item's transfer has been cancelled" ); >+ > $schema->storage->txn_rollback; > > }; >-- >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 41298
:
189924
| 189925