From ce4404002d5119f0cbfded906b0b10ec9354f690 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 Signed-off-by: Tomas Cohen Arazi --- Koha/Holds.pm | 7 +++ .../bootstrap/en/includes/item-status.inc | 2 +- opac/opac-basket.pl | 1 + t/db_dependent/Koha/Holds.t | 50 +++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/Koha/Holds.pm b/Koha/Holds.pm index a4de91c813..7c382dd3c6 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 2c692ec522..5e055307ff 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -744,3 +744,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.39.5