[replaceprevious](bug #3562) fix returning document in another branch
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 9 Sep 2009 21:23:06 +0000 (23:23 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 16 Sep 2009 21:19:45 +0000 (23:19 +0200)
there is no transfert alert if you make a return in another branch than the homebranch.

C4/Circulation.pm

index c260c1e..ab03ac7 100644 (file)
@@ -1335,20 +1335,19 @@ sub AddReturn {
         $messages->{'BadBarcode'} = $barcode;
         $doreturn = 0;
     } else {
-        if ( not %$iteminformation ) {
+        # find the borrower
+        if ( not $iteminformation->{borrowernumber} ) {
             $messages->{'NotIssued'} = $barcode;
-            # even though item is not on loan, it may still
-            # be transferred; therefore, get current branch information
-            my $curr_iteminfo = GetItem($itemnumber);
-            $iteminformation->{'itemnumber'}    = $curr_iteminfo->{'itemnumber'};
-            $iteminformation->{'homebranch'}    = $curr_iteminfo->{'homebranch'};
-            $iteminformation->{'holdingbranch'} = $curr_iteminfo->{'holdingbranch'};
-            $iteminformation->{'itemlost'}      = $curr_iteminfo->{'itemlost'};
-            # These lines patch up $iteminformation enough so it can be used below for other messages
             $doreturn = 0;
         }
-
-        my $hbr = $iteminformation->{C4::Context->preference("HomeOrHoldingBranch")} || '';
+        
+        # even though item is not on loan, it may still
+        # be transferred; therefore, get current branch information
+        my $curr_iteminfo = GetItem($iteminformation->{'itemnumber'});
+        $iteminformation->{'homebranch'} = $curr_iteminfo->{'homebranch'};
+        $iteminformation->{'holdingbranch'} = $curr_iteminfo->{'holdingbranch'};
+        $iteminformation->{'itemlost'} = $curr_iteminfo->{'itemlost'};
+        
         # check if the book is in a permanent collection....
         # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
         if ( $hbr ) {
@@ -1450,7 +1449,7 @@ sub AddReturn {
         #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch
         #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch .
         
-        if ($doreturn and ($branch ne $iteminformation->{$hbr}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){
+        if (($doreturn or $messages->{'NotIssued'}) and ($branch ne $iteminformation->{$hbr}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){
                        if (C4::Context->preference("AutomaticItemReturn") == 1) {
                                ModItemTransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{$hbr});
                                $messages->{'WasTransfered'} = 1;