[Koha-patches] [PATCH] Fixes bug 5216: returning lost material with forgive fines does not forgive overdues

Nicole Engard nengard at bywatersolutions.com
Wed Sep 29 07:50:04 CEST 2010


From: Ian Walls <ian.walls at bywatersolutions.com>

Modifies _FixAccountforLostandReturn to return the borrowernumber of the patron who has had the Lost bill removed from
their account.  This borrowernumber, if it exists, is then used for the rest of the AddReturn subroutine if it was not
defined before.  This includes the subroutine that forgives overdues, as well as the UpdateStats call.

Signed-off-by: Nicole Engard <nengard at bywatersolutions.com>
---
 C4/Circulation.pm |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 034a8d6..931e56d 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -1520,7 +1520,11 @@ sub AddReturn {
 
     # fix up the accounts.....
     if ($item->{'itemlost'}) {
-        _FixAccountForLostAndReturned($item->{'itemnumber'}, $borrowernumber, $barcode);    # can tolerate undef $borrowernumber
+        my $lostborrower = _FixAccountForLostAndReturned($item->{'itemnumber'}, $borrowernumber, $barcode);    # can tolerate undef $borrowernumber
+        # if a borrower was charged, and now forgiven, for this item, fill in $borrowernumber so overdues can be removed
+        if ($lostborrower && !$borrowernumber) {
+            $borrowernumber = $lostborrower;
+        }
         $messages->{'WasLost'} = 1;
     }
 
@@ -1704,12 +1708,14 @@ sub _FixOverduesOnReturn {
 
 =head2 _FixAccountForLostAndReturned
 
-  &_FixAccountForLostAndReturned($itemnumber, [$borrowernumber, $barcode]);
+  $lostborrower = &_FixAccountForLostAndReturned($itemnumber, [$borrowernumber, $barcode]);
 
 Calculates the charge for a book lost and returned.
 
 Internal function, not exported, called only by AddReturn.
 
+Returns the borrowernumber associated with Lost fee that is removed, if such a number exists
+
 FIXME: This function reflects how inscrutable fines logic is.  Fix both.
 FIXME: Give a positive return value on success.  It might be the $borrowernumber who received credit, or the amount forgiven.
 
@@ -1788,7 +1794,7 @@ sub _FixAccountForLostAndReturned {
         $usth->execute($borrowernumber, $data->{'accountno'}, $nextaccntno, $offset);
     }
     ModItem({ paidfor => '' }, undef, $itemnumber);
-    return;
+    return $data->{'borrowernumber'};
 }
 
 =head2 _GetCircControlBranch
-- 
1.5.6.5



More information about the Koha-patches mailing list