From 0cdaf2d93a717d13d4f47bc9409b9503c4bb6f8e Mon Sep 17 00:00:00 2001
From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 22 Sep 2009 21:15:44 +0000
Subject: [PATCH] When a hold has expired waiting for a copy to become
 available and is subsequently cancelled, set the cancel cause value and tell
 the notification innards to react as necessary (e.g. send the patron an
 email)

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14105 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../perlmods/OpenILS/Application/Storage/Publisher/action.pm  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
index 747e2827c9..bb8ba736b9 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
@@ -896,8 +896,17 @@ sub new_hold_copy_targeter {
 			if ($hold->expire_time) {
 				my $ex_time = $parser->parse_datetime( clense_ISO8601( $hold->expire_time ) );
 				if ( DateTime->compare($ex_time, DateTime->now) < 0 ) {
-					$hold->update( { cancel_time => 'now' } );
+
+					# cancel cause = un-targeted expiration
+					$hold->update( { cancel_time => 'now', cancel_cause => 1 } ); 
 					$self->method_lookup('open-ils.storage.transaction.commit')->run;
+
+					# tell A/T the hold was cancelled
+					my $fm_hold = $hold->to_fieldmapper;
+					my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+					$ses->request('open-ils.trigger.event.autocreate', 
+						'hold_request.cancel.expire_no_target', $fm_hold, $fm_hold->pickup_lib);
+
 					die "OK\n";
 				}
 			}
-- 
2.11.0