added some sanity checks, moved patron error event checks to end of script builder...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Sep 2006 21:08:13 +0000 (21:08 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Sep 2006 21:08:13 +0000 (21:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6199 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm
Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm

index b46234a..9d1a8fe 100644 (file)
@@ -179,23 +179,6 @@ sub fetch_user_data {
 
        return undef unless my $patron = $ctx->{patron};
 
-       unless( $ctx->{ignore_user_status} ) {
-               return OpenILS::Event->new('PATRON_INACTIVE')
-                       unless $U->is_true($patron->active);
-       
-               $patron->card($e->retrieve_actor_card($patron->card))
-                       unless ref $patron->card;
-       
-               return OpenILS::Event->new('PATRON_CARD_INACTIVE')
-                       unless $U->is_true($patron->card->active);
-       
-               my $expire = DateTime::Format::ISO8601->new->parse_datetime(
-                       clense_ISO8601($patron->expire_date));
-       
-               return OpenILS::Event->new('PATRON_ACCOUNT_EXPIRED')
-                       if( CORE::time > $expire->epoch ) ;
-       }
-
        $patron->home_ou( 
                $e->retrieve_actor_org_unit($patron->home_ou) ) 
                unless ref $patron->home_ou;
@@ -224,12 +207,6 @@ sub fetch_user_data {
 
        $ctx->{requestor} = $ctx->{requestor} || $e->requestor;
 
-       # this could alter the requestor object within the editor..
-       #if( my $req = $ctx->{requestor} ) {
-       #       $req->home_ou( $e->retrieve_actor_org_unit($requestor->home_ou) );      
-       #       $req->ws_ou( $e->retrieve_actor_org_unit($requestor->ws_ou) );  
-       #}
-
        if( $ctx->{fetch_patron_circ_info} ) {
                my $circ_counts = 
                        OpenILS::Application::Actor::_checked_out(1, $e, $patron->id);
@@ -240,17 +217,27 @@ sub fetch_user_data {
        }
 
        if( $ctx->{fetch_patron_money_info} ) {
-               # Grab the fines
-#              my $fxacts = $e->search_money_billable_transaction_summary(
-#                      { usr => $patron->id, balance_owed => { "!=" => 0 }, xact_finish => undef });
-#
-#              my $fines = 0;
-#              $fines += $_->balance_owed for @$fxacts;
-#              $ctx->{patronFines} = $fines;
                $ctx->{patronFines} = $U->patron_money_owed($patron->id);
                $logger->debug("script_builder: patron fines determined to be ".$ctx->{patronFines});
        }
 
+       unless( $ctx->{ignore_user_status} ) {
+               return OpenILS::Event->new('PATRON_INACTIVE')
+                       unless $U->is_true($patron->active);
+       
+               $patron->card($e->retrieve_actor_card($patron->card))
+                       unless ref $patron->card;
+       
+               return OpenILS::Event->new('PATRON_CARD_INACTIVE')
+                       unless $U->is_true($patron->card->active);
+       
+               my $expire = DateTime::Format::ISO8601->new->parse_datetime(
+                       clense_ISO8601($patron->expire_date));
+       
+               return OpenILS::Event->new('PATRON_ACCOUNT_EXPIRED')
+                       if( CORE::time > $expire->epoch ) ;
+       }
+
        return undef;
 }
 
@@ -350,6 +337,7 @@ sub has_common_ancestor {
 sub find_parent_at_depth {
        my $org = shift;
        my $depth = shift;
+       return undef unless $org and $depth;
        fetch_ou_types();
        do {
                my ($t) = grep { $_->id == $org->ou_type } @OU_TYPES;
index 13b6a88..4264399 100644 (file)
@@ -120,11 +120,12 @@ sub load_scripts {
 sub check_age_protect {
        my( $patron, $copy ) = @_;
 
-       return undef unless $copy->age_protect;
+       return undef unless $copy and $copy->age_protect and $patron;
+
+       my $hou = (ref $patron->home_ou) ? $patron->home_ou->id : $patron->home_ou;
 
        my $prox = $U->storagereq(
-               'open-ils.storage.asset.copy.proximity', 
-               $copy->id, $patron->home_ou->id );
+               'open-ils.storage.asset.copy.proximity', $copy->id, $hou );
 
        # If this copy is within the appropriate proximity, 
        # age protect does not apply