Bug 7639: add option to forgive overdue fines when declaring items lost
authorMeenakshi.R <meenakshi.r@osslabs.biz>
Fri, 6 Jul 2012 05:12:50 +0000 (10:42 +0530)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 17 Sep 2013 15:10:46 +0000 (15:10 +0000)
This patch adds functionality to forgive overdue fine when an item is
set to lost status.  Fines are forgiven only when the syspref
WhenLostForgiveFine is set to yes. Item can be set to lost status from:

- catalogue/moredetail.pl
- cataloguing/additem.pl
- tools/batchMod.pl
- misc/cronjobs/longoverdue.pl

Changed subroutine C4::Circulation::LostItem to forgive fines on the
item depending on the value of syspref WhenLostForgiveFine. This
routine is currently used to return an item and charge a replacement
cost.

Also added a new syspref in C4::Circulation::LostItem -
WhenLostChargeReplacementFee.  The replacement fee will now be charged
only if this syspref is set to yes.  The default value of the
WhenLostChargeReplacementFee is yes, meaning that current behavior
will not change during upgrade.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Alex Hatley <alexh@cctexas.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Testing notes on last patch in series.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Circulation.pm
catalogue/updateitem.pl
cataloguing/additem.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
misc/cronjobs/longoverdue.pl
tools/batchMod.pl

index df3245d..16575a4 100644 (file)
@@ -3293,7 +3293,7 @@ sub ReturnLostItem{
 
 
 sub LostItem{
-    my ($itemnumber, $mark_returned, $charge_fee) = @_;
+    my ($itemnumber, $mark_returned) = @_;
 
     my $dbh = C4::Context->dbh();
     my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
@@ -3305,14 +3305,22 @@ sub LostItem{
     my $issues=$sth->fetchrow_hashref();
     $sth->finish;
 
-    # if a borrower lost the item, add a replacement cost to the their record
+    # If a borrower lost the item, add a replacement cost to the their record
     if ( my $borrowernumber = $issues->{borrowernumber} ){
         my $borrower = C4::Members::GetMemberDetails( $borrowernumber );
 
-        C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}")
-          if $charge_fee;
-        #FIXME : Should probably have a way to distinguish this from an item that really was returned.
-        #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
+        if (C4::Context->preference('WhenLostForgiveFine')){
+            my $exemptfine=1;
+            my $dropbox=0;
+            my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, $exemptfine, $dropbox);
+            defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
+        }
+        if (C4::Context->preference('WhenLostChargeReplacementFee')){
+            C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}");
+            #FIXME : Should probably have a way to distinguish this from an item that really was returned.
+            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
+        }
+
         MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned;
     }
 }
index 63514c1..74613e2 100755 (executable)
@@ -74,6 +74,6 @@ if (defined $itemnotes) { # i.e., itemnotes parameter passed from form
 
 ModItem($item_changes, $biblionumber, $itemnumber);
 
-LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $itemlost;
+LostItem($itemnumber, 'MARK RETURNED') if $itemlost;
 
 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
index f2a5ccb..2c9b1c7 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Output;
 use C4::Biblio;
 use C4::Items;
 use C4::Context;
+use C4::Circulation;
 use C4::Koha; # XXX subfield_is_koha_internal_p
 use C4::Branch; # XXX subfield_is_koha_internal_p
 use C4::ClassSource;
@@ -606,6 +607,12 @@ if ($op eq "additem") {
         ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);
         $itemnumber="";
     }
+  my $item = GetItem( $itemnumber );
+    my $olditemlost =  $item->{'itemlost'};
+    my $newitemlost = $itemtosave->subfield('952','1');
+    if (($olditemlost eq '0' or $olditemlost eq '' ) and $newitemlost ge '1'){
+  LostItem($itemnumber,'MARK RETURNED');
+    }
     $nextop="additem";
 } elsif ($op eq "delinkitem"){
     my $analyticfield = '773';
index e8ca401..4b9c492 100644 (file)
@@ -409,6 +409,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('virtualshelves','1','','If ON, enables Lists management','YesNo'),
 ('WaitingNotifyAtCheckin','0',NULL,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.','YesNo'),
 ('WebBasedSelfCheck','0',NULL,'If ON, enables the web-based self-check system','YesNo'),
+('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo'),
+('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo'),
 ('XISBN','0','','Use with FRBRizeEditions. If ON, Koha will use the OCLC xISBN web service in the Editions tab on the detail pages. See: http://www.worldcat.org/affiliate/webservices/xisbn/app.jsp','YesNo'),
 ('XISBNDailyLimit','999','','The xISBN Web service is free for non-commercial use when usage does not exceed 1000 requests per day','Integer'),
 ('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'),
index da78e68..bd3718e 100755 (executable)
@@ -7130,6 +7130,15 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+
+$DBversion = "3.13.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
+    print "Upgrade to $DBversion done (Bug 7639: Added sysprefs WhenLostForgiveFine and WhenLostChargeReplacementFee)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
index 026b7fa..96b6d34 100644 (file)
@@ -507,6 +507,18 @@ Circulation:
                   yes: Include
                   no: "Don't include"
             - the grace period when calculating the fine for an overdue item.
+        -
+            - pref: WhenLostForgiveFine
+              choices:
+                  yes: Forgive
+                  no: "Don't Forgive"
+            - the fines on an item when it is lost.
+        -
+            - pref: WhenLostChargeReplacementFee
+              choices:
+                  yes: Charge
+                  no: "Don't Charge"
+            - the replacement price when a patron loses an item.
     Self Checkout:
         -
             - "Include the following JavaScript on all pages in the web-based self checkout:"
index 159db51..0f64712 100755 (executable)
@@ -165,7 +165,7 @@ foreach my $startrange (sort keys %$lost) {
             printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
             if($confirm) {
                 ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
-                LostItem($row->{'itemnumber'}, $mark_returned, 'CHARGE FEE') if( $charge && $charge eq $lostvalue);
+                LostItem($row->{'itemnumber'}, $mark_returned) if( $charge && $charge eq $lostvalue);
             }
             $count++;
         }
index acb4f0b..1a804d9 100755 (executable)
@@ -189,7 +189,7 @@ if ($op eq "action") {
                        UpdateMarcWith( $marcitem, $localmarcitem );
                        eval{
                             if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) {
-                                LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $item->{itemlost};
+                                LostItem($itemnumber, 'MARK RETURNED') if $item->{itemlost};
                             }
                         };
                    }