From bc3954d07ddac96ebb2e62d94530e51261575e0b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 6 Jun 2011 16:35:11 -0400 Subject: [PATCH] Cancel bib holds with bib is deleted And notify user via A/T Signed-off-by: Bill Erickson Signed-off-by: Jason Etheridge --- .../lib/OpenILS/Application/Cat/BibCommon.pm | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm index 4d928a86a3..6a776d8158 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm @@ -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; } -- 2.11.0