From 2ba2c3bf0c3fe3bcccd242fa435d589fe0847bf3 Mon Sep 17 00:00:00 2001 From: blake Date: Mon, 18 Apr 2016 16:25:46 -0500 Subject: [PATCH] LP1534283 SIP prevents renewal when user has any blocking standing penalties This code dives into each penalty to investigate weather or not the patron can renew based on the block list column. Before, SIP would block renewals with the presence of penalty 1 or 2 regardless. Signed-off-by: blake Signed-off-by: Mike Rylander --- Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm | 42 ++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index ad64b61b3c..08450841ba 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -354,12 +354,46 @@ sub charge_ok { $u->card->active eq 't'; } - - -# How much more detail do we need to check here? sub renew_ok { my $self = shift; - return $self->charge_ok; + my $u = $self->{user}; + my $e = $self->{editor}; + my $renew_block_penalty = 'f'; + + # compute expiration date for borrowing privileges + my $expire = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($u->expire_date)); + + # if barred or expired, forget it and save us the CPU + return 0 if(($u->barred eq 't') or (CORE::time > $expire->epoch)); + + # flesh penalties so we can look close at the block list + my $penalty_flesh = { + flesh => 2, + flesh_fields => { + au => [ + "standing_penalties", + ], + ausp => [ + "standing_penalty", + ], + csp => [ + "block_list", + ], + } + }; + my $user = $e->retrieve_actor_user([ $u->id, $penalty_flesh ]); + foreach( @{ $user->standing_penalties } ) + { + # archived penalty - ignore + next if ( $_->stop_date && ( CORE::time > DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($_->stop_date))->epoch ) ); + # check to see if this penalty blocks renewals + $renew_block_penalty = 't' if $_->standing_penalty->block_list =~ /RENEW/; + } + + return + $u->active eq 't' && + $u->card->active eq 't' && + $renew_block_penalty eq 'f'; } sub recall_ok { -- 2.11.0