}
sub generate_fines {
- my ($class, $conn, $args) = @_;
+ my ($class, $args) = @_;
my $circs = $args->{circs};
return unless $circs and @$circs;
my $e = $args->{editor};
+ # if a client connection is passed in, this will be chatty like
+ # the old storage version
+ my $conn = $args->{conn};
my $commit = 0;
unless ($e) {
$fine_interval = interval_to_seconds( $fine_interval );
if ( $fine_interval == 0 || int($c->$recurring_fine_method * 100) == 0 || int($c->max_fine * 100) == 0 ) {
- $conn->respond( "Fine Generator skipping circ due to 0 fine interval, 0 fine rate, or 0 max fine.\n" );
+ $conn->respond( "Fine Generator skipping circ due to 0 fine interval, 0 fine rate, or 0 max fine.\n" ) if $conn;
$logger->info( "Fine Generator skipping circ " . $c->id . " due to 0 fine interval, 0 fine rate, or 0 max fine." );
return;
}
"ARG! Overdue $ctype ".$c->id.
" for item ".$c->$target_copy_method.
" (user ".$c->usr.").\n".
- "\tItem was due on or before: ".localtime($due)."\n");
+ "\tItem was due on or before: ".localtime($due)."\n") if $conn;
my @fines = @{$e->search_money_billing(
{ xact => $c->id,
my $last_fine;
if ($fine) {
- $conn->respond( "Last billing time: ".$fine->billing_ts." (clensed format: ".cleanse_ISO8601( $fine->billing_ts ).")");
+ $conn->respond( "Last billing time: ".$fine->billing_ts." (clensed format: ".cleanse_ISO8601( $fine->billing_ts ).")") if $conn;
$last_fine = $parser->parse_datetime( cleanse_ISO8601( $fine->billing_ts ) )->epoch;
} else {
$logger->info( "Potential first billing for circ ".$c->id );
&& $grace_period # and we have a grace period
&& $now < $due + $grace_period # and some date math says were are within the grace period
) {
- $conn->respond( "Still inside grace period of: ". seconds_to_interval( $grace_period )."\n" );
+ $conn->respond( "Still inside grace period of: ". seconds_to_interval( $grace_period )."\n" ) if $conn;
$logger->info( "Circ ".$c->id." is still inside grace period of: $grace_period [". seconds_to_interval( $grace_period ).']' );
return;
}
- $conn->respond( "\t$pending_fine_count pending fine(s)\n" );
+ $conn->respond( "\t$pending_fine_count pending fine(s)\n" ) if $conn;
return unless ($pending_fine_count);
my $recurring_fine = int($c->$recurring_fine_method * 100);
$conn->respond(
"\tMaximum fine level of ".$c->max_fine.
" reached for this $ctype.\n".
- "\tNo more fines will be generated.\n" );
+ "\tNo more fines will be generated.\n" ) if $conn;
last;
}
}
$conn->respond( "\t\tAdding fines totaling $latest_amount for overdue up to $latest_billing_ts\n" )
- if ($latest_billing_ts and $latest_amount);
+ if ($conn and $latest_billing_ts and $latest_amount);
# $self->method_lookup('open-ils.storage.transaction.commit')->run;
if ($@) {
my $e = $@;
- $conn->respond( "Error processing overdue $ctype [".$c->id."]:\n\n$e\n" );
+ $conn->respond( "Error processing overdue $ctype [".$c->id."]:\n\n$e\n" ) if $conn;
$logger->error("Error processing overdue $ctype [".$c->id."]:\n$e\n");
# $self->method_lookup('open-ils.storage.transaction.rollback')->run;
last if ($e =~ /IS NOT CONNECTED TO THE NETWORK/o);