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:
parent
484c1f6dea
commit
d39262e61d
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue