koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4/Circulation Fines.pm [rel_2_2]


From: Ryan Higgins
Subject: [Koha-cvs] koha/C4/Circulation Fines.pm [rel_2_2]
Date: Fri, 06 Apr 2007 04:46:28 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_2_2
Changes by:     Ryan Higgins <rych>     07/04/06 04:46:28

Modified files:
        C4/Circulation : Fines.pm 

Log message:
        add another fine calc routine

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Fines.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.9.2.3&r2=1.9.2.4

Patches:
Index: Fines.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Fines.pm,v
retrieving revision 1.9.2.3
retrieving revision 1.9.2.4
diff -u -b -r1.9.2.3 -r1.9.2.4
--- Fines.pm    3 Aug 2006 03:22:21 -0000       1.9.2.3
+++ Fines.pm    6 Apr 2007 04:46:28 -0000       1.9.2.4
@@ -1,6 +1,6 @@
 package C4::Circulation::Fines;
 
-# $Id: Fines.pm,v 1.9.2.3 2006/08/03 03:22:21 kados Exp $
+# $Id: Fines.pm,v 1.9.2.4 2007/04/06 04:46:28 rych Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -48,7 +48,7 @@
 =cut
 
 @ISA = qw(Exporter);
address@hidden = qw(&Getoverdues &CalcFine &BorType &UpdateFine 
&ReplacementCost);
address@hidden = qw(&Getoverdues &CalcFine &OverdueCharge &BorType &UpdateFine 
&ReplacementCost);
 
 =item Getoverdues
 
@@ -131,29 +131,23 @@
 =cut
 #'
 sub CalcFine {
-  my ($itemnumber,$bortype,$difference)address@hidden;
+  my ($itemnumber,$bortype,$difference,$branchcode)address@hidden;
   my $dbh = C4::Context->dbh;
 
-  # Look up the categoryitem record for this book's item type and the
-  # given borrwer type.
-  # The reason this query is so messy is that it's a messy question:
-  # given the barcode, we can find the book's items record. This gives
-  # us the biblioitems record, which gives us a set of categoryitem
-  # records. Then we select the one that corresponds to the desired
-  # borrower type.
-
   # FIXME - Is it really necessary to get absolutely everything from
   # all four tables? It looks as if this code only wants
   # firstremind, chargeperiod, accountsent, and chargename from the
   # categoryitem table.
 
+  $branchcode = '' unless ($branchcode);
   my $sth=$dbh->prepare("Select * from 
items,biblioitems,itemtypes,issuingrules where items.itemnumber=?
   and items.biblioitemnumber=biblioitems.biblioitemnumber and
   biblioitems.itemtype=itemtypes.itemtype and
   issuingrules.itemtype=itemtypes.itemtype and
+  issuingrules.branchcode=? and
   issuingrules.categorycode=? and (items.itemlost <> 1 or items.itemlost is 
NULL)");
 
-  $sth->execute($itemnumber,$bortype);
+  $sth->execute($itemnumber,$branchcode,$bortype);
   my $data=$sth->fetchrow_hashref;
        # FIXME - Error-checking: the item might be lost, or there
        # might not be an entry in 'categoryitem' for this item type
@@ -199,6 +193,55 @@
   return($amount,$data->{'chargename'},$printout);
 }
 
+=item OverdueCharge
+
+  ($amount) =
+    &OverdueCharge($itemnumber, $borrowercode, $days_overdue, $branchcode);
+
+       Calculates fine if firstremind is taken as grace period and 
chargeperiod is frequency
+       of charge thereafter.  This is CalcFine the way most US libraries would 
expect it to work.:  
+
+=cut
+#'
+
+sub OverdueCharge {
+  my ($itemnumber,$bortype,$difference,$branchcode)address@hidden;
+  my $dbh = C4::Context->dbh;
+
+  $branchcode = '' unless ($branchcode);
+
+  my $sth=$dbh->prepare("Select issuingrules.* from 
items,biblioitems,itemtypes,issuingrules where items.itemnumber=?
+  and items.biblioitemnumber=biblioitems.biblioitemnumber and
+  biblioitems.itemtype=itemtypes.itemtype and
+  issuingrules.itemtype=itemtypes.itemtype and
+  issuingrules.branchcode=? and
+  issuingrules.categorycode=? and (items.itemlost <> 1 or items.itemlost is 
NULL)");
+
+ $sth->execute($itemnumber,$bortype, $branchcode);
+  my $data=$sth->fetchrow_hashref;
+    # FIXME - Error-checking: the item might be lost, or there
+    # might not be an entry in 'categoryitem' for this item type
+    # or borrower type.
+  $sth->finish;
+  my $amount=0;
+
+  #  firstremind is actually the first day to apply fines (length of grace 
period)
+  #
+$difference--;   # we start the day _after_ due date.  difference == 0 if the 
item is due today.
+my $grace = $data->{'firstremind'} + 0;
+my $per = $data->{'chargeperiod'} + 0;
+
+ if ($difference < $grace) {
+    return(0,'','');
+  } elsif ($difference == $grace){
+    $amount=$data->{'fine'};
+  } elsif ( ($difference - $grace) % $per == 0) {
+    $amount = $data->{'fine'} * ($difference - $grace) / $per;
+  }
+  return($amount);
+}
+
+
 =item UpdateFine
 
   &UpdateFine($itemnumber, $borrowernumber, $amount, $type, $description);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]