Bug 6987 Make return from Overdues::GetFine consistent

If there is not a fine amount return zero not
undefined or other undefined behaviour

Use more meaningful var names for readability

Signed-off-by: Sophie Meynieux <sophie.meynieux@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Colin Campbell 2011-10-07 13:19:06 +01:00 committed by Paul Poulain
parent 484c1f6dea
commit d39262e61d
1 changed files with 8 additions and 5 deletions

View File

@ -643,13 +643,16 @@ C<$borrowernumber> is the borrowernumber
sub GetFine {
my ( $itemnum, $borrowernumber ) = @_;
my $dbh = C4::Context->dbh();
my $query = "SELECT sum(amountoutstanding) FROM accountlines
where accounttype like 'F%'
AND amountoutstanding > 0 AND itemnumber = ? AND borrowernumber=?";
my $query = q|SELECT sum(amountoutstanding) as fineamount FROM accountlines
where accounttype like 'F%'
AND amountoutstanding > 0 AND itemnumber = ? AND borrowernumber=?|;
my $sth = $dbh->prepare($query);
$sth->execute( $itemnum, $borrowernumber );
my $data = $sth->fetchrow_hashref();
return ( $data->{'sum(amountoutstanding)'} );
my $fine = $sth->fetchrow_hashref();
if ($fine->{fineamount}) {
return $fine->{fineamount};
}
return 0;
}