[Patches] [PATCH] [SIGNED-OFF] Bug 6987 Make return from Overdues::GetFine

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Sat Nov 5 04:35:03 NZDT 2011


From: Colin Campbell <colin.campbell at ptfs-europe.com>
Date: Fri, 7 Oct 2011 13:19:06 +0100
Subject: [PATCH] [SIGNED-OFF] 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 at biblibre.com>
---
 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.5.4




More information about the Patches mailing list