Bug 24106: In returns.pl, don't search for item if no barcode is provided
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 25 Nov 2019 18:18:16 +0000 (13:18 -0500)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 13 Dec 2019 14:03:52 +0000 (14:03 +0000)
When loading returns.pl, code to check rotating collections fires off an search for items by barcode, but doesn't check for a barcode first. This means the code will search for items where barcode is NULL, which is definitely not the intended function.

Test Plan:
1) Apply this patch
2) Set up a rotating collection with items
3) Transfer the collection
4) Check in a rotating collection item
5) Note no change in functionality

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

circ/returns.pl

index 5e7d8e2..a9e2bc2 100755 (executable)
@@ -634,19 +634,21 @@ $template->param(
     AudioAlerts        => C4::Context->preference("AudioAlerts"),
 );
 
-my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!?
-if ( $item_from_barcode ) {
-    $itemnumber = $item_from_barcode->itemnumber;
-    my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
-    if ( $holdingBranch and $collectionBranch ) {
-        $holdingBranch //= '';
-        $collectionBranch //= $returnbranch;
-        if ( ! ( $holdingBranch eq $collectionBranch ) ) {
-            $template->param(
-              collectionItemNeedsTransferred => 1,
-              collectionBranch => $collectionBranch,
-              itemnumber => $itemnumber,
-            );
+if ( $barcode ) {
+    my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!?
+    if ( $item_from_barcode ) {
+        $itemnumber = $item_from_barcode->itemnumber;
+        my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
+        if ( $holdingBranch and $collectionBranch ) {
+            $holdingBranch //= '';
+            $collectionBranch //= $returnbranch;
+            if ( ! ( $holdingBranch eq $collectionBranch ) ) {
+                $template->param(
+                  collectionItemNeedsTransferred => 1,
+                  collectionBranch => $collectionBranch,
+                  itemnumber => $itemnumber,
+                );
+            }
         }
     }
 }