From 305c676ee2c9f7081ea173d42a021ef9def8e6fc Mon Sep 17 00:00:00 2001 From: Blou Date: Fri, 21 Oct 2016 11:51:12 -0400 Subject: [PATCH] Bug 17483 - Forgiving charge should apply to item's last fine. When returning an item with a fine, if the Forgive checkbox is clicked, this forgives the first accountline associated to the item/user, not the current/latest as it should. Scenario (Real world): - A patron returns a book late, ensuring a 5$ fine. Does not pay it. - The patron borrows the book again 3 months later. Gets late again, and fined 2$. - Great timing: The library offers amnesty for a week. Bring back your book and we'll forget that they're late. - On checkin, the librarian clicks "Forgive overdue charges" and scan the book. - Koha cancels the 3-months-ago 5$ fine. Test scenario: - Find a user with an unpaid fine (accounttype = 'FU' in db) on a returned item. - Checkout the same item for the same user. - CHOICE 1: - Force it being late by modifying the date_due to last year. - Run fines.pl to generate another fine. - CHOICE 2: - Create directly another accountlines entry in the DB with the same info - You may change the amounts to help differentiate - Go to the returns.pl screen, check the Forgive checkbox. Return the item. - Look at the DB, the first line got paid. Not the latest one. - APPLY THE PATCH - Redo scenario, this time the latest entry (by the timestamp column) is paid. --- C4/Circulation.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0cac5ed..faaede7 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2318,7 +2318,7 @@ sub _FixOverduesOnReturn { # check for overdue fine my $sth = $dbh->prepare( -"SELECT * FROM accountlines WHERE (borrowernumber = ?) AND (itemnumber = ?) AND (accounttype='FU' OR accounttype='O')" +"SELECT * FROM accountlines WHERE (borrowernumber = ?) AND (itemnumber = ?) AND (accounttype='FU' OR accounttype='O') order by timestamp desc" ); $sth->execute( $borrowernumber, $item ); -- 2.1.0