Bug 18501: (follow-up) Do not rely on userenv->{branchcode}
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 20 Aug 2020 12:28:41 +0000 (13:28 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 21 Aug 2020 09:51:20 +0000 (11:51 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/CirculationRules.pm
Koha/Item.pm

index 9bf1ab8..87062f5 100644 (file)
@@ -439,8 +439,8 @@ sub get_lostreturn_policy {
 
     my $behaviour = C4::Context->preference( 'RefundLostOnReturnControl' ) // 'CheckinLibrary';
     my $behaviour_mapping = {
-           CheckinLibrary => $params->{'return_branch'},
-           ItemHomeBranch => $item->homebranch,
+        CheckinLibrary    => $params->{'return_branch'} // $item->homebranch,
+        ItemHomeBranch    => $item->homebranch,
         ItemHoldingBranch => $item->holdingbranch
     };
 
index 84ba2da..8dffac4 100644 (file)
@@ -811,8 +811,10 @@ sub _set_found_trigger {
     return $self
       unless Koha::CirculationRules->get_lostreturn_policy(
         {
-            current_branch => C4::Context->userenv->{branch},
-            item           => $self,
+            item          => $self,
+            return_branch => C4::Context->userenv
+            ? C4::Context->userenv->{'branch'}
+            : undef,
         }
       );