From 998e68c35184a0d8cb680929fcbb13d656bbb060 Mon Sep 17 00:00:00 2001 From: btoumi Date: Mon, 7 May 2007 14:57:01 +0000 Subject: [PATCH] bug fix : adding condition for create the right notify_id --- C4/Circulation/Fines.pm | 67 +++++++++++++++++++++++------------------ misc/fines.pl | 6 ++-- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/C4/Circulation/Fines.pm b/C4/Circulation/Fines.pm index a825236429..5c1bbf8f8f 100644 --- a/C4/Circulation/Fines.pm +++ b/C4/Circulation/Fines.pm @@ -901,18 +901,22 @@ C<$notify_level> contains the accountline level =cut sub CheckAccountLineLevelInfo { - my($borrowernumber,$itemnumber,$level) = @_; - my $dbh = C4::Context->dbh; - my $query= qq|SELECT count(*) - FROM accountlines - WHERE borrowernumber =? - AND itemnumber = ? - AND notify_level=?|; - my $sth=$dbh->prepare($query); - $sth->execute($borrowernumber,$itemnumber,$level); - my ($exist)=$sth->fetchrow; - $sth->finish; - return($exist); + my($borrowernumber,$itemnumber,$level,$datedue) = @_; + my @formatdate; + @formatdate=split('-',$datedue); + $datedue=$formatdate[2]."/".$formatdate[1]."/".$formatdate[0]; + my $dbh = C4::Context->dbh; + my $query= qq|SELECT count(*) + FROM accountlines + WHERE borrowernumber =? + AND itemnumber = ? + AND notify_level=? + AND description like ?|; + my $sth=$dbh->prepare($query); + $sth->execute($borrowernumber,$itemnumber,$level,"%$datedue%"); + my ($exist)=$sth->fetchrow; + $sth->finish; + return($exist); } =item GetOverduerules @@ -1013,23 +1017,28 @@ C<$date_due> contains the date of item return =cut sub CheckExistantNotifyid { - my($borrowernumber,$date_due) = @_; - my $dbh = C4::Context->dbh; - my $query = qq|SELECT notify_id FROM issues,accountlines - WHERE accountlines.borrowernumber =? - AND issues.itemnumber= accountlines.itemnumber - AND date_due = ?|; - my $sth=$dbh->prepare($query); - $sth->execute($borrowernumber,$date_due); - my ($exist)=$sth->fetchrow; - $sth->finish; - if ($exist eq '') - { - return(0); - }else - { - return($exist); - } + my($borrowernumber,$date_due) = @_; + my $dbh = C4::Context->dbh; + my @formatdate; + @formatdate=split('-',$date_due); + $date_due=$formatdate[2]."/".$formatdate[1]."/".$formatdate[0]; + my $query = qq|SELECT notify_id FROM accountlines + WHERE description like ? + AND borrowernumber =? + AND( accounttype='FU' OR accounttype='F' ) + AND notify_id != 0 + AND notify_id != 1|; + my $sth=$dbh->prepare($query); + $sth->execute("%$date_due%",$borrowernumber); + my ($exist)=$sth->fetchrow; + $sth->finish; + if ($exist eq '') + { + return(0); + }else + { + return($exist); + } } =item CheckAccountLineItemInfo diff --git a/misc/fines.pl b/misc/fines.pl index 2b8a360bf2..fa642f00aa 100755 --- a/misc/fines.pl +++ b/misc/fines.pl @@ -91,7 +91,7 @@ if($delays1 and $delays2 and $delays3) { UpdateFine($data->[$i]->{'itemnumber'},$data->[$i]->{'borrowernumber'},$amount,$type,$due); my $getnotifyid=CheckExistantNotifyid($borrower->{'borrowernumber'},$datedue); - my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},1); + my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},1,$datedue); if ($update eq '0'){ if ($getnotifyid eq '0'){ $starter=GetNextIdNotify($reference,$borrower->{'borrowernumber'}); @@ -118,7 +118,7 @@ if($delays1 and $delays2 and $delays3) { if ($daycount >= $delays2 && $daycount < $delays3){ my $debarred2=GetOverduerules($borrower->{'categorycode'},2); (UpdateBorrowerDebarred($borrower->{'borrowernumber'}))if(($debarred2 eq '1' ) and ($debarredstatus eq '0')); - my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},2); + my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},2,$datedue); if ($update eq '0'){ UpdateAccountLines(undef,2,$borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'}); } @@ -129,7 +129,7 @@ if($delays1 and $delays2 and $delays3) { if ($daycount >= $delays3 ){ my $debarred3=GetOverduerules($borrower->{'categorycode'},3); (UpdateBorrowerDebarred($borrower->{'borrowernumber'}))if(($debarred3 eq '1' ) and ($debarredstatus eq '0')); - my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},3); + my $update=CheckAccountLineLevelInfo($borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'},3,$datedue); if ($update eq '0'){ UpdateAccountLines(undef,3,$borrower->{'borrowernumber'},$data->[$i]->{'itemnumber'}); } -- 2.39.5