Merge branch 'bug_9922' into 3.12-master
[koha-ffzg.git] / C4 / Overdues.pm
index ac66c36..bc1c7a7 100644 (file)
@@ -72,10 +72,6 @@ BEGIN {
        push @EXPORT, qw(
         &GetIssuesIteminfo
        );
-    #
-       # &GetIssuingRules - delete.
-       # use C4::Circulation::GetIssuingRule instead.
-       
        # subs to move to Members.pm
        push @EXPORT, qw(
         &CheckBorrowerDebarred
@@ -264,7 +260,11 @@ sub CalcFine {
     my $units_minus_grace = $chargeable_units - $data->{firstremind};
     my $amount = 0;
     if ($data->{'chargeperiod'}  && ($units_minus_grace > 0)  ) {
-        $amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents
+        if ( C4::Context->preference('FinesIncludeGracePeriod') ) {
+            $amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents
+        } else {
+            $amount = int($units_minus_grace / $data->{'chargeperiod'}) * $data->{'fine'};
+        }
     } else {
         # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
     }
@@ -692,41 +692,6 @@ sub GetFine {
     return 0;
 }
 
-
-=head2 GetIssuingRules
-
-FIXME - This sub should be deprecated and removed.
-It ignores branch and defaults.
-
-    $data = &GetIssuingRules($itemtype,$categorycode);
-
-Looks up for all issuingrules an item info 
-
-C<$itemnumber> is a reference-to-hash whose keys are all of the fields
-from the borrowers and categories tables of the Koha database. Thus,
-
-C<$categorycode> contains  information about borrowers category 
-
-C<$data> contains all information about both the borrower and
-category he or she belongs to.
-=cut 
-
-sub GetIssuingRules {
-       warn "GetIssuingRules is deprecated: use GetIssuingRule from C4::Circulation instead.";
-   my ($itemtype,$categorycode)=@_;
-   my $dbh   = C4::Context->dbh();    
-   my $query=qq|SELECT *
-        FROM issuingrules
-        WHERE issuingrules.itemtype=?
-            AND issuingrules.categorycode=?
-        |;
-    my $sth = $dbh->prepare($query);
-    #  print $query;
-    $sth->execute($itemtype,$categorycode);
-    return $sth->fetchrow_hashref;
-}
-
-
 sub ReplacementCost2 {
     my ( $itemnum, $borrowernumber ) = @_;
     my $dbh   = C4::Context->dbh();