From 1a84a9b2603d8cf365376a34b72303b559cc6837 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 15 Sep 2006 15:47:16 +0000 Subject: [PATCH] moving grace day recalc out of the main fine loop -- more correct this way git-svn-id: svn://svn.open-ils.org/ILS/trunk@6118 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/action.pm | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) 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 7ae1a19509..faa3e167eb 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -542,7 +542,33 @@ sub generate_fines { # XXX There is some contention over this ... it basically makes the grace period "hard" (non-fining) #$last_fine += $fine_interval * $grace; } - + + if ($last_fine == $due) { # first time we've billed for this + if (my $h = $hoo{$c->circ_lib}) { + + $due_dt = $due_dt->add( days => 1 ); + + my $dow = $due_td->day_of_week_0; + my $dow_open = "dow_${dow}_open"; + my $dow_close = "dow_${dow}_close"; + + my $count = 0; + while ( $h->$dow_open eq '00:00:00' and $h->$dow_close eq '00:00:00' ) { + + $grace++; + + $due_dt = $due_dt->add( days => 1 ); + $dow = $due_td->day_of_week_0; + $dow_open = "dow_${dow}_open"; + $dow_close = "dow_${dow}_close"; + + $count++; + last if ($count > 6); + } + } + } + + my $pending_fine_count = int( ($now - $last_fine) / $fine_interval ); if ($pending_fine_count < 1 + $grace) { $client->respond( "\tNo fines to create. " ); @@ -581,16 +607,6 @@ sub generate_fines { next if ( $h->$dow_open eq '00:00:00' and $h->$dow_close eq '00:00:00'); } - if ($last_fine eq $due) { # first time we've billed for this - $dow = $billing_ts->subtract( days => 1 )->day_of_week_0(); - $dow_open = "dow_${dow}_open"; - $dow_close = "dow_${dow}_close"; - - if (my $h = $hoo{$c->circ_lib}) { # if the day before now was a closed day, skip today (adding grace) - next if ( $h->$dow_open eq '00:00:00' and $h->$dow_close eq '00:00:00'); - } - } - my $timestamptz = $billing_ts->strftime('%FT%T%z'); my @cl = actor::org_unit::closed_date->search_where( { close_start => { '<=' => $timestamptz }, -- 2.11.0