LP#1619703 Transfer ACQ lineitem to alternate bib WIP
authorBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 17:53:44 +0000 (13:53 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 17 Mar 2017 17:53:44 +0000 (13:53 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm

index 9adc310..1e003c3 100644 (file)
@@ -4225,30 +4225,33 @@ sub transfer_lineitem {
         {substream => 1}
     );
 
-    # Group copies into call number batches so each call number can
-    # be assessed and processed once.
-    my %cn_batches;
-    for my $copy (@$copies) {
-        my $cn_id = $copy->call_number;
-        $cn_batches{$cn_id} = [] unless $cn_batches{$cn_id};
-        push(@{$cn_batches{$cn_id}}, $copy);
-    }
+    if (@$copies) {
+
+        # Group copies into call number batches so each call number can
+        # be assessed and processed once.
+        my %cn_batches;
+        for my $copy (@$copies) {
+            my $cn_id = $copy->call_number;
+            $cn_batches{$cn_id} = [] unless $cn_batches{$cn_id};
+            push(@{$cn_batches{$cn_id}}, $copy);
+        }
 
-    while (my ($cn_id, $cn_copies) = each %cn_batches) {
-        my $evt = transfer_order_volume($e, $bib_id, $cn_id, $cn_copies);
-        return $evt if $evt;
-    }
+        while (my ($cn_id, $cn_copies) = each %cn_batches) {
+            my $evt = transfer_order_volume($e, $bib_id, $cn_id, $cn_copies);
+            return $evt if $evt;
+        }
 
-    # Transfer parts as needed to the target bib record.
-    my $part_maps = $e->search_asset_copy_part_map(
-        [   {target_copy => [map {$_->id} @$copies]},
-            {flesh => 1, flesh_fields => {acpm => ['part']}}
-        ], {substream => 1}
-    );
+        # Transfer parts as needed to the target bib record.
+        my $part_maps = $e->search_asset_copy_part_map(
+            [   {target_copy => [map {$_->id} @$copies]},
+                {flesh => 1, flesh_fields => {acpm => ['part']}}
+            ], {substream => 1}
+        );
 
-    for my $map (@$part_maps) {
-        my $evt = transfer_order_copy_parts($e, $bib_id, $map);
-        return $evt if $evt;
+        for my $map (@$part_maps) {
+            my $evt = transfer_order_copy_parts($e, $bib_id, $map);
+            return $evt if $evt;
+        }
     }
 
     $e->commit;