[open-ils-commits] r15368 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jan 22 15:28:33 EST 2010
Author: miker
Date: 2010-01-22 15:28:28 -0500 (Fri, 22 Jan 2010)
New Revision: 15368
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
forward-porting r15367: correct billing timestamp and count calculation issues introduced by 1.6.0.0 "push day-granular circs to end of calendar day" trigger
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2010-01-22 20:23:15 UTC (rev 15367)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2010-01-22 20:28:28 UTC (rev 15368)
@@ -673,7 +673,9 @@
my $target_copy_method = 'target_copy';
my $circ_lib_method = 'circ_lib';
my $recurring_fine_method = 'recurring_fine';
+ my $is_reservation = 0;
if ($ctype eq 'reservation') {
+ $is_reservation = 1;
$due_date_method = 'end_time';
$target_copy_method = 'current_resource';
$circ_lib_method = 'pickup_lib';
@@ -699,7 +701,7 @@
$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 ( $is_reservation 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");
@@ -773,22 +775,26 @@
}
}
+ 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));
- my $recurring_fine = int($c->$recurring_fine_method * 100);
+ 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->$recurring_fine_method * 100);
my $max_fine = int($c->max_fine * 100);
my ($latest_billing_ts, $latest_amount) = ('',0);
More information about the open-ils-commits
mailing list