From 2eed36a08edf6b3a782242cde0c2b3836490040b Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Mon, 7 Apr 2008 17:47:48 -0500 Subject: [PATCH] Fix calls to CalcFine, and make fines obey CircControl syspref (get homebranch withssue data). Signed-off-by: Joshua Ferraro --- C4/Overdues.pm | 10 +++++----- misc/cronjobs/fines-ll.pl | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 1e4fd69868..7a9572c46a 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -119,13 +119,13 @@ sub Getoverdues { my $dbh = C4::Context->dbh; my $sth = (C4::Context->preference('item-level_itypes')) ? $dbh->prepare( - "SELECT issues.*,items.itype as itemtype FROM issues + "SELECT issues.*,items.itype as itemtype, items.homebranch FROM issues LEFT JOIN items USING (itemnumber) WHERE date_due < now() ORDER BY borrowernumber " ) : $dbh->prepare( - "SELECT issues.*,biblioitems.itemtype,items.itype FROM issues + "SELECT issues.*,biblioitems.itemtype,items.itype, items.homebranch FROM issues LEFT JOIN items USING (itemnumber) LEFT JOIN biblioitems USING (biblioitemnumber) WHERE date_due < now() @@ -225,7 +225,7 @@ sub CalcFine { my $countalldayclosed = $countspecialday + $countrepeatableday; my $daycount = $difference - $countalldayclosed; # get issuingrules (fines part will be used) - my $data = C4::Circulation::GetIssuingRule($item->{'itemtype'},$bortype,$branchcode); + my $data = C4::Circulation::GetIssuingRule($bortype, $item->{'itemtype'},$branchcode); my $daycounttotal = $daycount - $data->{'firstremind'}; if ($data->{'chargeperiod'} >0) { # if there is a rule for this bortype if ($data->{'firstremind'} < $daycount) @@ -237,7 +237,7 @@ sub CalcFine { # } -# warn "Calc Fine: " . join(", ", ($item->{'itemnumber'}, $bortype, $difference , $data->{'fine'} . " * " . $daycount . " days = \$ " . $amount , "desc: $dues")) ; + # warn "Calc Fine: " . join(", ", ($item->{'itemnumber'}, $bortype, $difference , $data->{'fine'} . " * " . $daycount . " days = \$ " . $amount , "desc: $dues")) ; return ( $amount, $data->{'chargename'}, $printout ,$daycounttotal ,$daycount ); } @@ -801,7 +801,7 @@ C<$level> contains the file level sub CreateItemAccountLine { my ($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level)=@_; my $dbh = C4::Context->dbh; - my $nextaccntno = getnextacctno($borrowernumber); + my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber); my $query= "INSERT into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level) VALUES diff --git a/misc/cronjobs/fines-ll.pl b/misc/cronjobs/fines-ll.pl index ff964ada21..a8d1fc4fb8 100755 --- a/misc/cronjobs/fines-ll.pl +++ b/misc/cronjobs/fines-ll.pl @@ -38,7 +38,8 @@ use C4::Circulation; use C4::Overdues; use Date::Manip qw/Date_DaysSince1BC/; use C4::Biblio; - +#use Data::Dumper; +# my $fldir = "/tmp"; my $libname=C4::Context->preference('LibraryName'); @@ -78,7 +79,7 @@ for (my $i=0;$i[$i]->{'homebranch'}; } elsif ( C4::Context->preference('CircControl') eq 'PatronLibrary' ) { $branchcode = $borrower->{'branchcode'}; - } else { +} else { # CircControl must be PickupLibrary. (branchcode comes from issues table here). $branchcode = $data->[$i]->{'branchcode'}; } @@ -91,13 +92,9 @@ for (my $i=0;$i[$i], $borrower->{'categorycode'}, $branchcode, $difference, $datedue); - - my ($delays1,$delays2,$delays3)=GetOverdueDelays($borrower->{'categorycode'}); - my $issuingrules=GetIssuingRule($data->[$i]->{'itemnumber'},$borrower->{'categorycode'},$branchcode); - - UpdateFine($data->[$i]->{'itemnumber'},$data->[$i]->{'borrowernumber'},$amount,$type,$due); - + my $issuingrules=GetIssuingRule($borrower->{'categorycode'}, $data->[$i]->{'itemnumber'},$branchcode); + UpdateFine($data->[$i]->{'itemnumber'},$data->[$i]->{'borrowernumber'},$amount,$type,$due) if( $amount > 0 ) ; if($delays1 and $delays2 and $delays3) { my $debarredstatus=CheckBorrowerDebarred($borrower->{'borrowernumber'}); -- 2.39.5