From ee65e322387d5a6e6bbf0eaa9f0ed25a4b947a37 Mon Sep 17 00:00:00 2001 From: Stefan Berndtsson Date: Fri, 21 Oct 2022 14:10:42 +0200 Subject: [PATCH] Bug 31907: Show items as On hold when in processing Test plan: 1. Make sure syspref "opacbookbag" is set to "Allow". 2. Make sure syspref "HoldsNeedProcessingSIP" is set to "Don't fulfill". 3. Place a hold on an item. 4. Return item via SIP at the pickup library. 5. View biblio in Opac. 6. Note that it says "Available" as status. 7. Add biblio to Cart. 8. Open Cart. 9. Note that it says "Available" as status. 10. Apply patch. 11. Reload Opac page. 12. It should now say "On hold". 13. Reload Card page. 14. It should also say "On hold". Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- Koha/Holds.pm | 7 +++ .../bootstrap/en/includes/item-status.inc | 2 +- opac/opac-basket.pl | 1 + t/db_dependent/Koha/Holds.t | 52 ++++++++++++++++++- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/Koha/Holds.pm b/Koha/Holds.pm index c5bfc55df3..1f7443d23f 100644 --- a/Koha/Holds.pm +++ b/Koha/Holds.pm @@ -48,6 +48,13 @@ sub waiting { return $self->search( { found => 'W' } ); } + +sub processing { + my ( $self ) = @_; + + return $self->search( { found => 'P' } ); +} + =head3 unfilled returns a set of holds that are unfilled from an existing set diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc index 0a5077bb58..ca13bac71c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc @@ -61,7 +61,7 @@ to [% Branches.GetName( transfertto ) | html %] since [% transfertwhen | $KohaDates %] [% END %] -[% IF (item.isa('Koha::Item') AND item.holds.waiting.count) OR (NOT item.isa('Koha::Item') AND item.waiting) %] +[% IF (item.isa('Koha::Item') AND item.holds.waiting.count) OR (item.isa('Koha::Item') AND item.holds.processing.count) OR (NOT item.isa('Koha::Item') AND item.waiting) OR (NOT item.isa('Koha::Item') AND item.processing) %] [% SET itemavailable = 0 %] On hold [% END %] diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index eb4ac974d2..411ae6444c 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -98,6 +98,7 @@ foreach my $biblionumber ( @bibs ) { foreach my $item (@$items) { my $reserve_status = C4::Reserves::GetReserveStatus($item->{itemnumber}); if( $reserve_status eq "Waiting"){ $item->{'waiting'} = 1; } + if( $reserve_status eq "Processing"){ $item->{'processing'} = 1; } } my $hasauthors = 0; diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index aec261dd1f..a6b3170ff9 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 9; use Test::Warn; use C4::Circulation qw( AddIssue ); @@ -717,3 +717,53 @@ subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_r $schema->storage->txn_rollback; }; + +subtest 'get holds in processing' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + + my $item = $builder->build_sample_item; + + my $hold_1 = $builder->build_object( + { + class => 'Koha::Holds', + value => { + found => 'P', + itemnumber => $item->id, + biblionumber => $item->biblionumber, + borrowernumber => $patron->id + } + } + ); + my $hold_2 = $builder->build_object( + { + class => 'Koha::Holds', + value => { + found => undef, + itemnumber => $item->id, + biblionumber => $item->biblionumber, + borrowernumber => $patron->id + } + } + ); + my $hold_3 = $builder->build_object( + { + class => 'Koha::Holds', + value => { + found => undef, + itemnumber => $item->id, + biblionumber => $item->biblionumber, + borrowernumber => $patron->id + } + } + ); + + my $processing_holds = $item->holds->processing; + is( $processing_holds->count, 1 ); + + $schema->storage->txn_rollback; +}; -- 2.20.1