From 64f0e822d0349e4ceb036da88718e9a3ccd74b21 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 17 Mar 2017 13:53:44 -0400 Subject: [PATCH] LP#1619703 Transfer ACQ lineitem to alternate bib WIP Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Acq/Order.pm | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 9adc310e37..1e003c3ff6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -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; -- 2.11.0