From 82162102b6629a901d774d06cdadeae613ca10ba Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 1 Sep 2011 09:13:47 -0400 Subject: [PATCH] Hourly fine periods do not charge enough Hourly fine periods are not charging for the first period of overdue-ness. If an item is due at 2:00pm and has a fine of $.50 per hour, the first fine should be eligible for generation at 2:01pm. As it stands, the first fine does not generate until an entire fine period has elapsed, so in this case, 3:00pm. The previous version of the code had a special case for day- granular fine periods, so a majority of fines were not affected. This commit expands the same idea (charging for the fine period you are currently "in") to all fine periods. Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Storage/Publisher/action.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index d54575db14..6a2b6d6d4d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -12,6 +12,7 @@ use OpenILS::Utils::PermitHold; use DateTime; use DateTime::Format::ISO8601; use OpenILS::Utils::Penalty; +use POSIX qw(ceil); sub isTrue { my $v = shift; @@ -920,10 +921,8 @@ sub generate_fines { } next if ($last_fine > $now); - my $pending_fine_count = int( ($now - $last_fine) / $fine_interval ); - - # 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)); + # Generate fines for each past interval, including the one we are inside + my $pending_fine_count = ceil( ($now - $last_fine) / $fine_interval ); if ( $last_fine == $due # we have no fines yet && $grace_period # and we have a grace period -- 2.43.2