From: erickson Date: Tue, 13 Jan 2009 17:44:05 +0000 (+0000) Subject: return penalty objects from retrieve_penalties. flesh the event desc with the penalt... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a6f766bb81b7331ad885387460a90c3d4c52d111;p=Evergreen.git return penalty objects from retrieve_penalties. flesh the event desc with the penalty label for circ panelaties. to reduce overhead, call the local penalty calculater from the fine generator git-svn-id: svn://svn.open-ils.org/ILS/trunk@11814 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 58ad5875e8..acdef5736d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -1110,9 +1110,24 @@ sub patron_adv_search { my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; return $e->event unless $e->allowed('VIEW_USER'); - return $U->storagereq( + + my $bcids = []; + if(my $bc = $$search_hash{card}{value}) { + $bcids = $e->json_query({ + select => {ac => ['usr']}, + from => {ac => {au => {field => 'id', fkey => 'usr'}}}, + where => {'+ac' => {barcode => {like => "$bc%"}, active => 't'}, '+au' => {deleted => 'f'}} + }); + $bcids = map [ {$_->{usr} ] @$bcids; + } + + my $ids = $U->storagereq( "open-ils.storage.actor.user.crazy_search", $search_hash, $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_depth); + + my %h; # dedup + $h{$_} = 1 for (@$bcids, $ids); + return [keys %h]; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index ba675b588a..f50001584b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -1064,18 +1064,6 @@ sub fetch_user_by_barcode { } - -# --------------------------------------------------------------------- -# Updates and returns the patron penalties -# --------------------------------------------------------------------- -sub update_patron_penalties_nonblock { - my( $self, %args ) = @_; - return $self->simplereq( - 'open-ils.penalty', - 'open-ils.penalty.patron_penalty.calculate', {background => 1} - ); -} - sub fetch_bill { my( $self, $billid ) = @_; $logger->debug("Fetching billing $billid"); @@ -1085,8 +1073,6 @@ sub fetch_bill { return($bill, $evt); } - - my $ORG_TREE; sub fetch_org_tree { my $self = shift; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 24f7fd8b75..0fccc00107 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -838,7 +838,13 @@ sub run_patron_permit_scripts { my $penalties = OpenILS::Utils::Penalty->retrieve_penalties($self->editor, $patronid, $self->circ_lib, $mask); $penalties = $penalties->{fatal_penalties}; - push(@allevents, OpenILS::Event->new($_)) for (@$penalties, @$patron_events); + for my $pen (@$penalties) { + my $event = OpenILS::Event->new($pen->name); + $event->{desc} = $pen->label; + push(@allevents, $event); + } + + push(@allevents, OpenILS::Event->new($_)) for (@$patron_events); } $logger->info("circulator: permit_patron script returned events: @allevents") if @allevents; 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 439b88923c..2e0119cd50 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -8,6 +8,7 @@ use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::PermitHold; use DateTime; use DateTime::Format::ISO8601; +use OpenILS::Penalty; sub isTrue { my $v = shift; @@ -601,7 +602,6 @@ sub generate_fines { my %hoo = map { ( $_->id => $_ ) } actor::org_unit::hours_of_operation->retrieve_all; - my $penalty = OpenSRF::AppSession->create('open-ils.penalty'); for my $c (@circs) { try { @@ -765,13 +765,7 @@ sub generate_fines { $self->method_lookup('open-ils.storage.transaction.commit')->run; - $penalty->request( - 'open-ils.penalty.patron_penalty.calculate', - { patron => $c->usr->to_fieldmapper, - update => 1, - background => 1, - } - )->gather(1); + OpenILS::Utils::Penalty->calculate_penalties(undef, $c->usr, $c->circ_lib); } catch Error with { my $e = shift; diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm b/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm index 86a0a34808..4b42c4ebf0 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm @@ -17,6 +17,12 @@ my $U = "OpenILS::Application::AppUtils"; sub calculate_penalties { my($class, $e, $user_id, $context_org) = @_; + my $rollback = 0; + unless($e) { + $e = new_editor(xact =>1); + $rollback = 1; + } + my $penalties = $e->json_query({from => ['actor.calculate_system_penalties',$user_id, $context_org]}); for my $pen_obj (@$penalties) { @@ -37,6 +43,7 @@ sub calculate_penalties { } } + $e->rollback if $rollback; return undef; } @@ -56,13 +63,13 @@ sub retrieve_penalties { if($p->standing_penalty->block_list) { for my $m (@fatal_mask) { if($p->standing_penalty->block_list =~ /$m/) { - push(@fatal, $p->standing_penalty->name); + push(@fatal, $p->standing_penalty); $pushed = 1; last; } } } - push(@info, $p->standing_penalty->name) unless $pushed; + push(@info, $p->standing_penalty) unless $pushed; } return {fatal_penalties => \@fatal, info_penalties => \@info};