From cf89f763f55dc17ce8b59c867d2aa19f45ed505d Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Sat, 31 May 2008 00:06:55 -0500 Subject: [PATCH] Fix typo in field name, apply branchcode selector logic from fines-ll. Signed-off-by: Joshua Ferraro --- misc/cronjobs/fines2.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/misc/cronjobs/fines2.pl b/misc/cronjobs/fines2.pl index 080b2e3dcf..fe2cfa14a2 100755 --- a/misc/cronjobs/fines2.pl +++ b/misc/cronjobs/fines2.pl @@ -88,6 +88,7 @@ sub insert_fine ($$$$$$) { return $fine_sth->execute(@_); } +my $circcontrol = C4::Context->preference('CircControl'); foreach (@$data){ my $date_due = $_->{date_due}; $verbose and print "date_due: $date_due ", ($date_due le $today_iso ? 'fine!' : 'ok'), "\n"; @@ -99,16 +100,18 @@ foreach (@$data){ my $borrower = BorType($borrowernumber); ($date_due le $today_iso) or next; # it is valid to string compare ISO dates. $overdueItemsCounted++ if $verbose; + my $branchcode = ($circcontrol eq 'PatronLibrary' ) ? $borrower->{branchcode} : + ($circcontrol eq 'ItemHomeLibrary') ? $_->{homebranch} : + $_->{branchcode} ; # Last option: Pickup Library. my $difference=$date-$date2; my (@calc_returns) = CalcFine( - $_, $borrower->{categorycode}, $_->{homebranch}, - undef, undef, C4::Dates->new($date_due,'iso'), $today_obj + $_, $borrower->{categorycode}, $branchcode,undef,undef, C4::Dates->new($date_due,'iso'), $today_obj ); if ($verbose) { my $dump = Dumper($_); $dump =~ s/;/,/; $verbose and print "CalcFine($dump" . - "\t$borrower->{categorycode}, $_->{homebranch},undef,undef,[$date_due],[today]) returns:\n" . Dumper(\@calc_returns), "\n"; + "\t$borrower->{categorycode}, $branchcode,undef,undef,[$date_due],[today]) returns:\n" . Dumper(\@calc_returns), "\n"; } my ($amount,$type,$printout) = @calc_returns[0..2]; # ($amount,$chargename,$daycount,$daycounttotal)=&CalcFine($itemnumber,$categorycode,$branch,$days_overdue,$description, $start_date, $end_date ); @@ -116,8 +119,8 @@ foreach (@$data){ ($amount > $maxFine) and $amount = $maxFine; if ($amount > 0) { UpdateFine($itemnumber,$borrowernumber,$amount,$type,$due); - if ($borrower->{'guarantor'}) { - $borrower->{'phone'} = get_guarantor_phone($borrower->{'guarantor'}) || $borrower->{'phone'}; + if ($borrower->{'guarantorid'}) { + $borrower->{'phone'} = get_guarantor_phone($borrower->{'guarantorid'}) || $borrower->{'phone'}; } print "$printout\t$borrower->{'cardnumber'}\t$borrower->{'categorycode'}\t$borrower->{'firstname'}\t$borrower->{'surname'}\t", "$_->{'date_due'}\t$type\t$difference\t", -- 2.39.5