From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 22 Feb 2010 14:18:21 +0000 (+0000)
Subject: keep in-db circ consistent with script circs WRT dissallowing checkouts and renewals... 
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c8dd0068c14fe0f3b3152a9d72404c1b2530afc3;p=contrib%2FConifer.git

keep in-db circ consistent with script circs WRT dissallowing checkouts and renewals for inactive patrons, inactive cards, and expired patrons

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15607 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
index 06ae0614f6..6f646253a0 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
@@ -669,16 +669,21 @@ sub mk_env {
     # Grab the patron
     # --------------------------------------------------------------------------
     my $patron;
+	my $flesh = {
+		flesh => 1,
+		flesh_fields => {au => [ qw/ card / ]}
+	};
+
 	if( $self->patron_id ) {
-		$patron = $e->retrieve_actor_user($self->patron_id) or return $e->event;
+		$patron = $e->retrieve_actor_user([$self->patron_id, $flesh]) or return $e->event;
 
 	} elsif( $self->patron_barcode ) {
 
 		my $card = $e->search_actor_card( 
 			{barcode => $self->patron_barcode})->[0] or return $e->event;
 
-		$patron = $e->search_actor_user( 
-			{card => $card->id})->[0] or return $e->event;
+		$patron = $e->search_actor_user([ 
+			{card => $card->id}, $flesh])->[0] or return $e->event;
 
 	} else {
 		if( my $copy = $self->copy ) {
@@ -686,7 +691,7 @@ sub mk_env {
 				{target_copy => $copy->id, checkin_time => undef});
 
 			if( my $circ = $circs->[0] ) {
-				$patron = $e->retrieve_actor_user($circ->usr)
+				$patron = $e->retrieve_actor_user([$circ->usr, $flesh])
 					or return $e->event;
 			}
 		}
@@ -694,6 +699,23 @@ sub mk_env {
 
     return $self->bail_on_events(OpenILS::Event->new('ACTOR_USER_NOT_FOUND'))
         unless $self->patron($patron) or $self->is_checkin;
+
+    unless($self->is_checkin) {
+
+        # Check for inactivity and patron reg. expiration
+
+        $self->bail_on_events(OpenILS::Event->new('PATRON_INACTIVE'))
+			unless $U->is_true($patron->active);
+	
+		$self->bail_on_events(OpenILS::Event->new('PATRON_CARD_INACTIVE'))
+			unless $U->is_true($patron->card->active);
+	
+		my $expire = DateTime::Format::ISO8601->new->parse_datetime(
+			cleanse_ISO8601($patron->expire_date));
+	
+		$self->bail_on_events(OpenILS::Event->new('PATRON_ACCOUNT_EXPIRED'))
+			if( CORE::time > $expire->epoch ) ;
+    }
 }
 
 # --------------------------------------------------------------------------