LP#1849212: (follow-up) numerous fixes to open-ils.courses.detach_material
[Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / Application / Courses.pm
index 577807a..304714d 100644 (file)
@@ -140,6 +140,7 @@ sub fetch_course_materials {
         $materials = $e->search_asset_course_module_course_materials($args);
     }
     $conn->respond($_) for @$materials;
+    $conn->respond_complete();
     return undef;
 }
 
@@ -256,25 +257,27 @@ sub _resetItemFields {
     my $acp = $e->retrieve_asset_copy($acmcm->item);
     my $course_lib = $e->retrieve_asset_course_module_course($acmcm->course)->owning_lib;
     if ($acmcm->original_status) {
-        $acp->status($acmcm->orginal_status);
+        $acp->status($acmcm->original_status);
     }
     if ($acmcm->original_circ_modifier) {
-        $acp->status($acmcm->orginal_circ_modifier);
+        $acp->circ_modifier($acmcm->original_circ_modifier);
     }
     if ($acmcm->original_location) {
-        $acp->status($acmcm->orginal_location);
+        $acp->location($acmcm->original_location);
     }
     $e->update_asset_copy($acmcm);
     if ($acmcm->original_callnumber) {
         my $existing_acn = $e->retrieve_asset_call_number($acp->call_number);
+        my $orig_acn = $e->retrieve_asset_call_number($acmcm->original_callnumber);
         # Let's attach to an existing call number, if one exists with the original label
         # and other appropriate specifications
-        my $acn_id = cat_sess->request('open-ils.cat.call_number.find_or_create',
-            $authtoken, $acmcm->original_callnumber,
+        my $dest_acn = $cat_sess->request('open-ils.cat.call_number.find_or_create',
+            $authtoken, $orig_acn->label,
             $existing_acn->record, $course_lib,
             $existing_acn->prefix, $existing_acn->suffix,
-            $existing_acn->label_class)->acn_id;
-        cat_sess->request('open-ils.cat.transfer_copies_to_volume',
+            $existing_acn->label_class)->gather(1);
+        my $acn_id = $dest_acn->{acn_id};
+        $cat_sess->request('open-ils.cat.transfer_copies_to_volume',
             $authtoken, $acn_id, [$acp->id]);
     }
 }