From a52ccb24770a50bdd62624d5ac6ee26b3e066bc1 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 18 Oct 2024 15:17:29 +0000 Subject: [PATCH] Bug 19336: (QA follow-up) Tidy fines.pl Signed-off-by: Kyle M Hall --- misc/cronjobs/fines.pl | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 77d8e2cfd0..8e43b53ec2 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -56,12 +56,12 @@ my $command_line_options = join( " ", @ARGV ); cronlogaction( { info => $command_line_options } ); GetOptions( - 'h|help' => \$help, - 'v|verbose' => \$verbose, - 'l|log' => \$log, - 'o|out:s' => \$output_dir, - 'm|maxdays:i' => \$maxdays, - 'i|verifyissue' => \$verify_issue, + 'h|help' => \$help, + 'v|verbose' => \$verbose, + 'l|log' => \$log, + 'o|out:s' => \$output_dir, + 'm|maxdays:i' => \$maxdays, + 'i|verifyissue' => \$verify_issue, 'maxfinesdays=i' => \$maxfinesdays ); my $usage = << 'ENDUSAGE'; @@ -100,6 +100,8 @@ try { exit; }; +cronlogaction( { info => $command_line_options } ); + my @borrower_fields = qw(cardnumber categorycode surname firstname email phone address citystate); my @item_fields = qw(itemnumber barcode date_due); my @other_fields = qw(days_overdue fine); @@ -151,23 +153,28 @@ for my $overdue ( @{$overdues} ) { } ++$counted; - my ( $amount, $unitcounttotal, $unitcount); - if ( defined($maxfinesdays) && $maxfinesdays <= $datedue->delta_days( $today )->in_units( 'days' ) ) { + my ( $amount, $unitcounttotal, $unitcount ); + if ( defined($maxfinesdays) && $maxfinesdays <= $datedue->delta_days($today)->in_units('days') ) { my $itype = $overdue->{itemtype} || $overdue->{itype}; - my $data = Koha::CirculationRules->get_effective_rule( { rule_name => 'overduefinescap', categorycode => $patron->categorycode, itemtype => $itype, branchcode => $branchcode } ); - if ( defined($data->rule_value) ) { - $amount = $data->rule_value; + my $data = Koha::CirculationRules->get_effective_rule( + { + rule_name => 'overduefinescap', categorycode => $patron->categorycode, itemtype => $itype, + branchcode => $branchcode + } + ); + if ( defined( $data->rule_value ) ) { + $amount = $data->rule_value; $unitcount = 'n/a'; - } - else { - print "No overduefinescap defined for {branchcode = $branchcode, itemtype = $itype and categorycode = $patron->categorycode}\n"; + } else { + print + "No overduefinescap defined for {branchcode = $branchcode, itemtype = $itype and categorycode = $patron->categorycode}\n"; } } - if (!$amount) { - ( $amount, $unitcounttotal, $unitcount ) = CalcFine( $overdue, $patron->categorycode, $branchcode, $datedue, $today ); + if ( !$amount ) { + ( $amount, $unitcounttotal, $unitcount ) = + CalcFine( $overdue, $patron->categorycode, $branchcode, $datedue, $today ); } - # Don't update the fine if today is a holiday. # This ensures that dropbox mode will remove the correct amount of fine. if ( -- 2.43.0