From f1af1db21d61972f0e6a7b0c5ebd6630569a827d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 3 Apr 2013 13:05:52 -0400 Subject: [PATCH] Bug 8770 - amount does not equal amountoutstanding on a fine with no payments or credits If a lost item fee is owed and partially paid off when an item is returned and a refund is processed, Koha tries to pay off existing fees before adding any leftover balance as a credit on the account. However, those fee payments aren't actually processed, due to a bug where the accountnumber was quoted as a string literal, and thus the for the fee payment would fail. This did not result in an DB error, as the query was still valid SQL. Checking the return value of the query would have revealed that the accountline had not been updated. History: This bug was introduced on April 23, 2007 with the commit 'reintroducing fixaccountforlostandreturned as requested by rosalie'. Commit id 111d590e9cdaf801256822e23f170bfc2365338f On July 30, 2009 the error was flagged with a FIXME and remained in that state until now. Commit id 51e8fc2cb6a0cf79f19206c822a4361aeca6f63f Test plan: 1) Create a test patron 2) Check out an item to that patron and give it a due date in the past 3) Run fines.pl to generate the fine for the item 4) Mark the item long overdue on the item tab (not in edit items) 5) Pay for the lost item 6) Check the item back in 7) Note the incorrect fines. Only the lost fee balance due is refunded, not the entire lost fee, but no other fees are paid off. 8) Apply the patch 9) Repeat steps 1-6, then not the fines are paid correctly Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Totel due is correct after applying the patch. All tests and QA script pass. Signed-off-by: Galen Charlton --- C4/Circulation.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f3c5808af2..3fc124f811 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2171,7 +2171,7 @@ sub _FixAccountForLostAndReturned { # FIXME: move prepares outside while loop! my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ? WHERE (accountlines_id = ?)"); - $usth->execute($newamtos,'$thisacct'); # FIXME: '$thisacct' is a string literal! + $usth->execute($newamtos,$thisacct); $usth = $dbh->prepare("INSERT INTO accountoffsets (borrowernumber, accountno, offsetaccount, offsetamount) VALUES -- 2.39.5