added support for volume-level holds migration during volume merging
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Feb 2008 18:51:26 +0000 (18:51 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Feb 2008 18:51:26 +0000 (18:51 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8825 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Cat/Merge.pm

index 310db24..7270182 100644 (file)
@@ -218,6 +218,7 @@ sub merge_volumes {
                $_->edit_date('now');
                return (undef,$editor->die_event) unless $editor->allowed('UPDATE_VOLUME', $_->owning_lib);
                $editor->update_asset_call_number($_) or return (undef, $editor->die_event);
+        merge_volume_holds($editor, $bigcn, $_->id);
        }
 
        my ($mvol) = grep { $_->id == $bigcn } @$volumes;
@@ -225,6 +226,32 @@ sub merge_volumes {
        return ($mvol);
 }
 
+sub merge_volume_holds {
+    my($e, $master_id, $vol_id) = @_;
+
+    my $holds = $e->search_action_hold_request(
+        {   cancel_time => undef, 
+            fulfillment_time => undef,
+            hold_type => 'V',
+            target => $vol_id
+        }
+    );
+
+    for my $hold (@$holds) {
+
+        $logger->info("Changing hold ".$hold->id.
+            " target from ".$hold->target." to $master_id in volume merge");
+
+        $hold->target($master_id);
+        unless($e->update_action_hold_request($hold)) {
+            my $evt = $e->event;
+            $logger->error("Error updating hold ". $evt->textcode .":". $evt->desc .":". $evt->stacktrace); 
+        }
+    }
+
+    return undef;
+}
+
 
 1;