vandelay copy overlay cont.
authorBill Erickson <berick@esilibrary.com>
Fri, 27 Jul 2012 19:55:13 +0000 (15:55 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 27 Jul 2012 19:55:13 +0000 (15:55 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm

index 484a7e2..139e147 100644 (file)
@@ -1581,11 +1581,30 @@ sub import_record_asset_list_impl {
             $$report_args{import_error} = undef;
             $$report_args{evt} = undef;
 
-            if ($item->internal_id) {
+            if (my $copy_id = $item->internal_id) { # assignment
                 # copy matches an existing copy.  Overlay instead of create.
 
+                my $qt = $e->json_query({
+                    select => {vbq => ['queue_type']},
+                    from => {vqbr => 'vbq'},
+                    where => {'+vqbr' => {id => $rec_id}}
+                })->[0]->{queue_type};
+
+                if ($qt eq 'acq') {
+                    # internal_id for ACQ queues refers to acq.lineitem_detail.id
+                    # pull the real copy id from the acq LID
+
+                    my $lid = $e->retrieve_acq_lineitem_detail($copy_id);
+                    if (!$lid) {
+                        $$report_args{evt} = $e->die_event;
+                        respond_with_status($report_args);
+                        next;
+                    }
+                    $copy_id = $lid->eg_copy_id;
+                }
+
                 $copy = $e->search_asset_copy([
-                    {id => $item->internal_id, deleted => 'f'},
+                    {id => $copy_id, deleted => 'f'},
                     {flesh => 1, flesh_fields => {acp => ['call_number']}}
                 ]);