[Koha-patches] [PATCH] Bug 6987 Make return from Overdues::GetFine consistent
Colin Campbell
colin.campbell at ptfs-europe.com
Fri Oct 7 14:25:44 CEST 2011
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
More information about the Koha-patches
mailing list