Whitespace. gah.
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Penalty.pm
1 package OpenILS::Application::Penalty;
2 use strict; use warnings;
3 use OpenSRF::EX qw(:try);
4 use OpenILS::Application;
5 use OpenILS::Utils::Penalty;
6 use OpenILS::Utils::CStoreEditor qw/:funcs/;
7 use base 'OpenILS::Application';
8
9 __PACKAGE__->register_method (
10         method   => 'patron_penalty',
11         api_name         => 'open-ils.penalty.patron_penalty.calculate',
12         signature => q/
13                 Calculates the patron's standing penalties
14                 @param args An object of named params including:
15                         patronid The id of the patron
16                         update True if this call should update the database
17                         background True if this call should return immediately,
18                                 then go on to process the penalties.  This flag
19                                 works only in conjunction with the 'update' flag.
20                 @return An object with keys 'fatal_penalties' and 
21                 'info_penalties' who are themeselves arrays of 0 or 
22                 more penalties.  Returns event on error.
23         /
24 );
25
26 # --------------------------------------------------------------
27 # if $args->{background} is true, immediately respond complete 
28 # to the caller, then finish the calculation
29 # --------------------------------------------------------------
30 sub patron_penalty {
31         my( $self, $conn, $args ) = @_;
32         $conn->respond_complete(1) if $$args{background};
33     my $e = new_editor(xact => 1);
34     OpenILS::Utils::Penalty->calculate_penalties($e, $args->{patronid}, $args->{context_org});
35     my $p = OpenILS::Utils::Penalty->retrieve_penalties($e, $args->{patronid}, $args->{context_org});
36     $e->commit;
37     return $p
38 }
39
40
41 1;