From c1463e72554639e2f913d335d6008b2fa912dbb9 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Fri, 12 Nov 2010 16:30:45 +0100 Subject: [PATCH] Bug 5381 - Fines in notices prints always 0.00 This was due to passing off the biblionumber to GetFines rather than the itemnumber. Signed-off-by: Katrin Fischer Signed-off-by: Chris Cormack --- misc/cronjobs/overdue_notices.pl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 761644a021..92bc786a20 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -19,7 +19,6 @@ use strict; use warnings; -use utf8; BEGIN { @@ -256,7 +255,7 @@ my $csvfilename; my $htmlfilename; my $triggered = 0; my $listall = 0; -my $itemscontent = join( ',', qw( issuedate title barcode author biblionumber ) ); +my $itemscontent = join( ',', qw( issuedate title barcode author itemnumber ) ); my @myborcat; my @myborcatout; @@ -476,6 +475,7 @@ END_SQL $verbose and warn "debarring $borrowernumber $firstname $lastname\n"; } my @params = ($listall ? ( $borrowernumber , 1 , $MAX ) : ( $borrowernumber, $mindays, $maxdays )); + $verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber, mindays = $mindays, maxdays = $maxdays"; $sth2->execute(@params); my $itemcount = 0; my $titles = ""; @@ -492,14 +492,14 @@ END_SQL my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t", @item_info) . "\n"; $itemcount++; - push (@items, $item_info->{'biblionumber'}); + push @items, { itemnumber => $item_info->{'itemnumber'}, biblionumber => $item_info->{'biblionumber'} }; } $sth2->finish; $letter = parse_letter( { letter => $letter, borrowernumber => $borrowernumber, branchcode => $branchcode, - biblionumber => \@items, + items => \@items, substitute => { # this appears to be a hack to overcome incomplete features in this code. bib => $branch_details->{'branchname'}, # maybe 'bib' is a typo for 'lib'? 'items.content' => $titles @@ -657,12 +657,12 @@ sub parse_letter { # FIXME: this code should probably be moved to C4::Letters:pa $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'branches', $params->{'branchcode'} ); } - if ( $params->{'biblionumber'} ) { + if ( $params->{'items'} ) { my $item_format = ''; PROCESS_ITEMS: - while (scalar(@{$params->{'biblionumber'}}) > 0) { - my $item = shift @{$params->{'biblionumber'}}; - my $fine = GetFine($item, $params->{'borrowernumber'}); + while (scalar(@{$params->{'items'}}) > 0) { + my $item = shift @{$params->{'items'}}; + my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'}); if (!$item_format) { $params->{'letter'}->{'content'} =~ m/(.*<\/item>)/; $item_format = $1; @@ -671,10 +671,10 @@ sub parse_letter { # FIXME: this code should probably be moved to C4::Letters:pa my $formatted_fine = currency_format("$1", "$fine", FMT_SYMBOL); $params->{'letter'}->{'content'} =~ s/.*<\/fine>/$formatted_fine/; } - $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'biblio', $item ); - $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'biblioitems', $item ); - $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'items', $item ); - $params->{'letter'}->{'content'} =~ s/(.*<\/item>)/$1\n$item_format/ if scalar(@{$params->{'biblionumber'}} > 0); + $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'biblio', $item->{'biblionumber'} ); + $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'biblioitems', $item->{'biblionumber'} ); + $params->{'letter'} = C4::Letters::parseletter( $params->{'letter'}, 'items', $item->{'itemnumber'} ); + $params->{'letter'}->{'content'} =~ s/(.*<\/item>)/$1\n$item_format/ if scalar(@{$params->{'items'}} > 0); } } -- 2.39.5