From: miker Date: Fri, 22 Jan 2010 20:03:56 +0000 (+0000) Subject: correct billing timestamp and count calculation issues introduced by 1.6.0.0 "push... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c6fa98e239f2d80de6bd5a22d6eab9e00199c3dd;p=Evergreen.git correct billing timestamp and count calculation issues introduced by 1.6.0.0 "push day-granular circs to end of calendar day" trigger git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@15366 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 8106dd97c7..2663a2acdc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -625,7 +625,7 @@ sub generate_fines { $fine_interval =~ s/(\d{2}):(\d{2}):(\d{2})/$1 h $2 m $3 s/o; $fine_interval = interval_to_seconds( $fine_interval ); - if ( $fine_interval >= interval_to_seconds('1d') ) { + if ( 0 and $fine_interval >= interval_to_seconds('1d') ) { my $tz_offset_s = 0; if ($due_dt->strftime('%z') =~ /(-|\+)(\d{2}):?(\d{2})/) { $tz_offset_s = $1 . interval_to_seconds( "${2}h ${3}m"); @@ -699,20 +699,24 @@ sub generate_fines { } } + next if ($last_fine > $now); + my $pending_fine_count = int( ($now - $last_fine) / $fine_interval ); - my $pending_fine_count = int( ($now - $last_fine) / $fine_interval ); - if ($pending_fine_count < 1 + $grace) { - $client->respond( "\tNo fines to create. " ); - if ($grace && $now < $due + $fine_interval * $grace) { - $client->respond( "Still inside grace period of: ". seconds_to_interval( $fine_interval * $grace)."\n" ); - $log->info( "Circ ".$c->id." is still inside grace period of: $grace [". seconds_to_interval( $fine_interval * $grace).']' ); - } else { - $client->respond( "Last fine generated for: ".localtime($last_fine)."\n" ); - } - next; - } - - $client->respond( "\t$pending_fine_count pending fine(s)\n" ); + # Generate fines for the interval we are currently inside, when the fine interval is some multiple of 1d + $pending_fine_count++ if ($fine_interval && ($fine_interval % 86400 == 0)); + + if ( $last_fine == $due # we have no fines yet + && $grace # and we have a grace period + && $pending_fine_count <= $grace # and we seem to be inside that period + && $now < $due + $fine_interval * $grace # and some date math bares that out, then + ) { + $client->respond( "Still inside grace period of: ". seconds_to_interval( $fine_interval * $grace)."\n" ); + $log->info( "Circ ".$c->id." is still inside grace period of: $grace [". seconds_to_interval( $fine_interval * $grace).']' ); + next; + } + + $client->respond( "\t$pending_fine_count pending fine(s)\n" ); + next unless ($pending_fine_count); my $recuring_fine = int($c->recuring_fine * 100); my $max_fine = int($c->max_fine * 100);