Bug 8939 : Fines being charged during the grace period
authorRobert Williams <williams@amigos.org>
Thu, 18 Oct 2012 00:58:23 +0000 (13:58 +1300)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 26 Oct 2012 15:26:07 +0000 (17:26 +0200)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Overdues.pm

index d17f445..ac66c36 100644 (file)
@@ -263,10 +263,10 @@ sub CalcFine {
     my $chargeable_units = _get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
     my $units_minus_grace = $chargeable_units - $data->{firstremind};
     my $amount = 0;
-    if ($data->{'chargeperiod'}  && $units_minus_grace  ) {
+    if ($data->{'chargeperiod'}  && ($units_minus_grace > 0)  ) {
         $amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents
     } else {
-        # a zero (or null)  chargeperiod means no charge.
+        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
     }
     $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
     $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);