@@ -, +, @@ --- C4/Overdues.pm | 11 +++++++++-- misc/cronjobs/staticfines.pl | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) --- a/C4/Overdues.pm +++ a/C4/Overdues.pm @@ -655,9 +655,16 @@ sub GetFine { my $dbh = C4::Context->dbh(); my $query = q|SELECT sum(amountoutstanding) as fineamount FROM accountlines where accounttype like 'F%' - AND amountoutstanding > 0 AND itemnumber = ? AND borrowernumber=?|; + AND amountoutstanding > 0 AND borrowernumber=?|; + my @query_param; + push @query_param, $borrowernumber; + if (defined $itemnum ) + { + $query .= " AND itemnumber=?"; + push @query_param, $itemnum; + } my $sth = $dbh->prepare($query); - $sth->execute( $itemnum, $borrowernumber ); + $sth->execute( @query_param ); my $fine = $sth->fetchrow_hashref(); if ($fine->{fineamount}) { return $fine->{fineamount}; --- a/misc/cronjobs/staticfines.pl +++ a/misc/cronjobs/staticfines.pl @@ -196,7 +196,7 @@ for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { $amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}}); # We check if there is already a fine for the given borrower - my $fine = GetFine($data->[$i]->{'borrowernumber'}); + my $fine = GetFine(undef, $data->[$i]->{'borrowernumber'}); if ($fine > 0) { $debug and warn "There is already a fine for borrower " . $data->[$i]->{'borrowernumber'} . ". Nothing to do here. Skipping this borrower"; next; --