Bug 13841 - Returns via backdating or SIP2 can create new fines with an amount outstanding of 0
Due to the way AddReturn and UpdateFine work, if you pass in a return date to AddReturn, and that item has a calculated fine of 0, Koha will insert the 0 amount fine into accountlines. This is good behavior when we want to update an existing fine, but bad behavior if there was no fine to begin with! Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Circulation.t 3) Note the test fails 4) Apply this patch 5) prove t/db_dependent/Circulation.t 6) Note the test passes Signed-off-by: Jen DeMuth <jdemuth@roseville.ca.us> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Confirmed the problem in the staff interface and that the patch fixes it. Also tested that fines still get calculated. Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
589fd84107
commit
faab00b88a
1 changed files with 17 additions and 22 deletions
|
@ -580,23 +580,17 @@ sub UpdateFine {
|
|||
# print "no update needed $data->{'amount'}"
|
||||
}
|
||||
} else {
|
||||
if ( $amount ) { # Don't add new fines with an amount of 0
|
||||
my $sth4 = $dbh->prepare(
|
||||
"SELECT title FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?"
|
||||
);
|
||||
$sth4->execute($itemnum);
|
||||
my $title = $sth4->fetchrow;
|
||||
|
||||
# # print "not in account";
|
||||
# my $sth3 = $dbh->prepare("Select max(accountno) from accountlines");
|
||||
# $sth3->execute;
|
||||
#
|
||||
# # FIXME - Make $accountno a scalar.
|
||||
# my @accountno = $sth3->fetchrow_array;
|
||||
# $sth3->finish;
|
||||
# $accountno[0]++;
|
||||
# begin transaction
|
||||
my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
|
||||
|
||||
my $desc = ( $type ? "$type " : '' ) . "$title $due"; # FIXEDME, avoid whitespace prefix on empty $type
|
||||
|
||||
my $query = "INSERT INTO accountlines
|
||||
(borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno)
|
||||
VALUES (?,?,now(),?,?,'FU',?,?,?)";
|
||||
|
@ -604,6 +598,7 @@ sub UpdateFine {
|
|||
$debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n";
|
||||
$sth2->execute( $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno );
|
||||
}
|
||||
}
|
||||
# logging action
|
||||
&logaction(
|
||||
"FINES",
|
||||
|
|
Loading…
Reference in a new issue