If there is not a fine amount return zero not
undefined or other undefined behaviour
Use more meaningful var names for readability
---
C4/Overdues.pm | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/C4/Overdues.pm b/C4/Overdues.pm
index 9f4b22f..898d538 100644
--- a/C4/Overdues.pm
+++ b/C4/Overdues.pm
@@ -644,13 +644,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;
}
--
1.7.6.4
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/