Cancel bib holds with bib is deleted
authorBill Erickson <berick@esilibrary.com>
Mon, 6 Jun 2011 20:35:11 +0000 (16:35 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 24 Jun 2011 15:15:53 +0000 (11:15 -0400)
And notify user via A/T

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm

index 4d928a8..6a776d8 100644 (file)
@@ -340,6 +340,32 @@ sub delete_rec {
 
    $editor->update_biblio_record_entry($rec) or return $editor->event;
 
+    my $holds = $editor->search_action_hold_request({
+        target => $rec->id,
+        hold_type => 'T',
+        cancel_time => undef,
+        fulfillment_time => undef
+    });
+
+    for my $hold (@$holds) {
+
+        $hold->cancel_time('now');
+        $hold->cancel_cause(1); # un-targeted expiration.
+        $editor->update_action_hold_request($hold) or return $editor->die_event;
+
+        my $maps = $editor->search_action_hold_copy_map({hold => $hold->id});
+        for(@$maps) {
+            $editor->delete_action_hold_copy_map($_) 
+                or return $editor->die_event;
+        }
+
+        my $at_ses = OpenSRF::AppSession->create('open-ils.trigger');
+        $at_ses->request(
+            'open-ils.trigger.event.autocreate',
+            'hold_request.cancel.expire_no_target', 
+            $hold, $hold->pickup_lib);
+    }
+
    return undef;
 }