From a047e4dd6556ce9876d02afe7731c1a0817cf3c0 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Fri, 28 Feb 2014 09:44:40 -0500
Subject: [PATCH] Bug 11872 - Lost overdue items should not generate fines

An item can be marked as lost by longoverdue.pl, but left checked out to
the patron. In this case, the item will continue to accrue fines.

Test Plan:
1) Check out an item and back date it so it is overdue and should
   generate fines.
2) Mark the item as lost by either using longoverdue.pl, or just
   by setting itemlost to 1 by directly accessing the database
3) Run fines.pl
4) Note the overdue generated a fine
5) Repeat steps 1-2
6) Apply this patch
7) Run fines.pl
8) Note a fine was not generated
---
 C4/Overdues.pm |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/C4/Overdues.pm b/C4/Overdues.pm
index 33dbd98..a71fb7d 100644
--- a/C4/Overdues.pm
+++ b/C4/Overdues.pm
@@ -93,6 +93,8 @@ overdue items. It is primarily used by the 'misc/fines2.pl' script.
 
 Returns the list of all overdue books, with their itemtype.
 
+This list does not include overdue items that are marked lost
+
 C<$overdues> is a reference-to-array. Each element is a
 reference-to-hash whose keys are the fields of the issues table in the
 Koha database.
@@ -110,6 +112,7 @@ sub Getoverdues {
      FROM issues 
 LEFT JOIN items       USING (itemnumber)
     WHERE date_due < NOW()
+      AND itemlost = 0
 ";
     } else {
         $statement = "
@@ -118,6 +121,7 @@ LEFT JOIN items       USING (itemnumber)
 LEFT JOIN items       USING (itemnumber)
 LEFT JOIN biblioitems USING (biblioitemnumber)
     WHERE date_due < NOW()
+      AND itemlost = 0
 ";
     }
 
-- 
1.7.2.5