From 97a761fdc5d14bcdd4e5acc4694ba6d9aba685f7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 5 Jan 2024 16:08:44 +0000 Subject: [PATCH] Bug 35100: Various fixes 1) Don't automagically always set a transfer to in transit on checkin.. wait for the user to actually confirm that's the case 2) New transfers triggered by a hold should take precidence, so hide transfers for any other reason from display 3) Remove current_branchtransfers prefect from detail.pl as doing a prefetch completely nukes the order_by that this transfer method relies heavily upon to get the right modified FIFO transfer of the queue. --- C4/Circulation.pm | 6 ++-- Koha/Item.pm | 1 - Koha/Schema/Result/Item.pm | 34 ++++++++++++------- catalogue/detail.pl | 2 +- .../prog/en/modules/circ/returns.tt | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 562cad72671..8ca2a742e30 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2376,8 +2376,7 @@ sub AddReturn { else { $messages->{'TransferTrigger'} = $transfer->reason; if ( $transfer->frombranch eq $branch ) { - $transfer->transit; - $messages->{'WasTransfered'} = $transfer->tobranch; + $messages->{'NeedsTransfer'} = $transfer->tobranch; } else { $messages->{'WrongTransfer'} = $transfer->tobranch; @@ -2522,7 +2521,8 @@ sub AddReturn { and not $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'} and not $messages->{TransferredRecall} - and not $messages->{RecallNeedsTransfer} ) + and not $messages->{RecallNeedsTransfer} + and not $messages->{NeedsTransfer} ) { my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; if (C4::Context->preference("AutomaticItemReturn" ) or diff --git a/Koha/Item.pm b/Koha/Item.pm index a86b9287645..b084d7b74aa 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -776,7 +776,6 @@ we still expect the item to end up at a final location eventually. sub get_transfer { my ($self) = @_; - my $transfer = $self->_result->current_branchtransfers->next; return Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer; } diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 8320ce4c761..be3dc681767 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -1013,19 +1013,29 @@ __PACKAGE__->many_to_many( "ordernumber", ); +#__PACKAGE__->has_many( +# "current_branchtransfers", +# "Koha::Schema::Result::Branchtransfer", +# sub { +# my $args = shift; +# +# return { +# "$args->{foreign_alias}.itemnumber" => { -ident => "$args->{self_alias}.itemnumber" }, +# "$args->{foreign_alias}.datearrived" => undef, +# "$args->{foreign_alias}.datecancelled" => undef, +# }; +# }, +# { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ] } +#); + __PACKAGE__->has_many( - "current_branchtransfers", - "Koha::Schema::Result::Branchtransfer", - sub { - my $args = shift; - - return { - "$args->{foreign_alias}.itemnumber" => { -ident => "$args->{self_alias}.itemnumber" }, - "$args->{foreign_alias}.datearrived" => undef, - "$args->{foreign_alias}.datecancelled" => undef, - }; - }, - { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ] } + "current_branchtransfers", + "Koha::Schema::Result::Branchtransfer", + { "foreign.itemnumber" => "self.itemnumber" }, + { + where => { 'datearrived' => undef, 'datecancelled' => undef }, + order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ] + } ); # Relationship with bundled items diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 9edaf3f3bbf..823f42d08ce 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -196,7 +196,7 @@ $params->{ itemlost } = 0 if $patron->category->hidelostitems && !$showallitems; my $items_params = { ( $invalid_marc_record ? () : ( host_items => 1 ) ), }; -my $items = $biblio->items($items_params)->search_ordered( $params, { prefetch => ['issue','current_branchtransfers'] } ); +my $items = $biblio->items($items_params)->search_ordered( $params, { prefetch => ['issue'] } ); # flag indicating existence of at least one item linked via a host record my $hostrecords = $biblio->host_items->count; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 2abde7f9c5a..720b9330137 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -121,7 +121,7 @@ [% END # /IF hold_auto_filled %] - [% IF ( trigger ) %] + [% IF ( trigger && !transfertodo ) %]

Reason for transfer

-- 2.43.0